[email protected]
Posts: 65
Joined: Fri Aug 26, 2022 9:33 am

Highchart Stock with Stacking - How to do dynamic

Hello,
I'm here fighting with Highchart Stock with Stacking , I want to do this: https://jsfiddle.net/adamvolta/w4xmdj8y/#run

But I need to do in dynamic way and I don't understand what's the format I should send, json or csv?
And I believe the JS need some changes to make this chart dynamic. I want to send the data already prepared if possible, if ot can you advice me how I can do in better efficient way?

I already did some months ago for Gantt and it was more easy to understand the format.

Many thanks in advance

Paulo Torres
[email protected]
Posts: 65
Joined: Fri Aug 26, 2022 9:33 am

Re: Highchart Stock with Stacking - How to do dynamic

Hi again,
I noticed when I put the values inside the JS it works but if I pass dynamically with a parameter not works.

Works like that:

Code: Select all

var data = [ { name: 'ADBE default (average)', data: [ [ 1313964000000, 23.17 ], [ 1314050400000, 23.78 ], [ 1314136800000, 24.1 ], [ 1314223200000, 23.86 ], [ 1314309600000, 24.54 ], [ 1314568800000, 25.51 ], [ 1314655200000, 25.19 ], [ 1314741600000, 25.24 ], [ 1314828000000, 24.77 ], [ 1314914400000, 24.15 ], [ 1315260000000, 23.74 ], [ 1315346400000, 25.3 ], [ 1315432800000, 24.99 ], [ 1315519200000, 24.64 ], [ 1315778400000, 25.2 ] ] }, { name: 'ADBE start', data: [ [ 1313964000000, 23.17 ], [ 1314050400000, 23.78 ], [ 1314136800000, 24.1 ], [ 1314223200000, 23.86 ], [ 1314309600000, 24.54 ], [ 1314568800000, 25.51 ], [ 1314655200000, 25.19 ], [ 1314741600000, 25.24 ], [ 1314828000000, 24.77 ], [ 1314914400000, 24.15 ], [ 1315260000000, 23.74 ], [ 1315346400000, 25.3 ], [ 1315432800000, 24.99 ], [ 1315519200000, 24.64 ], [ 1315778400000, 25.2 ] ], type: 'column', stack: 'one' }, { name: 'ADBE end', data: [ [ 1313964000000, 23.17 ], [ 1314050400000, 23.78 ], [ 1314136800000, 24.1 ], [ 1314223200000, 23.86 ], [ 1314309600000, 24.54 ], [ 1314568800000, 25.51 ], [ 1314655200000, 25.19 ], [ 1314741600000, 25.24 ], [ 1314828000000, 24.77 ], [ 1314914400000, 24.15 ], [ 1315260000000, 23.74 ], [ 1315346400000, 25.3 ], [ 1315432800000, 24.99 ], [ 1315519200000, 24.64 ], [ 1315778400000, 25.2 ] ], type: 'column', stack: 'one' } ]

console.log(data)


Highcharts.stockChart($parameters.ContainerID, {
    series: data,

    rangeSelector: {
        selected: 4
    },
    
    plotOptions: {
        series: {
            tooltip: {
                valueDecimals: 2
            },
            dataGrouping: {
                forced: true,
                units: [
                    ['week', [1]]
                ]
            }
        },
       column: {
            stacking: 'normal'
        }
    }
});
Not works like that:

Code: Select all

var data = $parameters.Data

console.log(data)


Highcharts.stockChart($parameters.ContainerID, {
    series: data,

    rangeSelector: {
        selected: 4
    },
    
    plotOptions: {
        series: {
            tooltip: {
                valueDecimals: 2
            },
            dataGrouping: {
                forced: true,
                units: [
                    ['week', [1]]
                ]
            }
        },
       column: {
            stacking: 'normal'
        }
    }
});
I noticed in inspector when the data is already in script happens a serialization but if comes from parameter this serialization not happens.

https://ptorres.outsystemscloud.com/Sto ... ts/Screen1

How I can solve this problem?
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Highchart Stock with Stacking - How to do dynamic

Hello,

What is $parameters? It doesn't look like a JavaScript variable. Are you using any wrapper?
Could you reproduce the issue in an online editor that I could work on?
This link doesn't work, I get an error: 404 - File or directory not found.

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”