Hi,
I have a BASIC line chart that is setup as the following:
Y axis - Total Sales (Double)
X axis - Date Project Sold (Dattime converted to String in SQL)
Here is my code: NOTE ucMain is the chart:
ucMain.LineChart.TreatDateTimeAsString = true;
ucMain.Axis.X.TickmarkPercentage = 50;
//ucMain.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL:mm/dd/yyyy>";
ucMain.DataSource = al.SQLDataSet.Tables["chart"];
ANY combo of this does not work. It is really drving me crazy.
Melegant
Try this quick example to see if you can get this very simple line chart working:
DataTable dt = new DataTable();dt.Columns.Add("col1", typeof(double));dt.Columns.Add("col2", typeof(string));dt.Rows.Add(new object[ { 10, "1/1/2008" });dt.Rows.Add(new object[ { 40, "1/2/2008" });dt.Rows.Add(new object[ { 20, "1/3/2008" });dt.Rows.Add(new object[ { 60, "1/4/2008" });ultraChart1.Data.SwapRowsAndColumns = true;ultraChart1.Data.DataSource = dt;If this somehow doesn't work, can you provide a bit more detail about how it doesn't work and what behavior you're seeing/expecting
My problem is that lets say I have a query that returns 100 records for the X-axis. The x-axis will show all 100 lables no matter how I try to configure it. (in the above example I tried using percentage, intervals etc)>
Maybe I am missing something on how to correctly configure the chart to display ONLY let's say 10 percent of the records as labels. I did quite a bit of research and I must be missing one tiny line of code....
Yes, using Percentage tickmarks doesn't work for string axes. I'm fairly certain that we didn't intend percentage to work for this scenario, though we may have to look into this. However, I tried using TickmarkStyle = DataInterval and TickmarkInterval = 10, i get every 10th label displayed. You can try using this approach instead, calculating the interval based on the number of records.
Are you using a NumericTimeSeries?Is the x axis DataType property set to Time?
If you answered no to either question, then you're not using a time scale line chart. In order to format the item labels with dd-MMM-yyyy you have to meet the above conditions.
I am having the same problem, though I am using a composite chart with y and y1 axis showing different parameters (as a line chart). I am setting the series datasource to a DataTable with two columns. A Date Column and a Numeric parameter column. If I set the type of Date column as DateTime, The chart shows Long date time string and I am unable to format it to my required format. This <ITEM_LABEL: dd-MMM-yyyy> doesn't work. If I use this, the chart shows this string and not the formatted date.
On the other hand, If I change the Date column in the datatable to type string, and send in preformatted date strings, the lables are clipped and as the number of ticks increase the lable is clipped even more and becomes invisible.
Sounds like you're not using a time scale on your chart.In order to display a datetime x axis, chart.LineChart.TreatDateTimeAsString has to be false. Otherwise you're still using a string axis and the chart will attempt to display each label until there's no space. Also setting TickmarkIntervalStyle has no effect on a string axis.
this.ultraChart1.ChartType = ChartType.LineChart;this.ultraChart1.LineChart.TreatDateTimeAsString = false;NumericTimeSeries series = new NumericTimeSeries();for (int i = 0; i < 1000; i++){ series.Points.Add(new NumericTimeDataPoint(DateTime.Now.AddMinutes(i), i, "", false));}this.ultraChart1.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL:hh:mm:ss>";this.ultraChart1.Axis.X.TickmarkInterval = 1;this.ultraChart1.Axis.X.TickmarkIntervalType = AxisIntervalType.Hours;this.ultraChart1.Axis.X.TickmarkStyle = AxisTickStyle.DataInterval;this.ultraChart1.Series.Add(series);
I've also noticed strange behaviour with tick marks.
I am plotting stock market price movements over a 24 hour period. A particular commodity has given me 650 ticks between 9.30am and 4.30pm. I am plotting price on the y axis and date/time on the x-axis.
I am using the settings: TickmarkStyle = DataInterval, TickmarkIntervalStyle = Minutes, TickmarkInterval = 60
I would expect to see around 4-5 labels over this time range. The only way i can see this is if I stretch the chart out over 3 screens (cumulative resolution 3840px). When i slowly reduce the width of the app, each label's width slowly gets shrunk making the labels unreadable at half the width and zero width by the time the app is at a reasonable size. It appears to be that each label is given the width = chart.width / # of ticks rather than just giving each label a fixed readable width.
1. Is there anyway to fix this?
2. Even when the app is stretched over three screens, the labels do not pick rounded times e.g. to the nearest hour, minute, etc. In this example my labels are: 16/02/2008 09:42:07, 16/02/2008 013:11:24, 16/02/2008 13:49.09, 16/02/2008 14:42:25, etc which is pretty meaningless (My data is at dynamic intervals, such is the nature of stock markets)
Note: The labels don't even appear when i set the interval to "1 hours" even though this should be identical
Thanks!