Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
naveenbalanagu
Contributor III
Contributor III

How can I retrieve data from a bar chart using .Net SDK?

I am trying to retrieve the following from a bar chart using .Net SDK

  • Bar chart x and y axes names.
  • Chart dimension and measures
  • Data points in each bar (ex: If a bar chart has 3 bars with values 10, 20 and 30 then the same need to be retrieved with corresponding dimension name and measure)

(I am a newbie to QlikSense/.Net SDK. So I am not sure if this can be done through SDK or any other API).

1 Solution

Accepted Solutions
naveenbalanagu
Contributor III
Contributor III
Author

I am able to read the data from bar chart. I've used the DataPages property in IBarChart interface to access the data points.

IEnumerable<ISheet> sheets = app.GetSheets();

                            foreach (ISheet sheet in sheets)

                            {

                                foreach (IBarchart child in sheet.Children.OfType<IBarchart>())

                                {

                                  

                                    Console.WriteLine("{0} : {1} : {2} : {3} : {4}", sheet.MetaAttributes.Title, child.Info.Type, child.Info.Id, child.Title, child.Subtitle);

                                    Console.WriteLine("The number of data points in the chart are " + child.DataPages.First().Matrix.Count()); //displays number of unit type bars in the chart

                                   var barchartdata = child.DataPages.First().Matrix.ToDictionary(row => row.ElementAt(0).Text, row => row.ElementAt(1).Num);

                                    foreach (var barchartrowitem in barchartdata)

                                    {

                                        Console.WriteLine(barchartrowitem.Key + ": " + barchartrowitem.Value); //displays the bar chart point name and value

                                     

                                    }

                                }

View solution in original post

1 Reply
naveenbalanagu
Contributor III
Contributor III
Author

I am able to read the data from bar chart. I've used the DataPages property in IBarChart interface to access the data points.

IEnumerable<ISheet> sheets = app.GetSheets();

                            foreach (ISheet sheet in sheets)

                            {

                                foreach (IBarchart child in sheet.Children.OfType<IBarchart>())

                                {

                                  

                                    Console.WriteLine("{0} : {1} : {2} : {3} : {4}", sheet.MetaAttributes.Title, child.Info.Type, child.Info.Id, child.Title, child.Subtitle);

                                    Console.WriteLine("The number of data points in the chart are " + child.DataPages.First().Matrix.Count()); //displays number of unit type bars in the chart

                                   var barchartdata = child.DataPages.First().Matrix.ToDictionary(row => row.ElementAt(0).Text, row => row.ElementAt(1).Num);

                                    foreach (var barchartrowitem in barchartdata)

                                    {

                                        Console.WriteLine(barchartrowitem.Key + ": " + barchartrowitem.Value); //displays the bar chart point name and value

                                     

                                    }

                                }