Hi Guys,
I am trying to plot a candle Data chart using XamDataChart. In the attached sample, data is generated minute by minute data for last 30 days. Going forward, we will stream minute by minute data into the existing DataPoints collection asynchronously - and would like to see dynamic updates - i.e. Say for example UI loads data for last 6 months, any new upcoming ticks from the market would get appended to existing loaded data.
Problems,
- Chart does not displays data for entire range data for 01-sep-2019 to 30-sep-2019.
- On Zoom - would like to update min and max values (and interval) dynamically. E.g for Sep 04 - Min - max values are 300-400 respectively, I would like to use this range to display the plotting in the intervals of 50.
Code is shared at following link
https://drive.google.com/file/d/1Te5K0ipzAjzAbSBLBmm-OPW18YEDd7ys/view
thanks,
Hello Abhay,
Thank you for contacting Infragistics!
The reason the chart doesn’t display data from the 1st to the 30th is when you are generating your data you set the day of the month of the date time to DateTime.Now.Day so all your data will always be for a single day of the day your run the sample.
Concerning setting the interval you can set the major interval on the axis to 5o for the spacing you want:www.infragistics.com/.../datachart-configuring-major-and-minor-intervals
After doing that and setting VertialZoomable it should zoom well with the interval set. If you don’t like the calculated range based on zooming you can set it yourself as described here:www.infragistics.com/.../datachart-axis-range
Thank you,
Data plotting issue is resolve. I made following changes to X axis.
<ig:CategoryDateTimeXAxis x:Name="xAxis" ItemsSource="{Binding DataPoints}" DateTimeMemberPath="Date" MinimumValue="{Binding StartDate}" MaximumValue="{Binding EndDate}" MinorInterval="00:00:01:00.00" Interval="01:00:00:00.00"> <ig:CategoryDateTimeXAxis.Label> <MultiBinding Converter="{StaticResource RectWidthToLabelFormatConverter}"> <Binding RelativeSource="{RelativeSource Self}" /> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ig:XamDataChart}}" /> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ig:XamDataChart}}" Path="WindowRect.Width"/> </MultiBinding> </ig:CategoryDateTimeXAxis.Label>
public class RectWidthToLabelFormatConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CategoryDateTimeXAxis axis = values[0] as CategoryDateTimeXAxis; XamDataChart chart = values[1] as XamDataChart; var viewport = new Rect(0, 0, axis.ActualWidth, chart.Axes.OfType<NumericYAxis>().First().ActualHeight); var window = chart.WindowRect;
//Getting the minimum displayed datetime var minVal = axis.GetUnscaledValue(0, new ScalerParams(window, viewport, axis.IsInverted)); DateTime min = new DateTime((long)minVal); //Getting the maximum displayed datetime var maxVal = axis.GetUnscaledValue(axis.ActualWidth, new ScalerParams(window, viewport, axis.IsInverted)); DateTime max = new DateTime((long)maxVal); //Calculating the range, coverted by the axis TimeSpan axisRange = max - min; if (axisRange.Days > 365) return "{Date:yyyy}"; else if (axisRange.Days > 1) return "{Date:MMM dd}"; else if (axisRange.Hours > 7) return "{Date:MMM dd}"; else if (axisRange.Hours > 1) return "{Date:hh:mm}"; else return "{Date:mm:ss}"; }
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }
1- A-Axs values are not getting updated, once I zoom past 1 hour into minute data.
2- Zoom is slow, and there is a lag. Is there any ways I could improve this performance?