Skip to content

Instantly share code, notes, and snippets.

@fxp
Created November 2, 2014 09:36
Show Gist options
  • Select an option

  • Save fxp/44f963268200d6a4f4e1 to your computer and use it in GitHub Desktop.

Select an option

Save fxp/44f963268200d6a4f4e1 to your computer and use it in GitHub Desktop.
chartjs: lose data point when .addData
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="http://www.chartjs.org/assets/Chart.min.js"></script>
</head>
<body>
<canvas id="mychart"></canvas>
<script>
var data = {
labels: [],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
}
]
};
var ctx = document.getElementById('mychart').getContext("2d");
var chartObj = new Chart(ctx).Line(data);
for (var i = 0; i < 4; i++) {
chartObj.addData([40], "asdsad");
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment