amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
337 stars 91 forks source link

stockPositiveValue and stockNegativeValue don't affect how chart looks. #728

Closed InnerDesires closed 1 year ago

InnerDesires commented 1 year ago

I've seen in your recent update log that there was an issue with these properties not being inherited right, however, I'm stuck with changing the colors of my candlestick diagram. I'm learning how to use amCharts with React, the version of amcharts being used is:

    "@amcharts/amcharts5": "^5.2.45",
     "react": "^18.2.0"

I'm setting those props like this:

let stockChart = root.container.children.push(
            am5stock.StockChart.new(root, {
                layout: root.verticalLayout,
                stockPositiveColor: am5.color('#00f'),
                stockNegativeColor: am5.color('#00f')
            })
        );
        root.numberFormatter.set("numberFormat", "#,###.00");
        let mainPanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
            wheelY: "zoomX",
            panX: true,
            panY: true,
        }));

However, the look of my chart is not being affected.

Also, the theming approach doesn't seem to work too:

let root = am5.Root.new("chartdiv");
        let myTheme = am5.Theme.new(root);
        myTheme.rule('StockChart').setAll({
            'stockPositiveColor': am5.color('#00F'),
            'stockNegativeColor': am5.color('#00F'),
            'volumePositiveColor': am5.color('#00F'),
            'volumeNegativeColor': am5.color('#00F'),
        })

The way the chart looks:

image
martynasma commented 1 year ago

These settings apply to main value and volume series only. If you need your series to have these colors applied, set it as stockSeries on StockChart:

https://www.amcharts.com/docs/v5/charts/stock/#Positive_negative_colors

InnerDesires commented 1 year ago

@martynasma Thanks for the reply, but I've already visited this part of your docs several times today and was setting those styles according to it:

let stockChart = root.container.children.push(
            am5stock.StockChart.new(root, {
                layout: root.verticalLayout,
                stockPositiveColor: am5.color(0x999999),
                stockNegativeColor: am5.color(0x000000),
                volumePositiveColor: am5.color(0x999999),
                volumeNegativeColor: am5.color(0x000000)
            })
        );
...  
stockChart.set("stockSeries", valueSeries);

And as you can see on the screenshot, only the volume series is actually being affected by the passed props: image

zeroin commented 1 year ago

There is a bug on our side, we will fix it in next release and will let you know. Meanwhile the quick fix would be to modify interface colors:

root.interfaceColors.set("positive", am5.color(0x999999));
root.interfaceColors.set("negative", am5.color(0x000000));
martynasma commented 1 year ago

Fixed in 5.2.46.

[5.2.46] - 2023-01-02

Fixed

Full change log.

Download options.

Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.