/** * Create a new SpreadsheetML chart legend */ public XSSFChartLegend(XSSFChart chart) { CT_Chart ctChart = chart.GetCTChart(); this.legend = (ctChart.IsSetLegend()) ? ctChart.legend : ctChart.AddNewLegend(); }
public void FillChart(IChart chart, IChartAxis[] axis) { if (!(chart is XSSFChart)) { throw new ArgumentException("Chart must be instance of XSSFChart"); } XSSFChart xssfChart = (XSSFChart)chart; CT_PlotArea plotArea = xssfChart.GetCTChart().plotArea; int allSeriesCount = plotArea.GetAllSeriesCount(); CT_ScatterChart scatterChart = plotArea.AddNewScatterChart(); AddStyle(scatterChart); for (int i = 0; i < series.Count; ++i) { Series s = (Series)series[i]; s.SetId(allSeriesCount + i); s.SetOrder(allSeriesCount + i); s.AddToChart(scatterChart); } foreach (IChartAxis ax in axis) { scatterChart.AddNewAxId().val = (uint)ax.Id; } }
static void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, string serie1, string serie2, bool enableMajorGridline = false) { XSSFChart chart = (XSSFChart)drawing.CreateChart(anchor); chart.SetTitle("Test 1"); IChartLegend legend = chart.GetOrCreateLegend(); legend.Position = LegendPosition.TopRight; ILineChartData <double, double> data = chart.ChartDataFactory.CreateLineChartData <double, double>(); // Use a category axis for the bottom axis. IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom); IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); leftAxis.Crosses = AxisCrosses.AutoZero; IChartDataSource <double> xs = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)); IChartDataSource <double> ys1 = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1)); IChartDataSource <double> ys2 = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1)); var s1 = data.AddSeries(xs, ys1); s1.SetTitle(serie1); var s2 = data.AddSeries(xs, ys2); s2.SetTitle(serie2); chart.Plot(data, bottomAxis, leftAxis); //add major gridline, available since NPOI 2.5.5 var plotArea = chart.GetCTChart().plotArea; plotArea.catAx[0].AddNewMajorGridlines(); plotArea.valAx[0].AddNewMajorGridlines(); }
public void FillChart(SS.UserModel.IChart chart, params IChartAxis[] axis) { if (!(chart is XSSFChart)) { throw new ArgumentException("Chart must be instance of XSSFChart"); } XSSFChart xssfChart = (XSSFChart)chart; CT_PlotArea plotArea = xssfChart.GetCTChart().plotArea; int allSeriesCount = plotArea.GetAllSeriesCount(); CT_BarChart barChart = plotArea.AddNewBarChart(); barChart.AddNewVaryColors().val = 0; for (int i = 0; i < series.Count; ++i) { Series s = (Series)series[i]; s.SetId(allSeriesCount + i); s.SetOrder(allSeriesCount + i); s.AddToChart(barChart); } foreach (IChartAxis ax in axis) { barChart.AddNewAxId().val = (uint)ax.Id; } }
/** * Create a new SpreadsheetML manual layout for chart. * @param chart a chart to create layout for. */ public XSSFManualLayout(XSSFChart chart) { CT_PlotArea ctPlotArea = chart.GetCTChart().plotArea; CT_Layout ctLayout = ctPlotArea.IsSetLayout() ? ctPlotArea.layout : ctPlotArea.AddNewLayout(); InitLayout(ctLayout); }
public void FillChart(IChart chart, IChartAxis[] axis) { if (!(chart is XSSFChart)) { throw new ArgumentException("Chart must be instance of XSSFChart"); } XSSFChart xssfChart = (XSSFChart)chart; CT_PlotArea plotArea = xssfChart.GetCTChart().plotArea; CT_ScatterChart scatterChart = plotArea.AddNewScatterChart(); AddStyle(scatterChart); foreach (Series s in series) { s.AddToChart(scatterChart); } foreach (IChartAxis ax in axis) { scatterChart.AddNewAxId().val = (uint)ax.Id; } }
public void FillChart(SS.UserModel.IChart chart, params IChartAxis[] axis) { if (!(chart is XSSFChart)) { throw new ArgumentException("Chart must be instance of XSSFChart"); } XSSFChart xssfChart = (XSSFChart)chart; CT_PlotArea plotArea = xssfChart.GetCTChart().plotArea; CT_LineChart lineChart = plotArea.AddNewLineChart(); lineChart.AddNewVaryColors().val = 0; foreach (Serie s in series) { s.AddToChart(lineChart); } foreach (IChartAxis ax in axis) { lineChart.AddNewAxId().val = (uint)ax.GetId(); } }
public XSSFManualLayout(XSSFChart chart) { CT_PlotArea plotArea = chart.GetCTChart().plotArea; this.InitLayout(plotArea.IsSetLayout() ? plotArea.layout : plotArea.AddNewLayout()); }