Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Adding series dynamically to igDataChart and assigning data
posted

Hi,

I need to show several data series in one igDataChart (mostly line charts). The number of series shown can vary, so I need to add or remove data series dynamically (as well as adjusting the legend) at runtime.

This is an example of my data (whereas the number of Series can vary):

var data = [{"Series":1,"X":0.0,"Y":10.0},
{"Series":1,"X":1.0,"Y":9.0},
{"Series":1,"X":2.0,"Y":8.5},
{"Series":1,"X":3.0,"Y":8.0},
{"Series":1,"X":4.0,"Y":7.75},
{"Series":1,"X":5.0,"Y":6.0},
{"Series":1,"X":6.0,"Y":5.5},
{"Series":1,"X":7.0,"Y":5.3},
{"Series":1,"X":8.0,"Y":5.0},
{"Series":2,"X":1.0,"Y":15.0},
{"Series":2,"X":2.0,"Y":14.75},
{"Series":2,"X":3.0,"Y":14.5},
{"Series":2,"X":4.0,"Y":14.25},
{"Series":2,"X":5.0,"Y":13.75},
{"Series":2,"X":6.0,"Y":14.0},
{"Series":2,"X":7.0,"Y":13.5},
{"Series":2,"X":8.0,"Y":13.0},
{"Series":2,"X":9.0,"Y":13.75}];


Based on the High Volume Example (https://www.igniteui.com/data-chart/binding-high-volume-data), I failed to add multiple dataSerires.

How do I create dynamically dataSeries for the igDatachart and how do I assign the data dynamically the corresping dataseries? I couldn't find any related examples. 

Kind regards.

--

edit 2020-03-26:

Mistake in embedded code window removed

Parents
  • 620
    Verified Answer
    Offline posted

    Hello,

    I have created and attached a sample illustrating how to dynamically change the series and their legend. I had to convert the structure of the data you have provided in order to create the series dynamically. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.

    0181.Sample.zip

Reply Children