I have two different spline charts on two consecutive rows. Both of them have the same XBindinPath, but different YBindingPath. I have the following requirement for them -
Can I get some suggestions to implement that in a cleaner way?
Here is a scratch of my design-
|
…
<chart:SfChart.RowDefinitions>
<chart:ChartRowDefinition/>
<chart:ChartRowDefinition/>
</chart:SfChart.RowDefinitions>
<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis LabelFormat="dd-MMM" ShowGridLines="False"
TickLineSize="10"/>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis ShowGridLines="False"
Minimum="0" Maximum="20"/>
</chart:SfChart.SecondaryAxis>
<chart:SplineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue" YBindingPath="YValue1">
</chart:SplineSeries>
<chart:SplineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue" YBindingPath="YValue2">
<chart:SplineSeries.YAxis>
<chart:NumericalAxis chart:SfChart.Row="1" ShowGridLines="False" PlotOffsetStart="30"
Minimum="0" Maximum="10"/>
</chart:SplineSeries.YAxis>
</chart:SplineSeries>
<chart:SfChart.Behaviors>
<chart:ChartTrackBallBehavior LineStyle="{StaticResource lineStyle}"/>
</chart:SfChart.Behaviors> |
Thank you
Devakumar Dhanapoosanam for your reply.
But I need to show the charts separately, plus the charts will have their own header like, "Graph1" "Graph2" in the picture. I am trying to use two different charts for this. In that case, is there any way to control the TrackBall from the backend? So that, when I mouse over on any chart, this will enable the trackball of the other chart at the given point?
Note: I am following MVVM pattern.
|
...
<chart:SfChart Grid.Row="0" x:Name="chart1"
Header="Graph 1"
MouseMove="chart_MouseMove" >
….
<chart:SfChart.Behaviors>
<local:ChartTrackBallBehaviorExt x:Name="trackball1" LineStyle="{StaticResource lineStyle}"/>
</chart:SfChart.Behaviors>
</chart:SfChart>
<chart:SfChart Grid.Row="1" x:Name="chart2"
Header="Graph 2" MouseMove="chart_MouseMove" >
…
<chart:SfChart.Behaviors>
<local:ChartTrackBallBehaviorExt x:Name="trackball2" LineStyle="{StaticResource lineStyle}"/>
</chart:SfChart.Behaviors>
</chart:SfChart>
|
|
private void chart_MouseMove(object sender, MouseEventArgs e)
{
var chart = sender as SfChart;
Point mousePoint = new Point
{
X = e.GetPosition(chart).X - chart.SeriesClipRect.Left - chart.Margin.Left,
Y = e.GetPosition(chart).Y - chart.SeriesClipRect.Top - chart.Margin.Top
};
ShowTrackball(mousePoint.X, mousePoint.Y);
}
private void ShowTrackball(double x, double y)
{
tracball1.Show((float)x, (float)y);
tracball2.Show((float)x, (float)y);
}
public class ChartTrackBallBehaviorExt : ChartTrackBallBehavior
{
...
public void Show(float x, float y)
{
IsActivated = true;
var point = new Point(x, y);
SetInternalProperty(typeof(ChartTrackBallBehavior), this, point, "CurrentPoint");
base.OnPointerPositionChanged();
InvokeInternalMethod(typeof(ChartTrackBallBehavior), this, "Activate", IsActivated);
}
…
} |