AnsweredAssumed Answered

Cedar chart not updating

Question asked by bem08c on Dec 23, 2016

HI all. I'm using Cedar to build a chart on a website. The data for the chart is being pulled from a Survey123 layer. This way when I submit something to Survey123 the chart will be automatically. My problem is that when I submit somthing to Survey123 my chart is not updating when the page is reloaded. Does anyone see anything wrong with my chart code? Im very new to JavaScript..

Thanks

 

<script>

  var chart = new Cedar({"type": "bar-horizontal"});

  //create the dataset w/ mappings
  var dataset = {
    "url":"https://services7.arcgis.com/2lya1j9hNfBnQwN6/arcgis/rest/services/survey123_xxxxxxxxxxxxxxxx/FeatureServer/0",
    "query": {
      "groupByFieldsForStatistics": "field_0",
      "outStatistics": [{
        "statisticType": "count",
        "onStatisticField": "field_0",
        "outStatisticFieldName": "Number_of_SUM"
      }]
    },
    "mappings":{
      "y": {"field":"field_0","label":"Food?"},
      "x": {"field":"Number_of_SUM","label":"# of Eats"}
    }
  };
  //show the chart
  chart.show({
    elementId: "#chart"
  });
 
  //assign to the chart
  chart.dataset = dataset;

  chart.update();

</script> 

Outcomes