Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upState of Chart.js & V3.0 #6598
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 |
|
@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. |
What does that mean exactly? Because I don't see any type definitions on the alpha branch. Regards, |
It means we generated TypeDocs: https://www.chartjs.org/docs/next/typedoc/. Perhaps we should change "TypeScript" to "TypeDoc" in that sentence to be clearer |
Clarifying to answer the question asked in #6598 (comment)
After testing v3 alpha version top priority is tree shaking for me. Simply adding one line chart increases bundle size from 6kb to 60kb with gzip As for user experience, Everything else worked really well |
Hello! I've got one question. Any chance of publishing v2 without Moment as dependency? |
You can use v2 without the Moment dependency already today: https://www.chartjs.org/docs/latest/getting-started/integration.html#bundlers-webpack-rollup-etc |
@benmccann on a sidenote, I'd hope (and a lot seem to agree) that you could move |
We would love to have that feature. If anyone would like to volunteer, I'd be happy to discuss what is needed. I can't promise anyone will get to it otherwise since our time is limited, but I do agree it'd be a big improvement |
I've played around with the docusaurus build. I don't have any big complaints. @kurkle have you had a chance to look yet? |
Clarifying to answer the question asked in #6598 (comment)
Is v3 going to include timeline chart? I still didn't see this in the list :( |
There's a plugin that someone created for a timeline chart: https://github.com/fanthos/chartjs-chart-timeline (Demo: https://jsfiddle.net/fanthos/8vrme4bt/) v3 doesn't included any new chart types in the core library. Our focus has been on changes to the core library to make it faster, more configurable, with fewer bugs and edge cases. If there are any changes we can make to the core library to better support plugins like the above then we're happy to consider those changes |
Will Charts have a US / World map type of chart? |
No, there are no new chart types as explained in my comment just above yours |
@Bradley-H I just remembered there's already a plugin for maps: https://github.com/sgratzl/chartjs-chart-geo |
I did a little performance testing on my Windows 10 laptop with a i7-8650U @ 1.9GHz and 16GB Ram. I preload data.datasets with 10 datasets containing time stamps and incrementing data points. I then console time around the call to new Chart(). I got the following results: 10,000 pts each (100,000 total) takes 1.5-2s, Chrome uses 520MB So it looks like it's pretty much scaling linearly with the points. I use the following options to increase performance:
Since I'm trying to use it for real-time graphing I need as much performance as I can get because 1Hz data for 8hrs is 60 * 60 * 8 = 28,800. If I have 10 items on a graph that would be 280,800 pts. Are there other tricks I can use for performance or other new optimizations in v3.0? |
There are performance docs here: https://www.chartjs.org/docs/next/general/performance You might also try #6881 if performance is really important However, I would also suggest you probably don't need that many points. Consider, for example, showing one data point per minute instead of one data point per second. If you have more than one point per pixel, I'm not sure how you would get benefit from additional data points after that |
Thanks Ben. I think I've implemented most of the performance options. The primary reason we graph so many points is the ability to zoom in and out on the graph. These are real-time graphs so decimating server side and then re-requesting data on zoom doesn't seem possible since the user could then immediately zoom out and resume. Otherwise v3.0.0-alpha worked great! |
FYI I created for the following plugins alpha versions targeting v3:
|
take a look at https://github.com/sgratzl/chartjs-chart-geo |
Following the idea behind #5939 (avoiding misleading charts per default) I would like to suggest to set |
Wouldn't turning off interpolation all together be even better from that perspective? (i.e. |
I am ok with |
Hello, |
We are still supporting those browsers |
alpha is available
We're proud to announce that Chart.js 3.0.0-alpha is now available. Get it with
npm install chart.js@next --save
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 (#6555)Removecustom
(#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 (#5019)(or not? should we revert? see #6791)Remove, move the moment adapter to an external project, and remove the rollup optional pluginmoment
frompackage.json
(#6745)RemovezeroLineIndex
feature and replace with function based axis properties (#6697 & #6700)Change, adopt ES6 classes, userequire
toimport
const
/let
, etc.Change axis options from an array to an object keyed by ID (#6773)CleanupgetPixelForTick
(#6715)Accept data in a format that doesn't require parsing (#6696)Improve performance of finding hovered element (#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 (#6845)Reduce number of objects created (e.g._view
and_model
) when animation is disabled (e.g. #6710).MakebeginAtZero
default betrue
for bar chart (#5939)remove(#6684 #6893)global
from options namespaceStandardize on using degrees for angles (#6936)Migrate docs from GitBook to Docusaurus (#7295)Proposed / Nice to Have Features
options.scales
andoption.scale
keys for all chart typeschart.scaleService
and have new scale types be a simple registration_resolveDataElementOptions
and_resolveDatasetElementOptions
_dataElementOptions
an array in all controllers (i.e. line and radar).chart.options
private (user should not directly edit, but should pass in new config to merge)horizontalBar
and make all charts capable of being horizontal (#7144)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?