Fixed axis scale with elm-plot

If anyone has used elm-plot before I need a little help. I am using elm-plot to create graphs in which I add data dynamically (using a time subscription). Using the default axis settings, the size of the vertical axis changes depending on the range of the y data. This means that every time I add a new data point to the data, the axis resizes. Is it possible to create a custom axis with a fixed (user-defined) scale?

Thanks in advance.

Iā€™m guessing maybe something like

fixedRangePlot minY maxY =
    viewSeriesCustom
        { defaultSeriesPlotCustomizations
            | toRangeLowest = always minY
            , toRangeHighest = always maxY
        }
1 Like

Thank you! That got me must of the way there. I imported elm-plot like this:

import Plot as P

and when I try to modify P.defaultSeriesPlotCustomizations the compiler complains that it is expecting white space or a lower case word. The only thing I could figure to get around this was to pass the default settings to the function. In case someone find this useful the code would look like this:

import Plot as P
...
fixedRangePlot default minY maxY =
    P.viewSeriesCustom 
        { default
           | toRangeLowest = always minY
           , toRangeHighest = always maxY
        }

You could also expose the default configuration in the plot import. :slight_smile:

1 Like