Skip to content
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

Flag Series won't render unless a child of YAxis #307

Open
hukka opened this issue Aug 27, 2020 · 1 comment
Open

Flag Series won't render unless a child of YAxis #307

hukka opened this issue Aug 27, 2020 · 1 comment

Comments

@hukka
Copy link

hukka commented Aug 27, 2020

Bug or Feature Request?

I expected it to work (so bug) since in plain Highcharts the flags series does not need a reference to any Y axis, but might be a design choice. An example or console warning might be good in that case.

Description

https://github.com/whawker/react-jsx-highcharts/wiki/Series mentions

Note In the vast majority of cases, a series should be wrapped in an Axis component.
but it seems that in every case the Series must be wrapped in the Axis. This makes sense when rendering flags on top of the pane or the series as in the example at https://www.highcharts.com/demo/stock/flags-placement as those need references to the Y axis or the series, but placing on the axis would seem logical outside any Y axis.

How to reproduce

Put a <Series type="flags"> directly as a child of a chart, instead of YAxis.

Live demo demonstrating bug

https://stackblitz.com/edit/base-chart-example-broken-flagsseries?file=MyChart.js
https://stackblitz.com/edit/base-chart-example-working-flagsseries?file=MyChart.js

@anajavi
Copy link
Collaborator

anajavi commented Sep 3, 2020

There was a warning in early hooks conversion code:

/*
if (defaultTo(restProps.requiresAxis, true)) {
const axis = getAxis();
if(!axis) throw new Error(`Series type="${restProps.type}" should be wrapped inside Axis`);
}
*/

However the axis can be null on first render, if axis is not in the context yet. So warning about it cannot be done on component body.

And to make it work the flagsseries needs to be declared with <FlagsSeries />.

The vanilla highstock actually always creates yaxis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants