How to convert this V1.0 Line Extend function to 2.0?
See original GitHub issueHello,
I came across a function in Stack Overflow that allows me to draw a vertical line at any axis I want. However, it was written for v1.0 and no longer works for 2.0. If I use it with the newer version I get this error:
Cannot read property ‘extend’ of undefined.
Can anyone assist me in converting the syntax so that it is compatible with version 2.0?
Here is the function:
Chart.types.Line.extend({
name: "LineWithLine",
draw: function () {
Chart.types.Line.prototype.draw.apply(this, arguments);
var point = this.datasets[0].points[this.options.lineAtIndex]
var scale = this.scale
// draw line
this.chart.ctx.beginPath();
this.chart.ctx.moveTo(point.x, point.y);
this.chart.ctx.strokeStyle = '#ff0000';
this.chart.ctx.lineTo(point.x, scale.endPoint);
this.chart.ctx.stroke();
// write TODAY
this.chart.ctx.textAlign = 'center';
this.chart.ctx.fillText("TODAY", point.x, scale.startPoint + 12);
}
});
Here is a JSFiddle that uses it: http://jsfiddle.net/dbyze2ga/14/
Here is a JsFiddle with 2.0 that I’m trying to get the function to work on: https://jsfiddle.net/L5069q3j/
Any help would be appreciated!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
.net - Azure Function Converting v1 to v2 DotNetStandard ...
Using Visual Studio 2017 go to File -> New -> Project -> Azure Functions -> Ok · Choose Azure Functions v2 (. ·...
Read more >Manage functions | Cloud Functions for Firebase - Google
Manage functions · On this page · Deploy functions · Delete functions · Modify a function's name, region or trigger. Rename a function;...
Read more >Changes from v1.1 to v2.0 - AutoHotkey
The translation from v1-command to function is generally as follows (but some functions have been changed, as documented further below):. If the command's...
Read more >Upgrade Guide - Tailwind CSS
Upgrading from Tailwind CSS v1.x to v2.0. Tailwind CSS v2.0 is the first new major version since v1.0 was released in May 2019,...
Read more >Python Tutorial - Getting Started with Python and Python Basics
The conversion formula is: hn-1hn-2...h2h1h0 = hn-1×16 n-1 + hn-2×16 n-2 + . ... multiple lines >>> x = [1, 22, 333] #...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use the Chart Annotation plugin (https://github.com/chartjs/chartjs-plugin-annotation)
Fiddle - https://codepen.io/anon/pen/ZywgKr
https://github.com/abelheinsbroek/chartjs-plugin-crosshair