score:2
Accepted answer
U can customize code before draw it
Working demo : https://jsfiddle.net/4rasm1hc/
let draw = Chart.controllers.line.prototype.draw;
Chart.controllers.line = Chart.controllers.bar.extend({
draw: function() {
draw.apply(this, arguments);
let ctx = this.chart.chart.ctx;
let _stroke = ctx.stroke;
ctx.stroke = function() {
ctx.save();
ctx.shadowColor = '#000000';
ctx.shadowBlur = 10;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 4;
_stroke.apply(this, arguments)
ctx.restore();
}
}
});
Chart.defaults.LineWithLine = Chart.defaults.bar;
Chart.controllers.LineWithLine = Chart.controllers.bar.extend({
draw: function(ease) {
Chart.controllers.line.prototype.draw.call(this, ease);
if (this.chart.tooltip._active && this.chart.tooltip._active.length) {
var activePoint = this.chart.tooltip._active[0],
ctx = this.chart.ctx,
x = activePoint.tooltipPosition().x+15,
topY =6000,
width=activePoint._view.width,
bottomY = 0;
console.log(activePoint);
// draw line
ctx.save();
ctx.beginPath();
ctx.moveTo(x, topY);
ctx.lineTo(x+width-10, bottomY+30);
ctx.lineWidth = width*4;
ctx.strokeStyle = '#e5e0e01a';
ctx.stroke();
ctx.restore();
}
}
});
Source: stackoverflow.com
Related Query
- How to add second Y-axis for Bar and Line chart in Chart.js?
- how to add a title to my ng2-charts bar chart
- How to add background image in bar chart column in Chart.js?
- How to add "shadow" on hovering bar chart?
- How to add unused data background to bar in chart js
- How to add labels on top of the chart bar with Chart.js 2
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- How to add data labels in each bar in stacked bar chart in chart.js?
- How to add label square to Bar Chart using Chart.js
- How to add vertical line in bar chart using chartJs and ng2-charts?
- How to add text inside the doughnut chart using Chart.js?
- chart js 2 how to set bar width
- Chartjs Bar Chart showing old data when hovering
- Chart.js Bar Chart - how to chart bars from 0
- How to add an on click event to my Line chart using Chart.js
- How to put rounded corners on a Chart.js Bar chart
- chartjs : how to set custom scale in bar chart
- Add DataSet Bar Chart - Chart.JS
- How to add an offset to a dataset in Chart js
- ChartJS add tooltip to a grouped bar chart
- How to add text in centre of the doughnut chart using Chart.js?
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to display inline values in a stacked bar chart with Chart.js?
- How to add datas to chart js from javascript array itself?
- Chart.js - Add gradient to bar chart
- How to add panning to chart in chartjs?
- ng2-charts customize data and whole html content of tooltip displayed when hovering on bar chart
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to have solid colored bars in angular-chart bar chart
More Query from same tag
- A chart Js error issue are occured in my Laravel other page?
- Hide all scale labels in chartjs
- How to update ChartJS in a long polling & stop animation stuttering?
- Group Chart with multiple layers in ChartJS
- How can I update my ChartJS in real time (It's works only when I zoom-in and zoom-out)
- Make Line Chart Dynamic From JSON File Using Chartjs
- chart.js how to show tick marks but hide gridlines
- How do I update the Chart.js automatically every 2 seconds?
- passing each element of array in the labels of char.js
- Change Angular js charts.js chart type dynamically
- Chart js size and placement
- How to only draw the graph and the Xaxis gridlines using chart.js
- show multiple responsive chart in the same page using chart.js
- Chart.js line chart tooltip shows wrong label when line doesn't start at first label
- Connecting Two Datasets in Chart.js Into a Single Line
- How to highlight a section of a stack in all bars in a stacked barchart in chartjs
- Prevent chart.js "jumping"
- Chart.js Stacked Group Bar model after updating version Chart.js 2.9.4 -> Chart.js 3.5.0
- Load Chart.js tooltip information asynchronously
- Why is here a number?
- How do I force Chart.js axes min and max with react-chartjs-2?
- Combine Chart.js programmatic and legend based dataset toggling
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- How to dynamically set backgroundColor and borderColor barchart unsing Chart.js
- Chart JS version 3+. How to get a tick's label in a tick callback function?
- chartjs - How to access chart instance in a custom tooltip callback
- Is there a way to represent date hole in chartjs time series?
- Chart.js - disable tooltip when cursor moves outside the main canvas
- Add labels to bar chart: chartjs
- ChartJs Stacked Bar Chart