Hi Jack,
We have
validated your query and would like to suggest that you can use your double
type seconds data in our TimeSpan axis by using below solution.
You
can convert your seconds to TimeSpan by using TimeSpan.FromSeconds methods.
Then assign the TimeSpan type model property to our XBindingPath as per the
below code snippet.
public class ViewModel
{
private Random random;
public
ObservableCollection<ChartModel> Data { get; set; }
public ViewModel()
{
random = new Random();
Data = new
ObservableCollection<ChartModel>();
for(int i=0; i<10;i++)
{
Data.Add(new ChartModel() { TimeSpanValue = GetTimeSpanValue(random.Next(20,120)),
Value1
= random.Next(10,50) });
}
}
private TimeSpan GetTimeSpanValue(double seconds)
{
return TimeSpan.FromSeconds(seconds);
}
}
public class ChartModel
{
public double Value1 { get; set; }
public TimeSpan TimeSpanValue { get; set; }
}
|
<chart:SfChart>
<chart:SfChart.PrimaryAxis>
<chart:TimeSpanAxis/>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis/>
</chart:SfChart.SecondaryAxis>
<chart:LineSeries ItemsSource="{Binding Data}" Label="First"
XBindingPath="TimeSpanValue" YBindingPath="Value1" />
</chart:SfChart>
|
I have also attached a demo sample based on your requirement, please
check and let us know if need any further assistance.
Regards,
Moneeshram
Attachment:
F_180453_a2442f0f.zip