.show( opt )

Renders a cedar chart object into the specified element in the DOM.

chart.show({elementId:"#chartDiv"})

Arguments

Name Type Required Description
elementId string yes Id of the DOM node to render the chart into.
renderer string no svg or canvas (default) for drawing the chart.
width number no Explicit pixel width of chart. If not specified, will use width of elementId.
height number no Explicit pixel height of chart. If not specified, will use height of elementId.
maxLabelLength number no Explicit max length of axis labels. If set, axis labels will be truncated to the given length.
callback function no Function to call once the chart has been shown. Will be called with (err, data) arguments. If there was an error it will be available as err.

Example Code

<div id='chartDiv'></div>

<script>
var dataset = {
    "url":"https://services.arcgis.com/uDTUpUPbk8X8mXwl/arcgis/rest/services/Public_Schools_in_Onondaga_County/FeatureServer/0",
    "mappings":{
      "group": {"field":"District","label":"District"},
      "count": {"field":"Number_of","label":"Student Number_of"}
    }
  };

  var chart = new Cedar({"specification":"../../../cedar/data/templates/bar.json", "dataset": dataset});

//create and render a chart
chart.show({
  'elementId': '#chartDiv',
  'renderer': 'canvas'
}, function(err, data) {
  if (err) { console.log(err); }
});

</script>

Edit this page on GitHub