<chart:SfChart.PrimaryAxis>
<chart:TimeSpanAxis
x:Name="xAxis"
ActualRangeChanged="TimeSpanAxis_ActualRangeChanged"/>
</chart:SfChart.PrimaryAxis> |
private void TimeSpanAxis_ActualRangeChanged(object sender,
ActualRangeChangedEventArgs e)
{
double interval = (double)xAxis.GetType().GetProperty("VisibleInterval", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).GetValue(xAxis);
if ((interval < 1 && e.ActualInterval > 1000) || interval > 1000)
xAxis.LabelFormat = @"mm\:ss";
else
xAxis.LabelFormat = "mm':'ss':'fff";
} |
<chart:SfChart.PrimaryAxis>
<chart:TimeSpanAxis
x:Name="xAxis"
ActualRangeChanged="TimeSpanAxis_ActualRangeChanged"/>
</chart:SfChart.PrimaryAxis> |
private void TimeSpanAxis_ActualRangeChanged(object sender,
ActualRangeChangedEventArgs e)
{
double interval = (double)xAxis.GetType().GetProperty("VisibleInterval", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).GetValue(xAxis);
if ((interval < 1 && e.ActualInterval > 1000) || interval > 1000)
xAxis.LabelFormat = @"mm\:ss";
else
xAxis.LabelFormat = "mm':'ss':'fff";
} |
<chart:SfChart.PrimaryAxis>
<chart:TimeSpanAxis Interval="00:00:01"
x:Name="xAxis" EnableAutoIntervalOnZooming="False"
LabelFormat="mm\:ss"/>
</chart:SfChart.PrimaryAxis> |
Hi Xmen,You can achieve this requirement by setting EnableAutoIntervalOnZooming as false and required Interval in axis as per the below code snippet.Code snippet
<chart:SfChart.PrimaryAxis><chart:TimeSpanAxis Interval="00:00:01"x:Name="xAxis" EnableAutoIntervalOnZooming="False"LabelFormat="mm\:ss"/></chart:SfChart.PrimaryAxis>Here Interval 00:00:01 represents hh:mm:ss format. Please let us know if you have any queries.Thanks,Muneesh Kumar G.
<chart:SfChart x:Name="chart" Margin="15" >
<chart:SfChart.Behaviors>
<chart:ChartZoomPanBehavior EnableZoomingToolBar="True" EnableSelectionZooming="True"/>
</chart:SfChart.Behaviors>
<chart:SfChart.PrimaryAxis>
<local:TimeSpanAxisExt
x:Name="xAxis"
LabelFormat="mm\:ss"/>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis >
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:FastLineBitmapSeries XBindingPath="XValue" YBindingPath="YValue" ItemsSource="{Binding Data}"/>
</chart:SfChart>
|
public class TimeSpanAxisExt :TimeSpanAxis
{
protected override void CalculateVisibleRange(Size avalableSize)
{
base.CalculateVisibleRange(avalableSize);
TimeSpan interval=new TimeSpan();
if (VisibleRange.Start > 1)
{
TimeSpan ts1 = TimeSpan.FromMilliseconds(VisibleRange.Start);
TimeSpan ts2 = TimeSpan.FromMilliseconds(VisibleRange.End);
TimeSpan diff = ts2.Subtract(ts1);
interval = new TimeSpan(diff.Ticks / 10);
if (interval.Seconds == 0)
interval = new TimeSpan(0, 0, 1);
}
this.GetType().GetProperty("VisibleInterval", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).SetValue(this, interval.TotalMilliseconds);
}
} |