-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
State of Chart.js & V3.0 #6598
Comments
I would like to work on
Should I do this within the current code base (may take a day for the whole projet, I could start during the upcomming weekend) aka |
@sebastianniemann I think that's the best way to do it. We've already started merging breaking changes to master. If we need to do 2.9.x hotfixes we'll do that in a separate branch. @benmccann @kurkle thoughts? |
Yes, go for it! I would love that :-) |
Chart.js currently struggles with hover / live value display in large datasets. Might want to also look into this. |
Good suggestion! I filed #6716 to discuss and track that issue |
Should we consider dropping IE support? It would make some new things available: Another thing worth exploring is ResizeObserver. That could be used, instead of current implementation, if supported. |
As much as I'd love to drop IE, I think there are still too many IE 11 users. The main website I'm working on right now has ~5% of traffic in IE. But it'd be great to use |
I recall |
as another datapoint, our IE11 traffic for the past 2 weeks has been 2.65%, it was 5.62% for the same period last year. (usa, ecommerce, home remodeling industry). at some point, as a lib/web author you gotta ask yourself whether maintaining IE11 compat further delays its inevitable death. |
For |
Hello - is there any movement towards enabling Chart.js to be used inside a web worker controlling an offscreencanvas? I've seen this issue: #5355. If it's appropriate I'd be interested in taking on the necessary work to get it working. Let me know if there's anywhere I should get started! I'll probably be submitting some speculative PRs for this soon. Context: a major project that we'll be taking on for https://github.com/cruise-automation/webviz in the near future is moving our Chart panel behind a web worker for performance reasons. We use Chart.js currently and love it, and we'd like to keep using it. |
@davidswinegar I haven't tried anything yet. However, I think the limitations would be similar to those for server-side rendering. I know that has been done a fair bit with Chart.js (example: https://github.com/shellyln/chart.js-node-ssr-example). I think you would need to disable resizing since that needs access to the DOM. I also don't know if
I am curious though, are you hitting performance bottlenecks in Chart.js itself? If so, you might like to try the latest code from master (will eventually release as v3) because @kurkle and @benmccann have been doing lots of performance improvements. |
@etimberg thanks for the info! I am hitting performance issues in Chart.js, though I'm not sure if it's because of the library itself or the fundamental cost of drawing on the canvas. I'll do some benchmarks on the code that's in master and see how it affects us. |
Sounds good. There are lots of breaking changes in master, and docs on those are https://www.chartjs.org/docs/master/getting-started/v3-migration.html |
Most of the work in 2.x is not related to drawing on the canvas. I think most of that work can be removed. A good chunk already has been. After that's done I don't know if web workers would still provide benefit? If you use the version from |
I tried the version in master and followed the performance documentation and I definitely noticed an improvement! Thanks for the feedback., Our product requirements mean that this improvement won't be enough, though, and that we'll still have to put Chart.js behind a web worker. I'll take this to Slack to work through some approaches on the details. For context, we're updating 5+ charts many times a second and attempting to play back data in real-time without dropping any data; our performance characteristics need to be closer to games than to analytics web applications. Regardless of how performant Chart.js is, passing data over a web-worker connection and drawing it from there is necessary for us to squeeze every cycle out of the browser - if we were writing our own performance optimized canvas library we'd still have to do this. |
@davidswinegar if these are line charts, you can try uPlot to get an idea of what's possible in terms of performance. |
I'm aiming to get about another 10x increase in performance. I have a handful of pending PRs that are all geared towards improving performance. I'm happy discuss the web worker approach or any other perf ideas over Slack as you suggested |
😮 that would be impressive! uPlot is currently at 40ms, Chart.js master is 305ms. 10x faster would be 25% faster than uPlot and i'm not really sure where i can shave a full 10ms! |
@leeoniya your numbers look impressive! I think that Chart.js is the choice for us because of support for panning & zooming, and more chart types, but I'll keep uPlot in mind. |
Re 10x: It depends which charts you're drawing, what dates you're comparing (e.g. @davidswinegar depending how much you want to experiment you can try grabbing my two pending PRs. It gets Chart.js line charts from 550ms down to 100ms on the uPlot benchmark on my machine compared to 70ms for uPlot: #6881 (comment). The "fastline" PR may be released as an external plugin rather than being merged into core, but should allow you to use other plugins with it still such as zoom/pan, etc. I'm curious what other chart types and scale types you use. I've been most focused on optimizing the time scale and line charts since that's what I use most myself |
I've seen that going to v3, the Do you think this new feature could be re-thought again? |
You can hook on the canvas click even directly to catch all clicks. |
But in this case you have more listeners instead of one. It sounds redundant, in my opinion. |
@Cristy94 I'm using alfa.2 for production too. I think the best docs for v3 at the moment is migration doc: https://www.chartjs.org/docs/next/getting-started/v3-migration |
With the alpha2, I was able to reproduce about 20 of my company's charts. Bars, pies and lines with different aspects of legends, title, tooltips, stacked, etc... I had some issue with the "pie" type where having the scaling configuration from "line" made it explode. Can I already consider the API as stable? I didn't see many changes on the API in the last months (due to COVID19 effect maybe?) |
A bit offtopic and advertising. I wrote a React wrapper for chat.js version 3. I use it for production. P.S. Forgive me if this is not correct, I am not very familiar with the rules in open source projects. @darkship the tooltips callbacks have been heavily modified. IMO |
I'm looking forward to being able to use chart.js v3 in my angular project. Hopefully ng2-charts will update and I'll be free of the new angular 10 warnings about commonjs/amd libs. I'd like to throw my 2 cents about IE11 support and recommend that you drop support for it. Bootstrap 5 will no longer support among the many many sites that are dropping support for it. If people still need IE11 they should stay on chart v2 or they can use polyfills. Much like the BS 5 - IE11 discussion I agree that library's should no longer held back by IE11 and that forward momentum is only possible by dropping support for it. |
Clarifying to answer the question asked in #6598 (comment)
Is there any date-adapter which is already ported to work with the |
chartjs-adapter-date-fns@next |
Guys, please do not consider me arrogant, but there are plans for the version of Beta.2? |
@xr0master I was waiting until #7806 got in before cutting a new release. |
#7806 was merged already in september. |
@literakl that released in v3.0.0-beta.2. |
Question about tree shaking in v3. Given the following:
and a basic chart config:
|
Is there an expected approximate release date for ChartJs 3? |
I'm also interested to know if there is an expected approximate release date for ChartJs 3, please? |
Is there an adapter for |
No specific date yet @Homand-Cindy. #8008 is what we're trying to get done before the release. @derwaldgeist I think you could easily create your own adapter for dayjs based off the moment adapter source https://github.com/chartjs/chartjs-adapter-moment |
@derwaldgeist, there's a few on npm, however the oldest I believe is unmaintained. The other two with recent releases also support Chart.js v3 I believe. https://www.npmjs.com/search?q=chartjs-adapter-dayjs But we also did what @etimberg said and adapted the official moment adapter. However that was two years ago. |
Creating a dayjs adapter should be extremely simple since dayjs uses most of the same method names as moment. First thing I'd do is is just do a find and replace and see what happens |
I have a project using Chart.js v3 right now. I just inlined the luxon adaptor since the repo wasn't updated at the time. Works quite well and was easy to set up |
Yes, I was thinking about doing that.
Thanks for the info! |
Looks like most of the PRs are already merged, any info on what is holding before the v3 stable release? |
The first release candidate, v3.0.0-rc was released today. |
3.0 final is available
We're proud to announce that Chart.js 3.0.0 is now available. Get it with
npm install --save chart.js
Overview
Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released in April 2016. In the years since then, as Chart.js has grown in popularity and feature set, we've learned some lessons about how to better create a charting library. In order to improve performance, offer new features, and improve maintainability, it was necessary to break backwards compatibility, but we aimed to do so only when worth the benefit. Some major highlights of v3 include:
In this issue we'll maintain a list of committed, nice-to-have, and proposed features for v3. Feedback from the community will help shape the prioritization for v3.
Committed Features
Rollup configured for ES6+ babel translation (Add babel plugin for rollup & transform code #6555)Removecustom
(Remove undocumented "custom" feature #6605)grep -ri backward src
still returns a handful of results. Also need to search the code for TODOsPrefix all private methods with underscoreMake ticks objects (Consider making ticks objects #5019)(or not? should we revert? see Remove ticksToTimestamps and change ticks to numbers #6791)Removemoment
frompackage.json
(Remove moment from dependencies #6745), move the moment adapter to an external project, and remove the rollup optional pluginRemovezeroLineIndex
feature and replace with function based axis properties (Remove zeroLineIndex functionality #6697 & Allow functions to be specified for scale grid line options #6700)Change, adopt ES6 classes, userequire
toimport
const
/let
, etc.Change axis options from an array to an object keyed by ID (Convert axis options from arrays to objects #6773)CleanupgetPixelForTick
(getPixelForTick is confusing and possibly inconsistent #6715)Accept data in a format that doesn't require parsing (Consider new format for passing data in #6696)Improve performance of finding hovered element (Improve hover performance #6716)Split_options
out of_model
. Creating_model
is expensive right now, since it's done for each data point. However,_options
does not need to be recreated for each data point unless scriptable options are being used. Thus by just using_options
directly instead of copying it into_model
we would be much more performant (Rewrite animation logic #6845)Reduce number of objects created (e.g._view
and_model
) when animation is disabled (e.g. Performance optimizations when animations are disabled #6710).MakebeginAtZero
default betrue
for bar chart (Change scale.beginAtZero default to true #5939)remove(Global datasets options thought #6684 Remove global from defaults #6893)global
from options namespaceStandardize on using degrees for angles (Polar area: startAngle in degrees, 0 at top. #6936)Migrate docs from GitBook to Docusaurus (Migrate from GitBook to Docusaurus #7295)Support tree shaking / individual module imports (v3: consider changing export logic for esm modules #7371)RemovehorizontalBar
and make all charts capable of being horizontal (Replace horizontalBar with indexAxis: 'y' #7144)Proposed / Nice to Have Features
options.scales
andoption.scale
keys for all chart typesRemove overrides of_resolveDataElementOptions
and_resolveDatasetElementOptions
(Option resolution with proxies #8374)Make_dataElementOptions
an array in all controllers (i.e. line and radar). (Option resolution with proxies #8374)Ensure user-specified options are applied after defaults. Delete_config
and have just a single object holding resolved options (Option resolution with proxies #8374)chart.options
private and immutable (user should not directly edit, but should pass in new config to merge)Cleanup interactions options (Add interaction options #7922)label
to axistitle
to differentiate from the tick labelsWon't do
data
from config so that we havedatasets
,labels
, andoptions
as first level properties. We agreed thatdata.datasets.data
is confusing, but every chart would need to be updated if we changed this and all StackOverflow answers would be outdatedHow can you help?
The text was updated successfully, but these errors were encountered: