Closed workingbuddy10 closed 10 months ago
This is because JSON parser does not know custom classes, and thus cannot restore it.
We will need to figure out a way to register custom classes for JSON parser.
At this point there's nothing that can be done by you. We'll need to implement it on our end.
Will keep you posted.
Sure no issues!!
A way to register custom Indicator class will be added in the next version. I will notify you here when it's out.
In the interim, I suggest you fix issues with your code.
1) The IndicatorControl callback that adds new indicator needs to return Indicator instance, not push it into stockChart.indicators
. By pushing it, you will get the indicator serialized and restored twice.
2) Your indicator is meant to display in the same panel as the main series, yet it extends ChartIndicator
which results in error. It should extend Indicator
.
So I should change the class to this, isn't ?
// Define indicator class
class MyIndicator extends am5stock.Indicator {
@martynasma
Correct.
Thank you @martynasma !!!!
Fixed in 5.7.2.
Label
: maxChars
. If set to a number, will truncate text to X characters with ellipsis, obeying breakWords
and ellipsis
settings.StockChart
.StockChart
.registerClass(name, classRef)
added to Stock Chart package (global: am5stock.registerClass()
). Allows registering own indicator class so that it gets properly serialized and restored.ValueAxis
when all the values of a series are the same.IndicatorControl
's dropdown, even if volumeSeries
was not set on the StockChart
.ValueAxis
on a StockChart
(opposite: false
) it was impossible to right-align axis labels to plot area. Scrollbar's width was also not adjusted to the width of the plot area.StockChart
where not working when chart was in comparison mode.StockChart
was in comparinson mode were not carried over correctly when switching to regular value mode.StockChart
series was updated.StockChart
were not clearing up the list of found items when the search field was cleared.Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.
For it to work properly you will need to register your custom indicator class:
am5stock.registerClass("MyIndicator", MyIndicator);
Example: https://codepen.io/team/amcharts/pen/GReRmbr/c84b1bf62d0f736a44b3a37382110923?editors=0010
@martynasma In the given example the chart is not getting plotted, please check it once!
Did you register your custom class as suggested above?
Yes @martynasma, can you try & test it in the below codepen?
https://codepen.io/team/amcharts/pen/GReRmbr/c84b1bf62d0f736a44b3a37382110923?editors=0010
OK, sorry, I failed to mention another important detail. The custom indicator class needs to also have className
set on it:
class MyIndicator extends am5stock.Indicator {
className = "MyIndicator";
// ...
}
OK, sorry, I failed to mention another important detail. The custom indicator class needs to also have
className
set on it:class MyIndicator extends am5stock.Indicator { className = "MyIndicator"; // ... }
It is also there, you can checkout the codepen link given, test it out.
@martynasma
OK, so CodePen is not good for testing it, because it changes the URL of its iframe, and indicators are saved based on URL.
So either you test it outside CodePen, or you specify your own storageId
:
https://www.amcharts.com/docs/v5/charts/stock/toolbar/data-save-control/#Storage_scope
I am trying to save the custom indicator which I made in the data save control.
Custom indicator name : My indicator Link to check : https://codepen.io/Ansh-m-the-reactor/pen/GRwawNg