-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type Error from chart.js using candlestick charts #128
Comments
bump - same here too. I think this is because |
Sweet - I figured out a short term fix. Where you have:
which will pull down the absolute latest version, replace it with the following snapshot from an earlier working version:
The long term fix is this library needs to be updated to supported the latest changes in v3.8.0. |
Same problem here. On Sunday candles disappeared from canvas and I got the same message as above on the console. Today the whole canvas disappeared from the page and I have new console errors. First a 404 and then this: Uncaught TypeError: Cannot read properties of undefined (reading 'DateTime') After a mail I have send to [email protected] I got this answer:Thank you for your email. I am afraid you have mistaken me for the web The candlestick plugin has not been modified since 2021. However, just a I would recommend if possible for you to downgrade the Chart.js version Do this, change your CDN link to specific CDN version so it will stay Best regards,
|
@Nireus79 oh man, this looks interesting. Been trying to shoe horn line graphs like EMA and VWAP along with candlesticks. Thanks for the tip. https://apexcharts.com/javascript-chart-demos/candlestick-charts/candlestick-with-line/ |
https://www.youtube.com/watch?v=ERgUCaYaI1Y On part 4 adds EMA line |
Tried apexcharts. Had problems with their multi Y axis scales. Got no support. It was a confirmation to keep on chart js. They are workin' on it. Fast. |
Any update on this? The original issue opened in the Chart js repo (#10665) had to do with |
Same here, does anybody found a solution other than downgrade to Chart js 3.7.1 ? |
I'm interested in a upgrade of this plugin. Maybe we could join us to make an effort team to migrate the plugin in way to be compatible with last charJS version ? |
@khalid10830, @firebird631 and anyone else watching this issue: I ran into this problem this past weekend when trying to upgrade my charts to the newest version of chart.js (v4.4.0). I spent some time trying to debug it myself hoping to come up with a "proper" solution that fixes the chartjs-chart-financial plugin, but it seems too daunting a task for me right now with my current lack of chart.js plugin development knowledge. The good news is that I was able to figure out a simple workaround to suppress the "String.prototype.toString requires that 'this' be a String" error msg which allows the chartjs-chart-financial plugin to be used with chart.js 3.8.0-4.4.0. To fix the error, all you need to do is specify the color attribute when you initialize your chart and it works on all versions from what I have seen. For example, to use the default candlestick colors you can initialize your chart like this:
Here's a working example using the most recent chart.js version: jsfiddle As mentioned above, I was unsuccessful in being able to fix this in the chartjs-chart-financial plugin code and don't have time to explore it further at the moment. Since we can prove that the financial plugin does in fact still work in chart.js v4.x as long as you explicitly specify the color object, I hope this knowledge may inspire someone with more time and/or understanding to procure a proper fix for this so that new chart.js users do not have to struggle like I did to make this work, In case it is useful, I would also like to provide some more insight into what I discovered when researching this problem: As indicated above, the chartjs-chart-financial plugin worked fine up until chart.js v3.8.0 when a change was made to the isPatternOrGradient function here: chartjs/Chart.js#10328 The problem is that the default color property sent to chart.js from the chartjs-chart-financial plugin throws an error when trying to run the following line from the isPatternOrGradient function:
I was able to prove that a small change to the isPatternOrGradient function in the chart.js code will prevent the "String.prototype.toString requires that 'this' be a String" error msg and not require any workaround. The consensus that I am getting from reading the comments of the chart.js devs regarding this problem is that they would like to see a fix to the chartjs-chart-financial plugin to correct this problem and therefore I have not bothered to submit a pull-request to correct this issue. If I am incorrect, I would ask that one of the chart.js devs please tag me here or get in contact with me and I will happily provide a pull request. In case someone else wants to add a pull request themselves, here is the proposed change: current isPatternOrGradient function code from /src/helpers/helpers.color.ts:
fixed isPatternOrGradient function code:
Here's a working example of the fix already in place that proves that updating the chart.js code will allow the current chartjs-chart-financial plugin to work with chart.js versions greater than v3.8.0: jsfiddle |
Here is the error:
Here is a simple coding example
<title>Document</title>`
The text was updated successfully, but these errors were encountered: