Pre loader

How to get axes right with Heatmap and Categorical Data

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

We need to make heatmaps of our data and don’t know the type of data variables until runtime. Because of this I am switching the axes like so in XAML:

 

The key is that I’m a custom LabelProvider class to convert any categorical values into the appropriate label for the axes. I would have liked to use a CategoryNumericAxis for both axes, but for some reason it seems you can’t so I’m using a NumericAxis.

All data values are coming in as 0, 1, 2,… for the categorical variables.

I am running into two issues with the axes. First is that the last category is cutoff prematurely and I’d like to align the labels with the center of the category not the left edge. These issues appear with the CategoryNumericAxis.

The second issue is that I’m having issues aligning both the values and controlling the number of what I guess are the tickmarks for the Y axis since it doesn’t know it is categorical data. Is there any (easy) way to handle the Y axis for categorical data?

Attached is an image of what the plots are looking like:

Version
8.8.0.28567
Images
  • You must to post comments
0
0

 

and in styles:

  • You must to post comments
0
0

Hi Robert,

Thank you for contacting us.
Please accept my apologies for such a delayed response.

We reviewed your inquiry.
Unfortunately, as you’ve already noticed, Category Axes are currently only supported as XAxes. Thus, a regular NumericAxis would be the only option for the YAxis.

I would also recommend trying IndexNumericAxis as an alternative to the CategoryNumericAxis:
SciChart WPF Documentation – IndexNumericAxis | WPF Chart Documentation

It has been introduced within the SciChart v8.7 release and is a more advanced version of the Category Axis type. Please have a look:
SciChart WPF v8.7 Released! – WPF Charts

You try switching between the IndexNumericAxis and a general NumericAxis in our updated “Category vs Value Axis” example:
https://www.scichart.com/example/wpf-chart/wpf-category-vs-value-axis/

Here you can find the source code of the mentioned example project:
SciChart.Wpf.Examples/Examples/SciChart.Examples/Examples/ModifyAxisBehaviour/CategoryVsValueAxis.xaml at master · ABTSoftware/SciChart.Wpf.Examples

Regarding aligning tick marks, you can set the MajorDelta and MinorDelta for the Axis manually. Please have a look at the “Setting MajorDelta, MinorDelta Manually When AxisBase.AutoTicks = False” section of the following documentation article for more details:
SciChart WPF Documentation – Axis Ticks – MajorDelta, MinorDelta and AutoTicks | WPF Chart Documentation

However, please note that the AutoTicks property should be set to “false” on the Axis for changes to take effect.

Please let us know if this helps.

I have also noticed that the mentioned code samples were not attached to your messages.
In order to get them formatted correctly and later visible in your message, we recommend marking the corresponding parts of the message as a “Code Sample” using the following button on the toolbar:
enter image description here

Kind regards,
Lex S., MSEE
SciChart Technical Support Engineer

Images
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.