Does anyone have some sample code for a simple scatter-line chart? I have done many of the 2D charts, but haven't done the scatter chart yet. I've seen one example of a scatter-line chart and can't get it to display. Any help would be greatly appreciated. My Y axis is min 0 & max 50 with a single increment of 25. My X Axis is Planets, with the various planets plotted on the chart (assigned values between 5 and 45). I get no errors, but I can't get it to display.
Hello dbishop9,
You can view our online samples here.
The sample in particular that might interest you is the scatter line chart sample.
You can view the code by clicking on the "Source Code" tab at the top.
Elizabeth Albert
Localization Engineer
In the ScatterLine sample you reference, the declaration Protected chartData1 As ChartDatagives an error, it does not recognize the type ChartData. I have included the Import refrences in the sample. Where is this type located? Thanks
I'm sorry, I did not mean annotations, I meant the data point labels (like the data points on the scatter chart). I haven't used them and can't figure out how to set and display them in code. I'm using a datatable with 3 columns; label, column1, & column2. Then I am adding rows with datapoint label, value1, value2. Then binding to the scatter chart, but it isn't displaying the datapoint label.
Here is a sample about how to display data point labels. The page load event has some code for showing the labels. It sets the this.UltraChart1.ScatterChart.ChartText[0].Visible property.
I found this API page for the ChartText property.
Please look at the sample and its code and see if that works. That data point label implementation might be specific to the sample. If it is not useful, I can forward your post to developer support, and they can open a case for you.
I've reviewed that sample, but get an index out of bounds error when addressing ChartText property. Should I be addressing it after I databind?
Yes, please try to set the property after databinding. The sample does databinding before setting the property.
No good, still get index out of bounds. Here is how I am filling my data table:
dt.Columns.Add(
"label", GetType(String))
"column1", GetType(Double))
"column2", GetType(Double))
dt.Rows.Add(
New Object() {"datapoint a", 5, 20})
New Object() {"datapoint b", 7, 25})
New Object() {"datapoint c", 9, 35})
New Object() {"datapoint d", 11, 15})
New Object() {"datapoint e", 13, 28})
New Object() {"datapoint f", 15, 22})
New Object() {"datapoint g", 17, 22})
New Object() {"datapoint h", 19, 25})
New Object() {"datapoint i", 21, 33})
New Object() {"datapoint j", 23, 15})
New Object() {"datapoint k", 25, 28})
New Object() {"datapoint l", 27, 27})
New Object() {"datapoint m", 29, 20})
New Object() {"datapoint n", 31, 25})
New Object() {"datapoint o", 33, 31})
New Object() {"datapoint p", 35, 15})
New Object() {"datapoint q", 37, 28})
New Object() {"datapoint r", 39, 22})
iScatterChart.DataSource = dt
iScatterChart.DataBind()
iScatterChart.ScatterChart.ChartText(0).Visible = True
And of course, the "datapoint x" label is what I'm expecting to display.
Hello Daryl,
Here is the link that will give you more details on dynamically creating ChartText Collection and setting properties: <http://help.infragistics.com/NetAdvantage/ASPNET/2010.2/?page=Chart_Apply_Chart_Text_Labels.html>
Refer to the code on above link. You can add ChartText to other types of chart also.
Please let me know if you have any further questions with this matter.
Thanks,
Bhadresh
It's me again. :)
I followed the "getting started" topic in the help to come up with this code behind for creating the data (just as an example).
protected void Page_Load(object sender, EventArgs e) { this.UltraChart1.DataSource = GetColumnData(); this.UltraChart1.DataBind(); } private DataTable GetColumnData() { DataTable mydata = new DataTable(); mydata.Columns.Add("Series Labels", typeof(string)); mydata.Columns.Add("XValue", typeof(int)); mydata.Columns.Add("YValue", typeof(int)); mydata.Rows.Add(new Object[] { "Mercury", 5, 20 }); mydata.Rows.Add(new Object[] { "Venus", 10, 20 }); mydata.Rows.Add(new Object[] { "Earth", 15, 20 }); mydata.Rows.Add(new Object[] { "Mars", 20, 20 }); return mydata; }
Then I did what Swetha suggested. I set the Column value differently each time, but I'm not sure that it matters. Setting the Visible property on each item might be the key. Here's how it appeared in the .aspx page.
<ChartText> <igchartprop:ChartTextAppearance ChartTextFont="Arial, 7pt" Column="0" ItemFormatString="Mercury" Row="0" Visible="True" /> <igchartprop:ChartTextAppearance ChartTextFont="Arial, 7pt" Column="10" ItemFormatString="Venus" Row="1" Visible="True" /> <igchartprop:ChartTextAppearance ChartTextFont="Arial, 7pt" Column="15" ItemFormatString="Earth" Row="2" Visible="True" /> <igchartprop:ChartTextAppearance ChartTextFont="Arial, 7pt" Column="20" ItemFormatString="Mars" Row="3" Visible="True" /> </ChartText>
I hope that information helps you with setting it in the code behind.
I have attached a screenshot. I can upload my sample project if you'd like, but I simply explored the designer and property windows.
Elizabeth AlbertLocalization Engineer
Sorry, I have already done that, but it only displays the last item, not each one. Example below
chartText.Row = 0
chartText.Column = 0
chartText.ItemFormatString =
"AAAAA"
chartText.Row = 1
"BBBBB"
chartText.Row = 2
"cccCC"
chartText.VerticalAlign = StringAlignment.Far
iScatterChart.ScatterChart.ChartText.Add(chartText)
iScatterChart.ScatterChart.Icon = SymbolIcon.Circle
iScatterChart.ScatterChart.ChartText(0).Visible =
True
Thanks Swetha. Can you give me an example of dynamically creating the ChartText Collection & Chart Type Properties object? Thanks.
Hello dbishop9, Attached is the sample on Scattered chart. In order to set the label for each datapoint please follow the steps below in VS design view:
Select igchart --> ScatterChat in properties --> ChartText collection -- > Add 'Chart Type Properties' --> and set 'ItemFormatString' with 'visible' to true.
Hope this helps. Please let me know if you have any questions.
Sincerely,
Swetha