Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal 'limit' line in Chart.js

Is it possibile to add a horizontal line to an existing chart in Chart.js?

Here the example char code:

// the canvas
<canvas id="myChart" width="800" height="200"></canvas>

// the js
var ctx = document.getElementById("myChart").getContext("2d");
var myNewChart = new Chart(ctx).Bar(data);

I want to add a horizontal marker line (eg. at y=100 like in this fiddle for highcharts)

like image 396
schlenger Avatar asked Feb 14 '15 17:02

schlenger


1 Answers

Yes you can actually do that. You want the horizontal marker line so you need to add this code inside your y-axis

plotLines: [{
            color: '#FF0000',
            width: 2,
            value: .50 * 200 // The marker value will be 100
                             // Or you can just set its value to 100
}]
like image 50
Nb12se Avatar answered Nov 11 '22 16:11

Nb12se