Recently I created a graph using the CVI built in Graphing Wizard in Excel Reports.
When I plotted the graph, the Y Axis always crossed over the 0 point on the X-Axis.
My graph actually had negative values in it on the X-Axis, i.e. -20 to +20, so this was not what I wanted.
In Excel you can change this by selecting the X-Axis, right clicking then going to format axis and at the bottom of the properties GUI you get:
Vertical axis crosses:
O Automatic
O Axis value: [ ]
O Maximum axis value
I did not see a function in Excel Reports to handle this type of property for an AXIS, so below is a short snippet of code which can accomplish this task:
(This is assuming you have already set up a chart and have its handle)
/* variables */
ERRORINFO errorinfo;
static CAObjHandle axesHandle;
/* Get handle of the AXES to change the crosses x at property */
Excel_ChartAxes (chartsheetHandle, &errorinfo,CA_VariantInt(1),ExcelConst_xlPrimary,&axesHandle);
Excel_SetProperty (axesHandle, NULL, Excel_AxisCrosses, CAVT_LONG, ExcelConst_xlAxisCrossesMinimum);
It took quite awhile to figure this out, so I hope someone else can benefit from it!
Joe
Joe,
Thanks! This is great! I was having a similar problem. When using the Excel Report library code,
there was no way to set the property for the X-Axis units to the bottom of the chart. The default
for the library code was to set the unit label to "Next to Axis" rather than "Low". This meant that
if the Y-Axis had positive and negative values, the X-Axis unit label would only be displayed at
the zero-crossing of the Y-Axis. This was very frustrating to figure out … I almost had it working,
by looking into the Excel code, and then I stumbled across your post which nailed it for me.
Thanks so much for posting your solution. For anyone interested, my fix for the above problem
is pasted below:
ERRORINFO errorinfo;
static CAObjHandle axesHandle;
/* Get handle of the AXES to change the Axis tick label position to Low */
Excel_ChartAxes (hChartS11, &errorinfo,CA_VariantInt(1),ExcelConst_xlPrimary,&axesHandle);
Excel_SetProperty (axesHandle, NULL, Excel_AxisTickLabelPosition, CAVT_LONG, ExcelConst_xlLow);
Great!
I am so glad it helped somebody, thanks for letting me know!
Joe