Comments (11)
4.3.2 has been released
from chart.js.
Discussion linked to the commit/PR: #11403
Something like this might work as a "workaround":
if (myChart.options.plugins?.tooltip)
(myChart.options.plugins.tooltip as TooltipOptions).enabled = true;
Nonetheless, I personnaly globaly agree with your remark (even though it was identified on PR).
Either we accept this change and we need to cast as specified in PR, or if we want something "smoother":
If I can make some suggestion too, either recheck all plugin types to have a enabled property (as @dperera-innerspec proposes) and return to old definition, or maybe use optional parameter to have some retro-compatibility (and yes, explicitly setting plugin to undefined is a bit ugly, but acceptable):
export interface PluginOptionsByType<TType extends ChartType> {
colors?: ColorsPluginOptions;
decimation?: DecimationOptions;
filler?: FillerOptions;
legend?: LegendOptions<TType>;
subtitle?: TitleOptions;
title?: TitleOptions;
tooltip?: TooltipOptions<TType>;
}
And you disable by explicitly setting null/undefined?
PS: I'm no TS expert either, but I think this would be acceptable (but didn't dug into code to check if undefined would effectively disable plugin but in theory it should)
from chart.js.
@Nico-DF i think first option is better because declaring a structure as undefined means you don't need it while declaring as something means you want it to behave a certain way
from chart.js.
Hi, @stockiNail I can confirm, that #11422 solves the typing issues I had. Thank you very much!
from chart.js.
Another solution might be:
export interface ConfigurablePlugin {
enabled: boolean
}
export interface PluginOptionsByType<TType extends ChartType> {
colors: ColorsPluginOptions & ConfigurablePlugin;
decimation: DecimationOptions & ConfigurablePlugin;
filler: FillerOptions & ConfigurablePlugin;
legend: LegendOptions<TType> & ConfigurablePlugin;
subtitle: TitleOptions & ConfigurablePlugin;
title: TitleOptions & ConfigurablePlugin;
tooltip: TooltipOptions<TType> & ConfigurablePlugin;
}
I think it should also work (even if base type alread have enabled <- to confirm) ?
from chart.js.
The current typings were incorrect. We specifically chose this route since the other route would have introduced new interfaces and a change in interfaces which we forsaw being more breaking/problematic.
For now in my oppinion these typings correspond the best with how they can be used in the code. For V5 we can refactor them so setting the defaults would be possible again without casting
from chart.js.
@LeeLenaleee v4.3.1 typings do not allow me to change values unless i re-cast the whole structure whenever i want to access it. That surely is not easier than just allowing the interface to be undefined (already a falsy value) aside from the structure.
from chart.js.
The current typings were incorrect. We specifically chose this route since the other route would have introduced new interfaces and a change in interfaces which we forsaw being more breaking/problematic.
For now in my oppinion these typings correspond the best with how they can be used in the code. For V5 we can refactor them so setting the defaults would be possible again without casting
LGTM, I accept proper change being made only on v5, but I would recommand to explicitely add a small note/breaking note on current release with recommended changes (especially since it is a patch update)
Although the cast is not a huge change, I had to dig a bit to understand the source of change and why (and I think @dperera-innerspec was probably the same)
from chart.js.
@etimberg @stockiNail maby we should revert the change and keep it for V5 to fix.
I hear a lot more complains now then before that we could not pass false.
from chart.js.
@LeeLenaleee I agree. Unfortunately I don't have much time because I'm deeply engage in new project. I'll do my best
from chart.js.
@LeeLenaleee @etimberg PR to revert #11422
from chart.js.
Related Issues (20)
- Allow setting constant width for bars and variable width for categories
- Setting Y-Min for bar chart messes with interactions/tooltips HOT 1
- ticks padding does not work as expected
- padding for the legend
- Clip option on scale doesn't do anything
- Cannot read properties of null (reading 'getContext')
- Radial Bar Chart Label Issue HOT 3
- Y-labels cropped way too early for vertically stacked axes
- Ticks callback function don't return initial value labels HOT 2
- floating point on y axis HOT 8
- Easy API for setting background color on each dataset's tooltip
- Hovering functionality for long labels
- Angular application reacting slow once multiple chart loaded into page. HOT 1
- Title padding does not appear to be scriptable (or type needs updating?)
- Provide an API using composition DP to build graphs
- Vertical Gradient to each bar are not able to set grouped Bar chart. (Sets the createLinearGradient for the whole graph, not for individual bars). HOT 1
- Tooltip content is not hoverable
- Dynamic text resize is not supported HOT 3
- Mix multiple bar and line HOT 2
- Issue with Updating Charts -> Adding or Removing Data code example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chart.js.