c# - Spreadsheet gear Chart's x axis date is appearing as whole number -
i generating output using spreadsheet gear contains chart output , xaxis has date , y axis has numbers plot chart. @ end, application copies source workbook sheets new workbook's spreadsheet. while doing this, date values in chart's xaxis not appearing date (mm/dd/yy) in sheet have copied (i.e. in new workbook's sheet), instead, getting number (such 39174, 39175, 39176. julian date?). though formatting date column date format (mm/dd/yy), still not referred date in graph. have cross checked right clicking on cell (in date column) , choosing 'format cells' option. showing has used custom formatting (as mm/dd/yy) it. also, have coded update links while copying new sheet, still not working.
please advise resolve issue.
thanks
you can either set format of chart labels using iticklabels interface or set property of axis linked source , set format of range data source:
here example of how set chart formatting
here detail of properties of iticklabels
this example of setting label format
chart.axes[axistype.value].ticklabels.numberformat = "0.00";
edit
this other method format cell range , link chart axis format range:
using spreadsheetgear basic chart example template:
// declare data range spreadsheetgear.irange datarange = worksheet.cells["a2:a13"]; // set data range format datarange.numberformat = "0.0";
the chart set follows
double left = windowinfo.columntopoints(2.0); double top = windowinfo.rowtopoints(1.0); double right = windowinfo.columntopoints(9.0); double bottom = windowinfo.rowtopoints(16.0); spreadsheetgear.charts.ichart chart = worksheet.shapes.addchart(left, top, right - left, bottom - top).chart; // set chart's source data range, plotting series in columns. chart.setsourcedata(datarange, spreadsheetgear.charts.rowcol.columns); // set chart type. chart.charttype = spreadsheetgear.charts.charttype.area; // set axis label format data range chart.axes[axistype.value].ticklabels.numberformatlinked = true;
to explicitly set chart axis range replace last line this:
chart.axes[axistype.value].ticklabels.numberformat = "0.00";
Comments
Post a Comment