Closed themars closed 5 years ago
CategoryAxis needs to know what series there are. It can't extract categories from Series' data.
So, you need to set data that would contain at least categories to either chart or category axis itself.
And be aware that in this case mostly all functionality of amcharts will be not functioning as expected. You will be forced to to:
series.events.on("visibilitychanged"
and update axis data, otherwise data will be not hidden.XYCursor.zoomXY
will not until you will not set data for axis (e.g. if you will not set data for Y, zooming will not scale data to actual data set). Not yet found workaround for this.chart.invalidateData()
.And probably other functionality also broken if you will use advanced scenarios (when chart.data is not set). amcharts 4 looks very cool, but actually any advanced functionality requires a little bit tweaking and deep understanding how does amcharts work.
And this issue also marked as question — well, position of this library is clear:
With v4 we decided to take a leap of faith, and minimize on fuzzy logic as much as possible, giving the complete control to our users
Such issues quite disappointing, because as this library looks high-quality, you expect that it will be quite smart to detect such "issues" and if not handle it, but at least throw a warning, but it is so.
Good thing is that every issue/lack of smart behaviour is easily (once you figured out how ;)) fixed in a clear and logical code (because amcharts is very well designed and final solution in your code looks not as ugly hack (just looks like low-level code)).
And also amcharts 4 has very good docs — and this pitfall also documented: https://www.amcharts.com/docs/v4/concepts/series/#Note_about_Series_data_and_Category_axis
Now this make sense, thank you @develar @martynasma But, in my case, that "issue" will bring ugly code back :(
@themars Yeach... and in my case I just realized that series rendered each one by one and not according to specified dateX
(so, data is not distributed across axis correctly according to date). So, no way to avoid "will bring ugly code back :"( Despite expectation, no easy way to express even simple tasks. Every aspect needs to be polished and hard crafted :(
https://jsfiddle.net/sL3cowj9/