P
Preben Zacho
Hi there
I'm new to charts and I'm trying to create a chart that shows development of
a share/portfolio over a 6 month period. The chart should show the closing
rate for the share for each day (make it about 180 days). However, on the
X-axis I only want to show 6 ticks, one for each of the months. I can't make
that work.
In the following excaple (from C#) I try to display values for an entire
year but only display 4 months on the X-axis. So you should still be able to
see that values for fx. Feb, Mar in between Jan and April. Hope this makes
sense to you. Here is the sample code:
using AxMicrosoft.Office.Interop.Owc11;
using Microsoft.Office.Interop.Owc11;
private AxMicrosoft.Office.Interop.Owc11.AxChartSpace axChartSpace1;
string XCategories = "Jan,Apr,Jul,Oct";
string XValues = "12,13,14,12,14,15,16,17,19,20,31,21";
// First add a chart to the chart space
Microsoft.Office.Interop.Owc11.ChChart chart = axChartSpace1.Charts.Add(0);
// Now add a new serie to the collection
chart.SeriesCollection.Add(0);
// Add the categories
chart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, XCategories);
// Add the values
chart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, XValues);
//Set tick spacing = 4 (in other words, only show the 4 months as the Axis
names, but display all 12 values for the entire year. This does not work
properly).
chart.Axes[0].TickLabelSpacing = 4;
The result is a chart where only the first 4 values are shown and ONLY "Jan"
is displayed on the axis.
Regards
Preben Zacho
I'm new to charts and I'm trying to create a chart that shows development of
a share/portfolio over a 6 month period. The chart should show the closing
rate for the share for each day (make it about 180 days). However, on the
X-axis I only want to show 6 ticks, one for each of the months. I can't make
that work.
In the following excaple (from C#) I try to display values for an entire
year but only display 4 months on the X-axis. So you should still be able to
see that values for fx. Feb, Mar in between Jan and April. Hope this makes
sense to you. Here is the sample code:
using AxMicrosoft.Office.Interop.Owc11;
using Microsoft.Office.Interop.Owc11;
private AxMicrosoft.Office.Interop.Owc11.AxChartSpace axChartSpace1;
string XCategories = "Jan,Apr,Jul,Oct";
string XValues = "12,13,14,12,14,15,16,17,19,20,31,21";
// First add a chart to the chart space
Microsoft.Office.Interop.Owc11.ChChart chart = axChartSpace1.Charts.Add(0);
// Now add a new serie to the collection
chart.SeriesCollection.Add(0);
// Add the categories
chart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, XCategories);
// Add the values
chart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataLiteral, XValues);
//Set tick spacing = 4 (in other words, only show the 4 months as the Axis
names, but display all 12 values for the entire year. This does not work
properly).
chart.Axes[0].TickLabelSpacing = 4;
The result is a chart where only the first 4 values are shown and ONLY "Jan"
is displayed on the axis.
Regards
Preben Zacho