in polymer i try
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
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: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var ctx = this.$.mychart.getContext("2d")
//var ctx = this.getElementById("mychart").getContext("2d");
//d= document.createElement("canvas")
console.log(ctx)
var myLineChart = new Chart(ctx).Line(data);
i got this error
Uncaught TypeError: (intermediate value).Line is not a function
@luluprat what version of Chart.js are you using?
I try 3 version with bower installation:
master
2 beta
2 dev
Might it be related to this?: http://stackoverflow.com/questions/23370269/jquery-autosize-plugin-error-intermediate-value-is-not-a-function
Missing semi colon on var "ctx = this.$.mychart.getContext("2d")" and "console.log(ctx)"
no thanks i get the same error with
<!doctype html>
<html>
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="bower_components/Chart.js/Chart.js"></script>
<canvas id="canvas" width="300" height="300"></canvas>
<script>
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
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: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var ctx = document.getElementById("canvas").getContext("2d");
//var ctx = this.getElementById("mychart").getContext("2d");
//d= document.createElement("canvas")
console.log(ctx);
var myLineChart = new Chart(ctx).Line(data);
</script>
Most helpful comment
@luluprat the method of instantiating charts has changed in v2. You can find documentation at http://nnnick.github.io/Chart.js/docs-v2/