简体   繁体   中英

Extend chart.js horizontal bar graph to include a vertical line

I'm trying to add a vertical line to at a set point of a horizontal bar chart. Examples I've found do not seem to apply to charts.js 2. Even if I create a new chart type and use the horizontalBar draw method with no modifications, the chart won't draw.

Chart.controllers.horizontalBarWithLine = Chart.controllers.horizontalBar.extend({
    draw: function () {
        Chart.controllers.horizontalBar.prototype.draw.apply(this, arguments);
    }
});

Can anyone explain how to extend this chart?

Here's my current attemp: https://jsfiddle.net/dwelch/6f1gfog2/

Please see my answer to this question. I think this is what you are looking for:

How do I draw a vertical line on a horizontal bar chart with ChartJS?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM