Esri / cedar

JavaScript Charts for ArcGIS
https://esri.github.io/cedar
258 stars 238 forks source link

Possible to have multiple series on a time chart? #275

Open simongis opened 7 years ago

simongis commented 7 years ago

Likely a rookie error, but is it possible to have multiple lines on a line chart?

Sample app here

The request seems to be returning the expected results from the service, but I must be missing something in parsing the results into the chart.

var chart = new Cedar({"type":"time"});

  var datasets = [
    {
      "url": "https://services1.arcgis.com/vHnIGBHHqDR6y0CR/ArcGIS/rest/services/CrashStats_2017/FeatureServer/0",
      "query": {
        "orderByFields": "accident_date",
        "groupByFieldsForStatistics": "accident_date",
        "outStatistics": [
        {
        "statisticType": "sum",
        "onStatisticField": "bicyclist",
        "outStatisticFieldName": "bicyclist_SUM"      
        },
        {
        "statisticType": "sum",
        "onStatisticField": "pedestrian",
        "outStatisticFieldName": "pedestrian_SUM"     
        }
        ]
      }
    }
  ];

  var series = [
    {
      "category": { "field": "accident_date", "label": "Date" },
      "value": { "field":"bicyclist_SUM","label":"Bikes" }
    },
    {
      "category": { "field": "accident_date", "label": "Date" },
      "value": { "field":"pedestrian_SUM","label":"Peds" }
    }

  ];

  chart.datasets = datasets;
  chart.series = series;
chart.show({
  elementId: "#chart",
  autolabels: true
});
tomwayson commented 7 years ago

@simongis no, not a rookie error. This is coming soon in v1, working on it now actually. What's confusing is that in the transition period we went ahead an updated the JSON API to take multiple series, but we are currently ignoring all but the first.

I will report back on this issue when the beta is ready for testing.

simongis commented 7 years ago

Thanks @tomwayson. Whats the ETA for v1? Assume it would be after our conference in a couple of weeks?

tomwayson commented 7 years ago

Working to have a publicly available beta by the end of this week.

simongis commented 7 years ago

That's great. Can you respond on this issue when it is available and I will add an iFrame to the prototype site we will be showing.

tomwayson commented 7 years ago

Of course. The site's looking good!

tomwayson commented 7 years ago

FYI - you can track progress on our beta here: https://github.com/Esri/cedar/labels/v1-beta

Unfortunately that list keeps growing instead of shrinking. Looks like I was overly optimistic to think that it would be available by the end of the week. 😞

tomwayson commented 7 years ago

So yeah, over 2 months later, an alpha release is finally available: https://github.com/Esri/cedar/releases/tag/v1.0.0-alpha