Is there an easy way to rotate the Chart(swapping X and Y-Axis) inclusive Annotations, Modifiers,…?
- Daniel Hartl asked 9 years ago
- You must login to post comments
Hi Daniel,
Yes, there is a way to rotate a chart! You can use our build in API to place an XAxis on the Left/Right and YAxis on the Top/Bottom of the chart. This is demonstrated in one of our examples: Vertical Chart Example
The most important part of the code is here. Note the AxisAlignment property:
<!-- Define the XAxis for this chart on the Left. -->
<SciChart:SciChartSurface.XAxis>
<SciChart:NumericAxis AxisAlignment="Left" AxisTitle="X-Axis" DrawMajorBands="True"/>
</SciChart:SciChartSurface.XAxis>
<!-- Define the YAxis on the Top -->
<SciChart:SciChartSurface.YAxes>
<SciChart:NumericAxis AxisAlignment="Top" AxisTitle="Red Line" BorderBrush="Red" BorderThickness="0,0,0,1" Id="Top1" TickTextBrush="Red"/>
<SciChart:NumericAxis AxisAlignment="Top" AxisTitle="Black Line" BorderBrush="Black" BorderThickness="0,0,0,1" Id="Top2" TickTextBrush="Black"/>
</SciChart:SciChartSurface.YAxes>
Alternatively, you can use WPF’s LayoutTransform. This will rotate the entire chart including axis labels. Rotating axis labels back would require additional transforms at the label level.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 9 years ago
-
Hello Andrew, thanks for the answer. I know the example and AxisAlignment, but my Chart consists of three charts. (3 Y-Axes,1 X-Axis)
-
Hi Daniel, got it, so what do you need? I still don't understand the question. You can place all three Y-Axis on the top/bottom and one XAxis on the left/right. Please explain if I've missed something. Best regards, Andrew
-
Hello Andrew, I was out of the office. My chart looks like the vertically stacked Axes example. I'm able to change the AxisAlignment property, but the main problem will be the ITemsPanelTemplate x:Key=YAxesPanel-> the RowDefinitions must be changed to ColumnDefinitions. Is there an easy way to do this? Thanks!
-
Sadly there isn't .. but couldn't you write an attached property to do this work for you? Say you bound the ItemsPanelTemplate Grid to a property (that you create) to an Alignment property in your view model. You could programmatically change the row definitions to column definitions when the binding fires. Just an idea, its not something we've tried ...
- You must login to post comments
Please login first to submit.