chart.js has evolved since this question was posted but even with the current version 2.9.4, the solution looks almost the same as the originally posted code.

the main changes are the following:

  • instead of using new chart(ctx).line(...), we should now use type: 'line' as shown here.
  • quite some dataset properties have different names.
  • use the option borderdash to draw the dashed line of the second dataset.

please take a look at your amended code and see how it works.

var ctx = document.getelementbyid("main-line-chart").getcontext("2d");
var gradient = ctx.createlineargradient(0, 0, 0, 300);
gradient.addcolorstop(0, 'rgba(40,175,250,.25)');
gradient.addcolorstop(1, 'rgba(40,175,250,0)');

var data = {
  labels: ["january", "february", "march", "april", "may", "june", "july"],
  datasets: [{
      label: "my first dataset",
      backgroundcolor: gradient,
      bordercolor: "#28affa",
      pointcolor: "#19283f",
      pointhighlightcolor: "#28affa",
      data: [65, 59, 80, 81, 56, null, null]
      label: "my second dataset",
      fill: false,
      bordercolor: "rgba(100, 100, 100,.39)",
      pointcolor: "#19283f",
      pointhighlightcolor: "#28affa",
      data: [null, null, null, null, 56, 27, 90],
      borderdash: [10, 5]

var options = {};
var mylinechart = new chart(ctx, {
  type: "line",
  data: data,
  options: options
<script src=""></script>
<canvas id="main-line-chart" height="100"></canvas>

Related Query

More Query from same tag