Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

naveenbalanagu
New Contributor III

QlikSense .Net SDK: Retrieve chart dimensions and measure information

Hi,

I am trying to retrieve the following information of any type of visuals in .Net SDK.

For example, if there is a bar chart, I would like to retrieve

  • Bar chart measure - SUM(something), AVG(something), COUNT(something) etc.
  • Bar chart dimension - Field used to apply the measure
  • Bar chart - color properties (which color mode is used)
  • Bar chart layout - Vertical or Horizontal
  • Sorting - Asc or Desc.

I am trying to retrieve measure and dimension information using DimensionInfo and MeasureInfo properties. But those are returning the object details instead of the actual values.

Note: Measures and Dimensions are not defined in Hyper cube in my case. I am able to retrieve the data in the chart using DataPages.First().Matrix.ToDictionary(row => row.ElementAt(0).Text, row => row.ElementAt(1).Num) but need the above mentioned additional properties as well.

Thanks

5 Replies
Employee
Employee

Re: QlikSense .Net SDK: Retrieve chart dimensions and measure information

It sounds to me like your bar chart uses master measures and dimensions, so you need to lookup the id used for referencing them in the hypercube and look up the corresponding definitions among the master objects. So once you have you've gotten the ID from the hypercube, you can get a dimension object from the app using this method:

IApp.GetGenericDimension Method

Once you have used this method, you can inspect the properties of the returned object to find the definition.

You might also want to have a look at these two methods for accessing the lists of all master measures and dimensions:

AppExtensions.GetDimensionList Method

AppExtensions.GetMeasureList Method

Once you have those list objects you can access the information from the layout like this:

var layout = await list.GetLayoutAsync();

var listItems = layout.As<DimensionListLayout>().DimensionList.Items;

var allMasterDimensionIds = listItems.Select(container => container.Info.Id);

Employee
Employee

Re: QlikSense .Net SDK: Retrieve chart dimensions and measure information

Also, I can highly recommend this tool:

Qlik Explorer for Developers is here!

It's very useful for inspecting what the properties and layout structures of Qlik Sense objects are.

naveenbalanagu
New Contributor III

Re: QlikSense .Net SDK: Retrieve chart dimensions and measure information

Actually I am new to QlikSense, so I've a very little understanding of Hypercubes. But based on what I read, all the dimensions and measures that are created in the visuals will be in hypercube.

I've gone through some public examples given in the Qlik website and able to get the dimensions and measures of the charts using the below piece of code.

Capture.JPG

I am calling the Print method with the required parameters.

Print(thePieChart.Properties.HyperCubeDef, thePieChart.Title, app);

Is it the best way? Also how can I retrieve other properties like

  • Bar chart - color properties (which color mode is used)
  • Bar chart layout - Vertical or Horizontal
  • Sorting - Asc or Desc.

Thank You.

naveenbalanagu
New Contributor III

Re: QlikSense .Net SDK: Retrieve chart dimensions and measure information

Yes, I have this installed. It is really useful to understand the structure of the visuals and hierarchy of different properties. Thank you for sharing.

Employee
Employee

Re: QlikSense .Net SDK: Retrieve chart dimensions and measure information

A hypercube is the main structure for used by Qlik Sense for handling filtering of data. A list object is sort of a special case hypercube with just one dimension and no measures.

To look at the details of properties used explicitly for bar charts, you need to inspect the client specific properties for that type of visualization. This example gives a high level view of how to do that:

PublicExamples/AppTraverser at master · AptkQlik/PublicExamples · GitHub

In particular, have a look at the type switch used in the last method in this file:

PublicExamples/Traversing.cs at master · AptkQlik/PublicExamples · GitHub

If a generic object is a bar chart, then you can access its properties like this:

var barChart = theGenericObject as Barchart;

And once you have done that you can access it's definition through the "Properties" property. So to inspect the color definition, you could for instance do like this:

var color = barChart.Properties.Color;

You might want to check out this class that encapsulates the bar chart properties: BarchartProperties Class

The vertical/horizontal behavior can similarly be inspected through the "Orientation" property of BarchartProperties, but the sorting order is a concept used by the hypercube, so you have to go all the way into the definitions of the individual dimensions to inspect sort configurations.

Community Browser