Hi,
We are using xamWebChart and adding Datapoints dynamically to it. We have to show Numeric Value in Y-Axis and Date Value in X-Axis. But we are having following issues:
1. We have to add dates by casting it to string (Hope it does not effect any thing)2. Only 4 Dates are shown in x-axis labels while there are hundred of date points, this makes chart less readable.3. We are adding tooltip to datapoints but it is not shown(If i convert the chart type to Scatter then it shows tooltip).4. It takes 3 to 4 seconds to add data points(I am using cht.RefreshEnabled this property too).
Can you help me to reolve these issues
Thanks
Could you provide a bit more information or a sample project? Which type of series are you trying to use that the tooltips are not showing? In terms of the axis labels, the chart will attempt to decide various parameters of the axis for you automatically based on the available space and other factors, but if the results you are seeing are not aesthetically pleasing or informative you may wish to manually adjust the range and interval of the axis: http://help.infragistics.com/NetAdvantage/DV/2009.2/CLR3.5/?page=SL_DV_xamWebChart_Modify_the_Axis_Range.html
or label formatting:
http://help.infragistics.com/NetAdvantage/DV/2009.2/CLR3.5/?page=SL_DV_xamWebChart_Format_the_Labels_of_an_Axis.html
-Graham
Hi Graham,
PFA sample code, you can test it with different number of datapoints by changing iterator controler from code. furthermore you can check change in loading and the refresh time after hitting the load button multiple times.
Hi Graham, I have checked If we add Markers in Series then it shows tooltipp. Is it necessary to add Markers to get tooltip on datapoints?
As Markers increase the loading time
you can adjust the frequency of the date category labels with something like this:
Axis xAxis = this.cht.Axes[0]; xAxis.AutoRange = false; xAxis.Minimum = 0; xAxis.Maximum = seriesValues.DataPoints.Count - 1; xAxis.Unit = seriesValues.DataPoints.Count/20.0;
Adjust the 20.0 value to change the frequency.
In the latest code I'm getting this as the performance (for i < 1000)
And it does not seem to be affected by subsequent runs of the population, how does this compare to what you are getting?
You can turn on markers for the line series to get the tooltips, but it will affect the performance when you have that many data points. You could do something with the series mouse events to display some tooltips, but it would be a bit complicated, as each line is actually associated with two seperate data points.
You can experiment with something like this for the tooltips:
new xaml:
<UserControl.Resources> <DataTemplate x:Key="tooltipTemplate"> <Border Background="White" CornerRadius="5" Padding="5"> <TextBlock Text="{Binding}" /> </Border> </DataTemplate> </UserControl.Resources>
and (in your grid, under the XamWebChart):
<Popup x:Name="thePopup" Grid.Column="0" Grid.Row="1" IsOpen="False"/>
new code behind (remember to hook up these methods with the corresponding chart events):
private void cht_DataItemMouseMove(object sender, DataItemMouseEventArgs e) { //dealing with a line chart Line l = e.Element as Line; //need to transform the hovered point from the //chart control coordinates to the coordinates on //which the line is plotted (an inner canvas) Canvas plottingPane = l.Parent as Canvas; if (plottingPane != null && l != null) { //transform the clicked point to a point relative to the canvas the //line is drawn on. Point pointInChart = cht.TransformToVisual(plottingPane) .Transform(e.Position); if (l.Tag != null && l.Tag is Dictionary<Type, object>) { //get the point index of the line. the line is really encompassing two points //however. int pointIndex = (int)(l.Tag as Dictionary<Type, object>)[typeof(int)]; double distToStartOfLine = Math.Pow((l.X1 - pointInChart.X), 2) + Math.Pow((l.Y1 - pointInChart.Y), 2); double distToEndOfLine = Math.Pow((l.X2 - pointInChart.X), 2) + Math.Pow((l.Y2 - pointInChart.Y), 2); //is the clicked point closer to the start of the line or the end of the line? if (distToStartOfLine > distToEndOfLine) { pointIndex += 1; } Series series = (l.Tag as Dictionary<Type, object>)[typeof(Series)] as Series; if (series != null) { thePopup.Child = new ContentControl() { Content = series.DataPoints[pointIndex].ToolTip, ContentTemplate = Resources["tooltipTemplate"] as DataTemplate }; thePopup.VerticalOffset = e.Position.Y - 25.0; thePopup.HorizontalOffset = e.Position.X; thePopup.IsOpen = true; } } } } private void cht_DataItemMouseLeave(object sender, DataItemMouseEventArgs e) { thePopup.IsOpen = false; }
Let me know if that helps!