Anders Pedersen
Anders Pedersen

Reputation: 2395

drawing line chart with chartjs

I'm trying to draw a line chart with chartjs, but i can't get it working - keep getting 't is undefined' error.

here is my fiddle example: http://jsfiddle.net/6bjy9nxh/344/

can anyone figure out what im doing wrong here?

chartjs: http://www.chartjs.org/docs/#line-chart-example-usage

cdn: https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js

html

<canvas id="myChart" width="500" height="350"></canvas>

javascript

var ctx = document.getElementById("myChart");

var data = {
  labels: ["January", "February", "March", "April", "May", "June", "July"],
  datasets: [
    {
          label: "My First dataset",
          fill: false,
          lineTension: 0.1,
          backgroundColor: "rgba(75,192,192,0.4)",
          borderColor: "rgba(75,192,192,1)",
          borderCapStyle: 'butt',
          borderDash: [],
          borderDashOffset: 0.0,
          borderJoinStyle: 'miter',
          pointBorderColor: "rgba(75,192,192,1)",
          pointBackgroundColor: "#fff",
          pointBorderWidth: 1,
          pointHoverRadius: 5,
          pointHoverBackgroundColor: "rgba(75,192,192,1)",
          pointHoverBorderColor: "rgba(220,220,220,1)",
          pointHoverBorderWidth: 2,
          pointRadius: 1,
          pointHitRadius: 10,
          data: [65, 59, 80, 81, 56, 55, 40],
      }
  ]
};

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

Upvotes: 0

Views: 3566

Answers (1)

Alex Baban
Alex Baban

Reputation: 11742

You are including version 1, you need version 2 for Chart.js

https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js

http://jsfiddle.net/x55sgzgf/

Upvotes: 3

Related Questions