Setting an onclick event which causes an error can fire multiple times, which I don't think should be able to happen.
If there are no errors in the onclick event, it works as expected and only fires once. If there is an error, whenever you go back and hover over the chart the onclick begins to fire for every hover event and can throw many errors in the console. I would expect even if there is an error for the onclick to only ever fire when clicking the chart.
I modified one of the examples and saw the behavior there, so it is not specific to my code.
I am running Chrome Version 46.0.2490.86 (64-bit) on Mac OSX 10.10.5
See the modified stacked bar chart example below:
<script>
function success(data){
data.dataLimitFrom = 0;
data.dataLimitTo = 0;
for (var i in data.values) {
if (data.dataLimitFrom == 0) {
data.dataLimitFrom = data.values[i][0];
}
data.dataLimitFrom = data.dataLimitFrom > data.values[i][0] ? data.values[i][0] : data.dataLimitFrom;
data.dataLimitTo = data.dataLimitTo < data.values[i][0] ? data.values[i][0] : data.dataLimitTo;
}
t = new TimeChart(
{
container: document.getElementById("demo"),
data:
{
units:["d"],
preloaded: data
},
events: {
onClick: function(){
console.log("error");
var test = {};
test.test.test = "test";
},
},
valueAxisDefault: { title: "Amount, metric tons" },
series:[
{
name:"Total",
id:"total",
type:"line",
data:{
index:1,
aggregation:"sum"
},
style:{
lineColor:"#666",
fillColor:"rgba(0,0,0,0.2)",
lineWidth: 1,
smoothing: true
}
},
{
name:"Gas fuel",
id:"series1",
type:"columns",
data:{
index:2,
aggregation:"sum"
},
stack: "default",
style:{
fillColor:"#85732c"
}
},
{
name:"Liquid Fuel",
id:"series2",
type:"columns",
data:{
index:3,
aggregation:"sum"
},
stack: "default",
style:{
fillColor:"#8c9937"
}
},
{
name:"Solid Fuel",
id:"series3",
type:"columns",
data:{
index:4,
aggregation:"sum"
},
stack: "default",
style:{
fillColor:"#697e0b"
}
},
{
name:"Cement",
id:"series4",
type:"columns",
data:{
index:5,
aggregation:"sum"
},
stack: "default",
style:{
fillColor:"#4c5510"
}
},
{
name:"Gas Flaring",
id:"series5",
type:"columns",
data:{
index:6,
aggregation:"sum"
},
stack: "default",
style:{
fillColor:"#303d0e"
}
}
],
navigation: {
initialDisplayUnit: "10 y",
initialDisplayPeriod: "250 y",
initialDisplayAnchor: "newestData"
},
area: {
displayUnits: [
{name: "year", unit: "1 y"},
{name: "10 years", unit: "10 y"},
{name: "50 years", unit: "50 y"}
]
},
currentTime: {enabled: false}
}
);
}
// using a custom library to load CSV data
loadCSV("/dvsl/data/time-chart/global-emissions.csv", "d", [
{type: "date", format: "([0-9]+)", fields: [1,2,3], process:
[null,function(a){return parseInt(a)}, function(b){return 1}, function(b){return 1;}]},
{type: "decimal"},
{type: "decimal"},
{type: "decimal"},
{type: "decimal"},
{type: "decimal"},
{type: "decimal"}
], ",", success);
</script>