User (Legacy) Posted February 9, 2005 Report Share Posted February 9, 2005 Is there any way when creating a scatter plot to force a Chart control to honor the the AxisX.LabelFormat.CustomFormat property? I am using the following code to create a chart: ArrayList container = new ArrayList(); ArrayList dates = new ArrayList(); ArrayList values = new ArrayList(); dates.Add(DateTime.Today.AddDays(10)); dates.Add(DateTime.Today.AddDays(30)); dates.Add(DateTime.Today.AddDays(40)); dates.Add(DateTime.Today.AddDays(44)); values.Add(10); values.Add(20); values.Add(15); values.Add(30); container.Add(dates); container.Add(values); chart2.Gallery = SoftwareFX.ChartFX.Gallery.Scatter; chart2.DataType[0] = DataType.XValue; chart2.DataType[1] = DataType.Value; chart2.Series[0].Gallery = Gallery.Lines; chart2.Series[0].LineWidth = 1; chart2.Series[0].MarkerShape = MarkerShape.Diamond; chart2.Series[0].Color = Color.Orange; chart2.AxisX.LabelsFormat.Format = AxisFormat.DateTime; chart2.AxisX.LabelsFormat.CustomFormat = "M/d/yy"; chart2.DataSource = new ListProvider(container); When the chart is initially rendered, the custom format is honored and the dates appear in the '2/9/05' format as they should. However, when the chart resized so that it is smaller horizontally, suddenly the x axis values are displayed as "Feb '05 | Mar". I have also seen this behavior when dealing with charts with 100 or more datapoints, where suddenly the x axis values will be displayed as "Q1 '03 | Q2 | Q3", etc. Is there any way to prevent this behavior? Thanks, Rich BTW: I know I can prevent this behavior by switching chart2.DataType[0] to Label, but that is not an acceptable solution since it treats each date as a label and not an XValue (causing each datapoint to be equidistant to each other datapoint which is incorrect). Link to comment Share on other sites More sharing options...
Software FX Posted February 11, 2005 Report Share Posted February 11, 2005 > Is there any way to prevent this behavior? Absolutely. When using dates the custom format is a composite string containing different formats to use depending on the interval: <day format>;<month format>;<abbreviated year format>;<quarter format>;<year format> Where: <day format> = Regular date format (Default = Default Date Format) <month format> = How the labels are display if the interval is month (default = "MMM") <abbreviated year format>: When interval is Month or Quarter, the year is displayed when it changes (Default = 'YY) <quarter format> = When the interval is Quarter. Use {q} as the placeholder for the Quarter number (Default = Q{q}) <year format> = Used when the interval is a year or more. In your case you want the quarter format to be the same as the day format, you want to set: chart.AxisX.LabelFormat.Custom = "MM/dd/yy;MM/dd/yy;;MM/dd/yy;yyyy" -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.