So I have a Composite Chart made up of Line Chart layers with the X-Axis representing a bunch of dates, and the Y-Axes representing numeric values. Since the Series representing the data are NumericTimeSeries, the graph adds weekends to the X-Axis even though the data supplied are strictly weekdays.
I can switch to NumericSeries, but it doesn't draw anything unless I change the Axis.DataType to AxisDataType.String, and the Axis.SetLabelAxisType to SetLabelAxisType.ContinuousData which is fine except that my date formatting in the Axis.Labels.ItemFormatString gets ignored ("<ITEM_LABEL:MM/dd/yyyy>").
I'd prefer to keep the NumericTimeSeries and somehow communicate that I wish for missing time intervals to be ignored, but I doubt that's possible from what I've seen in the scant documentation. If I'm forced to treat the dates as strings, how can I force them to be formatted the way I need?
Thanks,ChrisPowers
By the way, I'm using 2007 Volume 1 CLR 2.x Release (v7.1.20071.40).
try setting the X axis's TimeAxisStyle property to Discrete.
you could also use IRenderLabel to force formatting on the string labels:
string IRenderLabel.ToString(Hashtable context)
{
return DateTime.Parse(context["ITEM_LABEL"].ToString()).ToString("MM/dd/yyyy");
}
Do you know if setting the TimeAxisStyle to Discrete will work, or you just taking a guess at it?
I ask because I tried this before and it had no effect, but I may have been overlooking some other setting elsewhere. However, when the forum archive went back up last week, I managed to find a reference to that IRenderLabel method for intercepting the label formatting, and it seems to be working okay. So, I'm reluctant to spend the time reverting my code to try out the Discrete TimeAxisStyle only to have it not work, but I would prefer to do it the right way if possible. Right now, what I'm doing feels like a hack.
it should work, assuming ((LineChartAppearance)lineLayer.ChartTypeAppearanc).TreatDateTimeAsString = true, axisX.DataType = Time, and the only series used are NumericTimeSeries.
when i tested this using 7.1.20071.40, there was an issue with the first label on the axis not appearing... however, this is fixed in the current hotfix version (7.1.20071.1067)
Thanks for responding, David.
I went back and changed the code to try what you suggested, but it does not appear to work. To clarify: what I want is for there to be no space allocated on the chart for weekends, whether they're labeled and plotted or not. Like any financial chart, the x-distance between the points on Thursday and Friday should be the same as the x-distance between the points on Friday and Monday.
Is that what you're able to accomplish with the above code?
The closest I was able to come to what I need is to use NumericSeries, treat the X-axis labels as string, and format them using the IRenderLabel method. The problem with this is that it then becomes a huge pain in the @$$ to customize the X-axis' TickmarkType and Interval.
I tried attaching a screenshot of what I'm getting when I try the suggested code above.
okay, i guess i didn't understand the question fully. it's not possible to plot on a time scale adjusted for weekend time in this way. all time axes are linear.
i think your solution of using a NumericSeries is the least complex (and therefore the best) way to work around this limitation.
Nice to have some closure on this issue. Thanks for your help, David.