I'm using Chart.js and I will create a small bar chart. How can I draw red line on y axis (without create new datasets) in any point like on picture?
It's not problem to create this line in different kind of chart, but in bar chart I cannot find any solution for this.
My code:
<!doctype html>
<html>
<head>
<title>Bar Chart</title>
<script src="../Chart.js"></script>
</head>
<body>
<div style="width: 50%">
<canvas id="canvas" height="450" width="600"></canvas>
</div>
<script>
var randomScalingFactor = function(){ return Math.round(Math.random()*70)};
var orders = [ '181-1','181-2','181-3','182-1','183-1','183-2','183-3','183-4','184-1','184-2'];
var barChartData = {
labels : orders,
datasets : [
{
label: "Order",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data : [6,randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),5,6]
}
]
}
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
var chart = new Chart(ctx).Bar(barChartData, {
responsive : true,
animation: true,
barValueSpacing : 5,
barDatasetSpacing : 1,
tooltipFillColor: "rgba(0,0,0,0.8)",
// multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"
tooltipTemplate: function(valuesObject){
console.log(valuesObject);
// do different things here based on whatever you want;
var label = valuesObject.label
var objLen = label.length;
// 111-1
var string = label.substring(0,objLen-2);
console.log(string);
return "Order nr: " + string;
}
});