ApiChart

new ApiChart()

Class representing a chart.

Methods

Name Description
AddSeria

Adds a new series to the current chart.

ApplyChartStyle

Sets a style to the current chart by style ID.

GetClassType

Returns a type of the ApiChart class.

RemoveSeria

Removes the specified series from the current chart.

SetAxieNumFormat

Sets the specified numeric format to the axis values.

SetCatFormula

Sets a range with the category values to the current chart.

SetDataPointFill

Sets the fill to the data point in the specified chart series.

SetDataPointOutLine

Sets the outline to the data point in the specified chart series.

SetHorAxisLablesFontSize

Specifies the font size to the horizontal axis labels.

SetHorAxisMajorTickMark

Specifies the major tick mark for the horizontal axis.

SetHorAxisMinorTickMark

Specifies the minor tick mark for the horizontal axis.

SetHorAxisOrientation

Specifies the direction of the data displayed on the horizontal axis.

SetHorAxisTickLabelPosition

Sets the possible values for the position of the chart tick labels in relation to the main horizontal label or the chart data values.

SetHorAxisTitle

Specifies the chart horizontal axis title.

SetLegendFill

Sets the fill to the chart legend.

SetLegendFontSize

Specifies the legend font size.

SetLegendOutLine

Sets the outline to the chart legend.

SetLegendPos

Specifies the chart legend position.

SetMajorHorizontalGridlines

Specifies the visual properties of the major horizontal gridline.

SetMajorVerticalGridlines

Specifies the visual properties of the major vertical gridline.

SetMarkerFill

Sets the fill to the marker in the specified chart series.

SetMarkerOutLine

Sets the outline to the marker in the specified chart series.

SetMinorHorizontalGridlines

Specifies the visual properties of the minor vertical gridline.

SetMinorVerticalGridlines

Specifies the visual properties of the minor vertical gridline.

SetPlotAreaFill

Sets the fill to the chart plot area.

SetPlotAreaOutLine

Sets the outline to the chart plot area.

SetSeriaName

Sets a name to the specified series.

SetSeriaValues

Sets values from the specified range to the specified series.

SetSeriaXValues

Sets the x-axis values from the specified range to the specified series. It is used with the scatter charts only.

SetSeriesFill

Sets the fill to the specified chart series.

SetSeriesOutLine

Sets the outline to the specified chart series.

SetShowDataLabels

Specifies which chart data labels are shown for the chart.

SetShowPointDataLabel

Spicifies the show options for the data labels.

SetTitle

Specifies the chart title with the specified parameters.

SetTitleFill

Sets the fill to the chart title.

SetTitleOutLine

Sets the outline to the chart title.

SetVerAxisOrientation

Specifies the direction of the data displayed on the vertical axis.

SetVerAxisTitle

Specifies the chart vertical axis title.

SetVertAxisLablesFontSize

Specifies the font size to the vertical axis labels.

SetVertAxisMajorTickMark

Specifies the major tick mark for the vertical axis.

SetVertAxisMinorTickMark

Specifies the minor tick mark for the vertical axis.

SetVertAxisTickLabelPosition

Sets the possible values for the position of the chart tick labels in relation to the main vertical label or the chart data values.

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.SetName("sheet 1");
oWorksheet.GetRange("B1").SetValue("Row 1");
oWorksheet.GetRange("C1").SetValue("Row 2");
oWorksheet.GetRange("D1").SetValue("Row 3");
oWorksheet.GetRange("A2").SetValue("Category 1");
oWorksheet.GetRange("A3").SetValue("Category 2");
oWorksheet.GetRange("A4").SetValue("Category 3");
oWorksheet.GetRange("A5").SetValue("Category 4");
oWorksheet.GetRange("B2").SetValue("4.3");
oWorksheet.GetRange("B3").SetValue("2.5");
oWorksheet.GetRange("B4").SetValue("3.5");
oWorksheet.GetRange("B5").SetValue("4.5");
oWorksheet.GetRange("C2").SetValue("2.4");
oWorksheet.GetRange("C3").SetValue("4.4");
oWorksheet.GetRange("C4").SetValue("1.8");
oWorksheet.GetRange("C5").SetValue("2.8");
oWorksheet.GetRange("D2").SetValue("2");
oWorksheet.GetRange("D3").SetValue("2");
oWorksheet.GetRange("D4").SetValue("3");
oWorksheet.GetRange("D5").SetValue("5");
var oChart = oWorksheet.AddChart("'sheet 1'!$A$1:$D$5", true, "bar", 2, 100 * 36000, 70 * 36000, 0, 2 * 36000, 5, 3 * 36000);
oChart.SetVerAxisTitle("Vertical Title", 10);
oChart.SetHorAxisTitle("Horizontal Title", 11);
oChart.SetLegendPos("right");
oChart.SetShowDataLabels(false, false, true, false);
oChart.SetTitle("Main Chart Title", 13);
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(51, 51, 51));
oChart.SetSeriesFill(oFill, 0, false);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
oChart.SetSeriesFill(oFill, 1, false);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(128, 128, 128));
oChart.SetSeriesFill(oFill, 2, false);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 213, 191));
oChart.SetSeriesFill(oFill, 3, false);
builder.SaveFile("xlsx", "ApiChart.xlsx");
builder.CloseFile();

Resulting document