Pepp Pia
Pepp Pia

Reputation: 23

How does display chart javascript?

i'm working on web application and i need to use library "Chart.js".I'm testing the code on "jsfiddle" and i don't know why this doesn't work! Thanks for help. <body> <canvas id="myChart" width="600" height="600"></canvas> </body> var data = {

                labels: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto"], 
                datasets: [ 
                    { 
                        label: "Temperature 2013", 
                        fillColor: "rgba(99,240,220,0.2)", 
                        strokeColor: "rgba(99,240,220,1)", 
                        pointColor: "rgba(99,240,220,1)", 
                        pointStrokeColor: "#fff", 
                        pointHighlightFill: "#fff", 
                        pointHighlightStroke: "rgba(220,220,220,1)", 
                        data: [8, 11, 18, 22, 24, 26, 34, 39] 
                    }, 
                    { 
                        label: "Temperature 2014", 
                        fillColor: "rgba(205,99,151,0.2)", 
                        strokeColor: "rgba(205,99,151,1)", 
                        pointColor: "rgba(205,99,151,1)", 
                        pointStrokeColor: "#fff", 
                        pointHighlightFill: "#fff", 
                        pointHighlightStroke: "rgba(151,187,205,1)", 
                        data: [16, 18, 22, 24, 26, 28, 32, 36] 
                    } 
                ] 
            };

var ctx = document.getElementById("myChart").getContext("2d"); var myLineChart = new Chart(ctx).Line(data);`JSFIDDLE

Upvotes: 0

Views: 147

Answers (1)

surfmuggle
surfmuggle

Reputation: 5944

I changed both links to https and changed this

   var myLineChart = new Chart(ctx).Line(data);

 // to this
   var myLineChart = new Chart(ctx, {
    type: 'line',
    data: data
});

The Example renders two lines.

Upvotes: 0

Related Questions