Skip to content

Commit f712870

Browse files
committed
Fixed: support for multiple graphs
1 parent edaddde commit f712870

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

appserver/static/visualizations/candlestick_chart/src/visualization_source.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ define([
2020

2121
initialize: function() {
2222
// Save this.$el for convenience
23-
this.$el = $(this.el);
2423

24+
// Handle multiple Graphs
25+
this.__uniqueID = Math.floor(Math.random() * 100000);
26+
27+
this.$el = $(this.el);
2528
// Add a css selector class
26-
this.$el.attr('id', 'candlestickContainer');
29+
this.$el.attr('id', 'candlestickContainer' + this.__uniqueID);
2730
},
2831

2932
getInitialDataParams: function() {
@@ -61,7 +64,7 @@ define([
6164
var dataSet = data
6265
// console.log("dataSet?" + dataSet);
6366

64-
Plotly.purge('candlestickContainer');
67+
Plotly.purge('candlestickContainer' + this.__uniqueID);
6568

6669
$('#' + this.id).empty();
6770

@@ -225,7 +228,7 @@ define([
225228
}
226229
};
227230

228-
Plotly.plot('candlestickContainer', data1, layout, {
231+
Plotly.plot('candlestickContainer' + this.__uniqueID, data1, layout, {
229232
displayModeBar: modeBar
230233
});
231234

0 commit comments

Comments
 (0)