Search code examples
javascriptdygraphs

Is it possible to draw closed shapes in Dygraphs?


I know that closed shapes are not functions, because there can be more than one y value for each x value. The easiest example is a circumference.

I was wondering if it's possible to draw a closed shape in dygraphs. Basically what i would love to do is to draw a path with Dygraph using a list of GPS points.

I tried simply to give those GPS point to dygraphs, but unfortunately nothing good came out.

Thanks


Solution

  • dygraphs is designed for rendering time series and data sets that look like time series. It's not particularly good at scatter plots like yours.

    If you really want to give it a shot, here's one idea: make a data set where the three columns are point number, latitude and longitude. dygraphs will think that point number is the x-axis but you can trick it by setting both dateWindow (to control the x-axis range) and valueRange (to control the y-axis range). Then you'll need to write a custom plotter to draw the closed shape using the latitudes and longitudes.