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?
When I run the sample with v17.2.20172.1000 I am able to see it broken down by minutes. I am attaching a screen shot to demonstrate. The only change I made is to the format of the minutes label. I changed it to "{Date:hh:mm:ss}" so it can clearly be seen that the minutes being displayed are within an single hour and not hours and minutes instead.
Okay, much better now. Could you help with following please,1- On Load, we would like to default visible space to Current date only. Only upon, zoom out - data for entire range should be visible. E.g. 05-12-19 OHLCV data should be visible by default, and zoom out in order to view data from 31-10-2019.2- What should be the CategoryDateTimeXAxis lebel format to be able to view the date range comfortably? Since, it's minute by minute data, data on the x-axis becomes blurry until zoomed to 20 mins or less data.3- Zoom performance is a bit slow (we have enabled virtualization using VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling", is that the correct way?), how can it be improved further?3- How many records XamDatachart can hold comfortably, without any performance issues? Maximum data we plan to support is for every symbol - 9 years minute by minute data - approximately 877 thousand records.
4- Although Scroll panel allows changing Interval, can this be achieved automatically while zooming both and x, and y Axis?
5- How do I restrict graph to take only Trading hours (9-16-3:30)? Right now graph is taking 24 hours format.
6- On Zoom, bars appear a bit wide, we would like to view that with minute interval, and narrow bars.
I have attached our POC sample for your reference, along with Csv.
8168.CandleChart.zip
To adjust the default viewable space you can try adjusting the window rect:www.infragistics.com/.../infragisticswpf.controls.charts.xamdatachart~infragistics.controls.seriesviewer~windowrect
If that doesn’t work try the scale:www.infragistics.com/.../infragisticswpf.controls.charts.xamdatachart~infragistics.controls.charts.xamdatachart~windowscalehorizontal
www.infragistics.com/.../infragisticswpf.controls.charts.xamdatachart~infragistics.controls.charts.xamdatachart~windowscalevertical
As for labels, the format of the label is just going to determine how the labels display at the level you are at, which you can setup however works best for you in your Label format method you have setup.
Concerning chart performance you can see the following doc:www.infragistics.com/.../datachart-chart-performance
Concerning limiting data displayed if you want to only display data that was produced during certain hours of the day you would have to filter your data yourself.
Can you clarify what you mean by points 4 and 6?
Point 6 - Following is how minute by minute data appears (each bar is very wide, doesn't even appear as a candle stick, should appear as one candle stick per minute of frequency).
We wish to make it appear like following for each minute of frequency (Following snapshot is from another control suite).
We
Michael Peterson said:
: Our data is generated for working hours only - It's just that we don't know how to omit the intervals on the axis where there is no data. For example see following screenshot.
Date 25-22-19, and 26-11-19 contain data between 9:15 AM - 3:30 PM, but there are large gaps on the x-axis without any data. We don't want to display those gaps.
In Short: Is it even possible to display minute by minute OHLC data on this graph component, in a clean and concise way.
We obviously are struggling update the labels easily on the zoom to view in minute frequency easily with clear and distinct bars. Following is how it appears when we zoom into a particular day's data.
when we zoom further, e.g. we try to view OHLC data between 9:15 - 10:30 AM, following is how it appears (Obviously, very difficult to see each bar distinct),
Following is how it appears per minute frequence - barely appears are a candle stick.
Regarding scale - what should be the scale to display current day's data only?
Thank you for the update. For making your data appear without gaps you will want to try the Ordinal time x axis instead of the date time x axis. As the date time x axis sorts and aligns them to a chronological time scale, where the ordinal the dates are assumed equidistant.
www.infragistics.com/.../datachart-using-ordinal-time-x-axis
Do you have a sample that you can attach that demonstrates the candle sticks appearing wide as I don’t see that behavior in the sample you attached. Note for the sample you attached I am using v19.1.
To get the scale you want you are going to have to try different scales to find what you like as the scale is going to depend upon your data.