0

I'm using library highChart https://www.highcharts.com/ for statistics graphs and i wanna know if there's the possibility to create data different in different periods for exemple I have series like that :

Categories : [
                '2021-01-01',
                '2021-01-02',
                '2021-01-03',
                '2021-01-04',
                '2021-01-05',
                '2021-01-06',
                '2021-01-07',
                '2021-01-08',
                '2021-01-09',
                '2021-01-10',
                '2021-01-11',
                '2021-01-12',
                '2021-01-13',
                '2021-01-14',
                '2021-01-15',
                '2021-01-16',
                '2021-01-17',
                '2021-01-18',
                '2021-01-19',
                '2021-01-20',
                '2021-01-21',
                '2021-01-22',
                '2021-01-23',
                '2021-01-24',
                '2021-01-25',
                '2021-01-26',
                '2021-01-27',
                '2021-01-28',
                '2021-01-29',
                '2021-01-30',
             ]
series : [
{
    name : 'serie 1',
    data : [
                {x : '2021-01-05' , s : 5},
                {x : '2021-01-10' , s : 20},
                {x : '2021-01-11' , s : 40},
                {x : '2021-01-15' , s : 80},
                {x : '2021-01-30' , s : 20},

           ]
}

] 


i wanna the x values in the graphic get the period in categories and get the x value from series to compare if the x value in series exist then get s value in the series else put 0 
How i can do that in highChart 

1 Answer 1

2

I implemented a logic that parsed data into a wanted format. Take a look at this demo: https://jsfiddle.net/BlackLabel/hrasqo92/

const parsedData = categories.map(category => {
  const dataPoint = baseData.filter(data => data.x === category);
  if (dataPoint.length) {
    return [category, dataPoint[0].y]
  } else {
    return [category, 0]
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.