Skip to content

Instantly share code, notes, and snippets.

@dranney-sugarcrm
Created February 6, 2017 21:35
Show Gist options
  • Save dranney-sugarcrm/68dff0990fc56fb07cd38ddafc2d414b to your computer and use it in GitHub Desktop.
Save dranney-sugarcrm/68dff0990fc56fb07cd38ddafc2d414b to your computer and use it in GitHub Desktop.
Dynamically add elements to DOM and display new chart
({
...
renderChart: function () {
if (!this.isChartReady()) {
return;
}
var self = this;
var id_val = "";
var selector_str = "";
_.each(this.chartDataArr, function (data, key) {
id_val = 'example_chart' + key;
selector_str = '#' + id_val + ' svg';
$("#chart-section").append('<div id="' + id_val + '"><svg></svg></div>');
d3.select(self.el).select(selector_str)
.datum(data)
.transition().duration(500)
.call(self.chart);
});
this.chart_loaded = _.isFunction(this.chart.update);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment