I've got data that is formatted in a table as follows, and am displaying it in a Scatter Chart in WinChart version 7.3.20073.38:
Date (Text), Index (Integer), Value (Double) 2007-01-20, 1, 182708.213068332 2007-04-20, 2, 191849.206636247 2007-07-19, 3, 181909.247938635 2007-10-17, 4, 193106.239361725 2008-01-15, 5, 186136.687476901 2008-04-14, 6, 181598.738009246 2008-07-13, 7, 182911.470058264 2008-10-11, 8, 180885.534667417
The scatter chart is using the second column (Index) for the X Axis, and the third column (Value) for the Y Axis. The index column is used for the X axis so that I may use custom code to calculate and graph the best-fit polynomial on the chart. The first column is a text column, not a date column, representing the date that the value was taken.
I'm getting a chart as shown in the attached screen shot, but I would like the X axis labels to use the first text field in each row, instead of the second field. I've tried setting the X Axis label's ItemFormat to <ITEM_LABEL>, but this only results in the X Axis being labeled with a bunch of literal "<ITEM_LABEL>" strings.
How would I go about having the text fields show up as X Axis labels?
You are looking at a IRenderLabel implementation. Take a look at the "Custom Labels" section in my chart blog post:
http://blogs.infragistics.com/blogs/skim/archive/2008/09/05/chart-university-chart-101-and-some-201-301-401-stuff.aspx
Hi, I have an issue that I cannot resolve. I followed the process on that blog but for some reason, the X Axis label will only change if i hover on the scatter plot. Also, the X axis label changes according to the data of the hovered plot.
This is the code that i used. I also used the data that u post above this email chain. Thanks.
NLDChart.Axis.X.Labels.ItemFormat = AxisItemLabelFormat.Custom
"<DATA_VALUE:#>"
Regards,
Bobby Pohan
bpohan said:I followed the process on that blog but for some reason, the X Axis label will only change if i hover on the scatter plot
This part makes me think that you are talking about tooltips and not the x axis labels. Are you saying the axis labels toggle back and forth depending on whether you are above the data point.
bpohan said:Also, the X axis label changes according to the data of the hovered plot.
The labels are dependant on the data. If this is a scatter chart then the x and y axis will both be numeric. By default, our axis will dynamically change the range based on the range of data. If you want it to be static, you have to look at the "Custom Axis Range" section of the blog post.
If this doesn't answer you question. Could you be specific on what you are trying to do?
Thanks for the quick response. What I want to do is to be able to change the X Axis label by lets just say, clicking a button. So, if this is the data that i use:
dt.Columns.Add("Month", typeof(string));
dt.Columns.Add("Leads", typeof(int));
dt.Columns.Add("Sales", typeof(int));
dt.Rows.Add("January", 120, 50);
dt.Rows.Add("February", 90, 44);
dt.Rows.Add("March", 70, 22);
dt.Rows.Add("April", 66, 21);
dt.Rows.Add("May", 80, 42);
dt.Rows.Add("June", 85, 48);
by default, i want to show the X axis label as the second column (i.e. 120, 90, 70, etc.). Then, by clicking the button, I want to change the X axis label to
January, February, etc. from the 1st column in my scatter plot graph. Is this possible? Like i said previously,
I used :
NLDChart.Axis.X.Labels.ItemFormatString =
"<SERIES_LABEL:#>"
But, the label on the X axis' ticks changes based on what data plot that I hover. Again, I appreciate your help.
You want to toggle between
ultraChart1.Axis.X.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.DataValue;
ultraChart1.Axis.X.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.ItemLabel;
Thanks, I tested, it worked by showing the correct X axis label. But, when I click the button to run the
I received the attach result. The X axis are only ITEM_LABEL. Any suggestion?
For a scatter chart both the x and y axis is numeric. There is no item or series equivalent at each of the tickmarks.
If you wanted to use a scatter, instead of line or the other chart types, then you could set a custom range on the axis and use a custom token using IRenderLabel. This allow you to post any string that you want. So, like 1 to 12. Then convert those to months. You can find IRenderLabel implementations all throughout the forum including my blog post.
Hi Sung Kim,
I modified the graph to scatter plot and the button2 code to this:
private
void button2_Click(object sender, EventArgs e) {
//ultraChart1.Axis.X.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.ItemLabel;
ultraChart1.Axis.X.Labels.ItemFormat =
AxisItemLabelFormat.Custom;
ultraChart1.Axis.X.Labels.ItemFormatString =
"<SERIES_LABEL>";}
The "symptoms" are the same just like my software. When i click the button2, it will change the X axis to only SERIES_LABEL for all ticks. BUT, when I highlight one of the plot, and move my mouse to outside of the graph boundary box, it will immediately populate ALL the ticks to the corresponding month for instance JUNE. I attach the image. Thanks. Bobby Pohan
I tried the attachment that you included on ur previous post. It worked untl I changed the graph to scatter plot. So, I assume this only works on bar graph then? Is there a way to work around so that I can use the same functionality in the scatter plot? Thanks. Bobby Pohan
I am not sure what is happening over here. I even tested your code on the Infragistics sample code. I used LabelsTitlesTooltips: CustomToolTips form. I changed the graph to scatter plot. I still received the same behavior. It "<ITEM_LABELS> on the X axis. Let me remind you that I use VB.Net instead of C# if that makes any difference. Do I need to set up something when changing the graph to scatter plot? Thanks. Bobby Pohan
I am using the following and not seeing an issue (9.1 vs08 sample attached):
private void Form1_Load(object sender, EventArgs e){ DataTable dt = new DataTable(); dt.Columns.Add("Month", typeof(string)); dt.Columns.Add("Leads", typeof(int)); dt.Columns.Add("Sales", typeof(int)); dt.Rows.Add("January", 120, 50); dt.Rows.Add("February", 90, 44); dt.Rows.Add("March", 70, 22); dt.Rows.Add("April", 66, 21); dt.Rows.Add("May", 80, 42); dt.Rows.Add("June", 85, 48); ultraChart1.Data.DataSource = dt; ultraChart1.Data.DataBind();}
private void button1_Click(object sender, EventArgs e){ ultraChart1.Axis.X.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.DataValue;}
private void button2_Click(object sender, EventArgs e){ ultraChart1.Axis.X.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.ItemLabel;}