Hi,
I am trying to display Markers in my chart in such a way that it only apears on cirtain datapoints but not at all data points. Currently I am using line chart and Binding my collection with chart at runtime and maping Xvalue and Yvalue on my chart. But I want to display markers on cirtain XValues not to all Xvalues in mychart . Can anyone suggest me the solution please.
Thanks.
Currently, there is no way to do this with a template or converter (that I see). One way to do this programmatically is, when the data changes you can override the Marker property in the DataPoint class.
Each Series is populated with DataPoint items. The Series object contains a Marker property which is applied to all items. Go ahead and assign a Marker you want to this class. For each DataPoint that you do not want to show the default Marker, you can assign a Marker which has Type set to None. To hide the Marker text, set the Marker Foreground to Transparent.
Another approach is to not assign a default Marker to the Series. Simply assign a New Marker to each relevant DataPoint at run time.
If you would like to submit a feature request for this idea for a feature, please do so. We are always listening to our customers on how to improve our products!http://devcenter.infragistics.com/Protected/RequestFeature.aspx
Thank you!
Hi Curtis,
Thanks for your reply. I already have done in the same way but by this method I have identify a problem which is to create datapoints explicitely, and if want bind my graph with my collection then on data change I have to explicitely notify my Gui to redraw graph on change in data in my collection.
Can you please suggest me more efficient way to achieve this functionality.
Thanks Curtis.
Cheers.
Hello,
I looked at the code you attached. Assigning the ToolTip to the DataPoint is the way to display a ToolTip for a data point and its marker - so what you have right now looks good.
In order to help improve the sample you sent, it would be more efficient working with developer support. This case needs more direct interaction with you to ask you questions and answer them right away. Doing this on the forums for this type of case would take too long. For example, I would need to ask you what parts of the code you sent did you want to improve exactly and what areas are proving problematic for you.
In order to expedite getting you the help you need, I've opened a Developer Support case for this issue. You should hear from a support engineer soon. The case he will be referring to will be: CAS-46373-2NX1M7
Thanks Curtis for your help and assistance.
Muhammad,
The attached sample seems to display toolTips on the markers.
Did you have any ather question?
Sincerely,
Sam
Hi Sam,
Thanks for reply, Well yes its displaying tooltip but I need to show some custom text in my marker label not the valueX or ValueY. Any other custom value... Can you please suggest a solution in this regard.
The chart uses the DataPoint for markers. The ToolTip can be mapped, but it is not a valid token for markers. ValueX and ValueY are designed for the markers.
Here is additional iniformation about data mapping criteria:
http://help.infragistics.com/NetAdvantage/WPF/current/CLR3.5/?page=xamChart_DataMapping_for_xamChart.html
Let me know if you have any question.
Thanks for your reply and the solution you provided it was already working but for static datas. If you want to simulate your graphs on change in data and on notificationchanged then it ill never work. But I have found the solution please find the code below:
public static Series MakeSeriesForLabels<T>(T SeriesList, string Labelstring)
{
Series sr = new Series();
Binding DataMapingBinding = new Binding();
DataMapingBinding.Source = SeriesList;
sr.SetBinding(
Series.DataSourceProperty, DataMapingBinding);
sr.Label = Labelstring;
sr.Fill =
Brushes.Transparent;
sr.ChartType =
ChartType.ScatterLine;
sr.DataMapping =
"ValueX=CurvePointX ; ValueY=CurvePointY; ToolTip= Tenors";
Marker m = new Marker();
m.Fill =
Brushes.Green;
m.Type =
MarkerType.Star5;
m.Stroke =
Brushes.Black;
m.SetBinding(
Marker.FormatProperty, "Tenors");
//m.Format = "";// Here I want to display Tenors maped in ToolTip
sr.Marker = m;
return sr;
}
This function will definately work for anytype of collection to simulate change in data on runtime with markers depending upon your data and containting text outof any property from binded collection. If you could suggest anything better this then most welcome.
If you are trying to display the tooltip text on the marker, then the tooltips have to be defined for each data point, and then create markers for the data points that need to be customized, then you can set the data point's marker property with the customized marker.
Here is an example:
Marker marker9; Random rand = new Random(); for (int i = 0; i < 5; i++) { DataPoint dp = new DataPoint(); dp.ChartParameters.Add(ChartParameterType.ValueX, ValueX, rand.Next(1, 5)); dp.ChartParameters.Add(ChartParameterType.ValueY, ValueY, rand.Next(1, 5)); dp.ToolTip = "your text" + dp.Value.ToString();
marker9 = new Marker(); marker9.Format = dp.ToolTip.ToString(); marker9.Type = MarkerType.Rectangle; dp.Marker = marker9; ser.DataPoints.Add(dp); }
Thanks Curtis for your reply.
Just to clarify a couple of things on our end. Marker is eventually derived from the WPF base class FrameworkContentElement. FrameworkContentElement contains a ToolTip property. However, the Chart does not use this property. The Chart is designed to use the DataPoint ToolTip for displaying ToolTips on individual points along the chart.
If you think we ought to support separate ToolTips on the Markers, I encourage you to submit this as a feature request:http://devcenter.infragistics.com/Protected/RequestFeature.aspx
From reading your posts, are you asking if there is a way to bind the DataPoint.ToolTip text to the DataPoint.Marker Text? Would this solve the issue?
Thanks,