Jump to content
Software FX Community

One categorical and one non-categorical X axis on one chart.


ben.vlayen

Recommended Posts

There seems to be a problem when we add a series with a non-categorical x axis and one with a categorical x-axis to one chart.

If we draw the series separately to a chart, they are displayed normally (see attachment; 2 charts on top), however if we want both series on the same chart, the chart acts very strange (see attachment; the bottom chart).

  • The points on the categorical axis are not drawn on the label on the x-axis
  • The points on the non-categorical axis are not drawn according their x value.


Should we enable some options?



Chart fx wpf version: 8.0.3700.31053


Code snippet:



Private mCategoricalData As ObservableCollection(Of Point)

Private mXYData As ObservableCollection(Of Point)



Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)



'Remove the default series:

mChartControl.Series.Clear() ' the mChartControl is the Chartfx WPF chart



'create the test data:

CreateCategoricalData()

CreateXYData()



'add the first serie on the normal x axis

Dim catSerie = New ChartFX.WPF.SeriesAttributes()

catSerie.Gallery = ChartFX.WPF.Gallery.Line

catSerie.BindingPath = "Y"

catSerie.Content = "Cat"

catSerie.AxisX = mChartControl.AxisX

'We want a categorical axis over here, so bind the labels

catSerie.AxisX.Labels.BindingPath = "X"

catSerie.ItemsSource = mCategoricalData

mChartControl.Series.Add(catSerie)





'Add a serie on the same chart with an other x axis,

'this axis should not be categorical!



'add an non categorical axis

Dim nonCategoricalAxis As New ChartFX.WPF.Axis()

nonCategoricalAxis.ForceZero = False

mChartControl.AxesX.Add(nonCategoricalAxis)



Dim xySerie = New ChartFX.WPF.SeriesAttributes()

xySerie.Gallery = ChartFX.WPF.Gallery.Line

xySerie.BindingPath = "Y"

'We don't want a categorical axis over here, so bind the BindingPathX

xySerie.BindingPathX = "X"

xySerie.Content = "XY"

xySerie.AxisX = nonCategoricalAxis

xySerie.ItemsSource = mXYData

mChartControl.Series.Add(xySerie)



End Sub



Private Sub CreateCategoricalData()

mCategoricalData = New ObservableCollection(Of Point)

mCategoricalData.Add(New Point(0, 1.1))

mCategoricalData.Add(New Point(1, 1.2))

mCategoricalData.Add(New Point(2, 1.3))

mCategoricalData.Add(New Point(0, 1.1))

mCategoricalData.Add(New Point(1, 1.4))

mCategoricalData.Add(New Point(0, 1.3))

End Sub





Private Sub CreateXYData()

mXYData = New ObservableCollection(Of Point)

mXYData.Add(New Point(10, 2.1))

mXYData.Add(New Point(11, 2.2))

mXYData.Add(New Point(12, 2.4))

mXYData.Add(New Point(12.5, 2.2))

mXYData.Add(New Point(13, 2.0))

End Sub

Link to comment
Share on other sites

  • 1 month later...

Update: After some consideration and code tweaking we found a relatively safe way to add support for this scenario, to fix the first problem "The points on the categorical axis are not drawn on the label on the x-axis" you can add the following (this should be supported in the current build)

chart1.AxisX.AxisStyle |=

AxisStyles.Categorical;To fix the second problem "The points on the non-categorical axis are not drawn according their x value" you will need a new hotfix that should be available in a couple of days, any build marked 3775 or later should add support for this.

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...