问题
With a Chart.js - Bar Chart how to add a straight line for achievements such as if over 75/100 is a pass - so need a line in the 75 count. or a thick line on the grid... 4px solid etc...
http://drawingwithnumbers.artisart.org/wp-content/uploads/2013/03/v8-simple-measures.png Like the green stripped line (Target 0.7) on the right hand side...of this image...
So if I use this fiddle as an example... would need a straight line at values 75000 http://jsfiddle.net/rnX2Z/1/
Was trying to add this code with no luck...
var c = document.getElementById("canvas");
var ctx = c.getContext("2d");
ctx.moveTo(0,200);
ctx.lineTo(500,200);
ctx.stroke();
Was looking at adding a line on the canvas - but have trouble with the code - or do I have to add some code to the .js... any help or a direction to take, as the rest of the charts look fantastic .. would be cool... thanks
回答1:
If the chart is from highcharts.com, as per example...
http://jsfiddle.net/wergeld/hXDYh/2/
<script type="text/javascript" src="http://code.highcharts.com/highcharts.src.js"></script>
<div id="container" style="height: 400px"></div>
and then lots of Javascript ... etc... needs a JSON / Data of Plot line and Color
Not sure about - ChartJS - have not found info for this - possible a SVG ?
Not sure why a -1 before I added this answer... More of a suggestion for anyone reading this...
Cheers Simon
来源:https://stackoverflow.com/questions/25553051/chart-js-how-to-add-a-line-in-the-canvas-for-bar-chart