I have a line graph with a cross hair and I am wondering is it possible for the y axis cross hair (horizontal) to only move along the maximum values of a line graph. If my description isn't clearing my problem up hopefully these images will help?
I am wondering if it is possible to have this displayed as currently I need to move the mouse up to the point from 40 to 60 to achieve this look, is it possible to do get this result without me having to adjust the cross hair myself?
Xaml
<Grid>
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<syncfusion:SfChart Margin="10">
<syncfusion:SfChart.PrimaryAxis>
<syncfusion:CategoryAxis />
</syncfusion:SfChart.PrimaryAxis>
<syncfusion:SfChart.SecondaryAxis>
<syncfusion:NumericalAxis Maximum="80" Minimum="0"/>
</syncfusion:SfChart.SecondaryAxis>
<syncfusion:SfChart.Behaviors>
<local:CustomCrossHairBehavior />
</syncfusion:SfChart.Behaviors>
<syncfusion:LineSeries x:Name="series"
ItemsSource="{Binding DataPoint}"
XBindingPath="XData"
YBindingPath="YData"/>
</syncfusion:SfChart>
</Grid>
Edit C#
public class Model
{
public string XData
{
get;
set;
}
public double YData
{
get;
set;
}
}
public class ViewModel
{
public ObservableCollection<Model> DataPoint
{
get;
set;
}
public ViewModel()
{
this.DataPoint = new ObservableCollection<Model>();
var date = new DateTime(2000, 1, 1);
DataPoint.Add(new Model { XData = "Jan", YData = 40});
DataPoint.Add(new Model { XData = "Feb", YData = 60});
DataPoint.Add(new Model { XData = "Mar", YData = 30});
DataPoint.Add(new Model { XData = "Apr", YData = 20});
DataPoint.Add(new Model { XData = "May", YData = 60});
DataPoint.Add(new Model { XData = "June", YData = 50});
DataPoint.Add(new Model { XData = "July", YData = 10});
DataPoint.Add(new Model { XData = "August", YData = 40});
}
}
public class CustomCrossHairBehavior:ChartTrackBallBehavior
{
public Line newline;
public CustomCrossHairBehavior()
{
newline = new Line();
Binding binding = new Binding();
binding.Path = new PropertyPath("LineStyle");
binding.Source = this;
newline.SetBinding(Line.StyleProperty, binding);
}
protected override void OnMouseMove(MouseEventArgs e)
{
var element = e.Source as SfChart;
var positon = e.GetPosition(this.AdorningCanvas);
newline.X1 = ChartArea.SeriesClipRect.Left;
newline.Y1 = positon.Y;
newline.Y2 = positon.Y;
newline.X2 = ChartArea.SeriesClipRect.Width + ChartArea.SeriesClipRect.Left;
AddElement(newline);
base.OnMouseMove(e);
}
}
This might be helpful from the control's vendor....
Or this one, Strip Lines, you can adjust style
When using proprietary controls, look to the vendor first for support and tutorials.