public void TestOneSeriePlot() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, plotData).Build(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Bottom); IChartAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); IScatterChartData <string, double> scatterChartData = chart.ChartDataFactory.CreateScatterChartData <string, double>(); IChartDataSource <String> xs = DataSources.FromStringCellRange(sheet, CellRangeAddress.ValueOf("A1:J1")); IChartDataSource <double> ys = DataSources.FromNumericCellRange(sheet, CellRangeAddress.ValueOf("A2:J2")); IScatterChartSeries <string, double> series = scatterChartData.AddSeries(xs, ys); Assert.IsNotNull(series); Assert.AreEqual(1, scatterChartData.GetSeries().Count); Assert.IsTrue(scatterChartData.GetSeries().Contains(series)); chart.Plot(scatterChartData, bottomAxis, leftAxis); }
private static void CreateChart(ISheet sheet, IDrawing drawing, IClientAnchor anchor, string serieTitle, int startDataRow, int endDataRow, int columnIndex) { XSSFChart chart = (XSSFChart)drawing.CreateChart(anchor); IBarChartData <string, double> barChartData = chart.ChartDataFactory.CreateBarChartData <string, double>(); IChartLegend legend = chart.GetOrCreateLegend(); legend.Position = LegendPosition.Bottom; IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom); bottomAxis.MajorTickMark = AxisTickMark.None; IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); leftAxis.Crosses = AxisCrosses.AutoZero; leftAxis.SetCrossBetween(AxisCrossBetween.Between); IChartDataSource <string> categoryAxis = DataSources.FromStringCellRange(sheet, new CellRangeAddress(startDataRow, endDataRow, 0, 0)); IChartDataSource <double> valueAxis = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(startDataRow, endDataRow, columnIndex, columnIndex)); var serie = barChartData.AddSeries(categoryAxis, valueAxis); serie.SetTitle(serieTitle); chart.Plot(barChartData, bottomAxis, leftAxis); }
static void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, string serie1, string serie2) { IChart chart = drawing.CreateChart(anchor); 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.GetChartAxisFactory().CreateCategoryAxis(AxisPosition.Bottom); IValueAxis leftAxis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.Left); leftAxis.SetCrosses(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); }
public void TestFormulaCache() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, plotData).Build(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Bottom); IChartAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); IScatterChartData scatterChartData = chart.ChartDataFactory.CreateScatterChartData(); DataMarker xMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A1:E1")); DataMarker yMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A2:E2")); IScatterChartSerie serie = scatterChartData.AddSerie(xMarker, yMarker); chart.Plot(scatterChartData, bottomAxis, leftAxis); XSSFScatterChartData.Serie xssfScatterSerie = (XSSFScatterChartData.Serie)serie; XSSFNumberCache yCache = xssfScatterSerie.LastCalculatedYCache; Assert.AreEqual(5, yCache.PointCount); Assert.AreEqual(4.0, yCache.GetValueAt(3), 0.00001); Assert.AreEqual(16.0, yCache.GetValueAt(5), 0.00001); }
/// <summary> /// Ctor. /// </summary> /// <param name="a1"></param> /// <param name="a2"></param> /// <param name="ipsve"></param> /// <param name="vxs"></param> public Category2StyleContext(IChartAxis a1, IChartAxis a2, IProvideSeriesValueExtents ipsve, double[] vxs) { Category1Axis = a1; Category2Axis = a2; ValueExtents = ipsve; Values = vxs; }
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 TestXSSFChartAxis() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = wb.CreateSheet(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); axis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.BOTTOM); }
static void Main(string[] args) { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = wb.CreateSheet("linechart"); int NUM_OF_ROWS = 3; int NUM_OF_COLUMNS = 10; // Create a row and put some cells in it. Rows are 0 based. IRow row; ICell cell; for (int rowIndex = 0; rowIndex < NUM_OF_ROWS; rowIndex++) { row = sheet.CreateRow((short)rowIndex); for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { cell = row.CreateCell((short)colIndex); cell.SetCellValue(colIndex * (rowIndex + 1)); } } IDrawing drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = drawing.CreateAnchor(0, 0, 0, 0, 0, 5, 10, 15); IChart chart = drawing.CreateChart(anchor); IChartLegend legend = chart.GetOrCreateLegend(); legend.Position = LegendPosition.TopRight; ILineChartData <double, double> data = chart.GetChartDataFactory().CreateLineChartData <double, double>(); // Use a category axis for the bottom axis. IChartAxis bottomAxis = chart.GetChartAxisFactory().CreateCategoryAxis(AxisPosition.Bottom); IValueAxis leftAxis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.Left); leftAxis.SetCrosses(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.AddSerie(xs, ys1); s1.SetTitle("title1"); var s2 = data.AddSerie(xs, ys2); s2.SetTitle("title2"); chart.Plot(data, bottomAxis, leftAxis); using (FileStream fs = File.Create("test.xlsx")) { wb.Write(fs); } }
public TestXSSFChartAxis() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = wb.CreateSheet(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); axis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.Bottom); }
/// <summary> /// Shift this item by given count. /// Recalculates <see cref="Index"/> and <see cref="XValue"/>. /// </summary> /// <param name="count">Shift count.</param> /// <param name="ice">Evaluator to use. MAY be NULL to skip <see cref="XValue"/> update.</param> /// <param name="axis">Axis to map category-axis value.</param> /// <param name="callback">Post-update callback. MAY be null.</param> public void Shift(int count, ICategoryEvaluator ice, IChartAxis axis, Action <ItemStateCore> callback) { Index = Index + count; if (ice != null) { // if using INDEX, the XValue "moves" along with this item, otherwise NOT var xv = ice.CategoryValue(XValue, Index); XValue = axis.For(xv); } callback?.Invoke(this); }
/// <summary> /// Create a final (MP) matrix for NDC in X axis, and axis.Range in Y-axis. /// Y-axis is inverted (for Q4). /// All components are pre-multiplied instead of using <see cref="MatrixSupport.Multiply"/>. /// </summary> /// <param name="area">Target area.</param> /// <param name="yaxis">The y-axis.</param> /// <returns>New matrix.</returns> public static Matrix TransformFor(Rect area, IChartAxis yaxis) { if (yaxis == null) { throw new ArgumentNullException(nameof(yaxis)); } var scaley = area.Height / yaxis.Range; var matx = new Matrix(area.Width, 0, 0, -scaley, area.Left, area.Top + yaxis.Maximum * scaley); return(matx); }
public void GenaretionChart() { FileStream RfileStream = new FileStream("D:\\test.xlsx", FileMode.Open, FileAccess.Read); //建立讀取資料的FileStream XSSFWorkbook wb = new XSSFWorkbook(RfileStream); //讀取檔案內的Workbook物件 ISheet Wsheet = wb.GetSheetAt(1); //選擇圖表存放的sheet ISheet Rsheet = wb.GetSheetAt(0); //選擇資料來源的sheet IDrawing drawing = Wsheet.CreateDrawingPatriarch(); //sheet產生drawing物件 IClientAnchor clientAnchor = drawing.CreateAnchor(0, 0, 0, 0, 0, 0, 5, 10); //設定圖表位置 IChart chart = drawing.CreateChart(clientAnchor); //產生chart物件 IChartLegend legend = chart.GetOrCreateLegend(); //還沒研究出這行在做甚麼 legend.Position = LegendPosition.TopRight; ILineChartData <double, double> data = chart.ChartDataFactory.CreateLineChartData <double, double>(); //產生存放資料的物件(資料型態為double) IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom); //設定X軸 IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); //設定Y軸 bottomAxis.Crosses = AxisCrosses.AutoZero; //設定X軸數值開始為0 leftAxis.Crosses = AxisCrosses.AutoZero; //設定Y軸數值開始為0 IChartDataSource <double> xs = DataSources.FromNumericCellRange(Rsheet, new CellRangeAddress(0, 4, 0, 0)); //取得要讀取sheet的資料位置(CellRangeAddress(first_row,end_row, first_column, end_column)) //x軸資料 IChartDataSource <double> ys1 = DataSources.FromNumericCellRange(Rsheet, new CellRangeAddress(0, 4, 1, 1)); //第一條y軸資料 IChartDataSource <double> ys2 = DataSources.FromNumericCellRange(Rsheet, new CellRangeAddress(0, 4, 2, 2)); //第二條y軸資料 data.AddSeries(xs, ys1); data.AddSeries(xs, ys2); //加入到data chart.Plot(data, bottomAxis, leftAxis); //加入到chart FileStream WfileStream = new FileStream("D:\\test.xlsx", FileMode.Create, FileAccess.Write); //建立寫入資料的FileStream wb.Write(WfileStream); //將workbook寫入資料 RfileStream.Close(); //關閉FileStream WfileStream.Close(); //關閉FileStream }
private void ChartAxisAssert(IChartAxis chartAxis, string fontName, float fontSize) { if (chartAxis?.TextProperties != null) { TextFrameAssert(chartAxis.TextProperties, fontName, fontSize); } if (chartAxis?.Title?.TextProperties != null) { TextFrameAssert(chartAxis.Title.TextProperties, fontName, fontSize); } }
/// <summary> /// Create a final (MP) matrix for this rectangle and axes. /// Renders for Q1. /// </summary> /// <param name="area">Target area.</param> /// <param name="xaxis">The x-axis.</param> /// <param name="yaxis">The y-axis.</param> /// <returns></returns> public static Matrix TransformFor(Rect area, IChartAxis xaxis, IChartAxis yaxis) { if (xaxis == null) { throw new ArgumentNullException(nameof(xaxis)); } if (yaxis == null) { throw new ArgumentNullException(nameof(yaxis)); } return(Multiply(ModelFor(xaxis, yaxis), ProjectForQuadrant(1, area))); }
public IValueAxis CreateValueAxis(AxisPosition pos) { XSSFValueAxis xssfValueAxis = new XSSFValueAxis(this, (long)(this.axis.Count + 1), pos); if (this.axis.Count == 1) { IChartAxis axi = this.axis[0]; axi.CrossAxis((IChartAxis)xssfValueAxis); xssfValueAxis.CrossAxis(axi); } this.axis.Add((IChartAxis)xssfValueAxis); return((IValueAxis)xssfValueAxis); }
public IValueAxis CreateValueAxis(AxisPosition pos) { long id = axis.Count + 1; XSSFValueAxis valueAxis = new XSSFValueAxis(this, id, pos); if (axis.Count == 1) { IChartAxis ax = axis[0]; ax.CrossAxis(valueAxis); valueAxis.CrossAxis(ax); } axis.Add(valueAxis); return(valueAxis); }
public IChartAxis CreateCategoryAxis(AxisPosition pos) { long id = axis.Count + 1; XSSFCategoryAxis categoryAxis = new XSSFCategoryAxis(this, id, pos); if (axis.Count == 1) { IChartAxis ax = axis[0]; ax.CrossAxis(categoryAxis); categoryAxis.CrossAxis(ax); } axis.Add(categoryAxis); return(categoryAxis); }
public IChartAxis CreateDateAxis(AxisPosition pos) { long id = axis.Count + 1; XSSFDateAxis dateAxis = new XSSFDateAxis(this, id, pos); if (axis.Count == 1) { IChartAxis ax = axis[0]; ax.CrossAxis(dateAxis); dateAxis.CrossAxis(ax); } axis.Add(dateAxis); return(dateAxis); }
private IWorkbook CreateWorkbookWithChart() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = wb.CreateSheet("linechart"); int NUM_OF_ROWS = 3; int NUM_OF_COLUMNS = 10; // Create a row and Put some cells in it. Rows are 0 based. IRow row; ICell cell; for (int rowIndex = 0; rowIndex < NUM_OF_ROWS; rowIndex++) { row = sheet.CreateRow((short)rowIndex); for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { cell = row.CreateCell((short)colIndex); cell.SetCellValue(colIndex * (rowIndex + 1)); } } IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 0, 5, 10, 15); IChart chart = Drawing.CreateChart(anchor); IChartLegend legend = chart.GetOrCreateLegend(); legend.Position = (/*setter*/ 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 = (/*setter*/ 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)); data.AddSeries(xs, ys1); data.AddSeries(xs, ys2); chart.Plot(data, bottomAxis, leftAxis); return(wb); }
/// <summary> /// <see cref="GeometryShim{G}"/> Offset version. Caller must account for the Matrix.OffsetX component there. /// <para/> /// Create a final (MP) matrix for this rectangle and axes. /// </summary> /// <param name="area">Target area. The Left component is eliminated from output matrix.</param> /// <param name="xaxis">The x-axis.</param> /// <param name="yaxis">The y-axis.</param> /// <returns></returns> public static Matrix TransformForOffsetX(Rect area, IChartAxis xaxis, IChartAxis yaxis) { if (xaxis == null) { throw new ArgumentNullException(nameof(xaxis)); } if (yaxis == null) { throw new ArgumentNullException(nameof(yaxis)); } var proj = ProjectForQuadrant(1, area); // remove the x-offset proj.OffsetX = 0; return(Multiply(ModelFor(xaxis, yaxis), proj)); }
/// <summary> /// Create the model (M) matrix for the given axis' extents. /// Uses axis Range and extent values. /// Model maps world coordinates to NDC. /// The basis vectors normalize the axis range. /// The translation components compensate for the axis "ends". Note these are also normalized. /// </summary> /// <param name="axis1">The x-axis.</param> /// <param name="axis2">The y-axis.</param> /// <returns>New matrix</returns> public static Matrix ModelFor(IChartAxis axis1, IChartAxis axis2) { if (axis1 == null) { throw new ArgumentNullException(nameof(axis1)); } if (axis2 == null) { throw new ArgumentNullException(nameof(axis2)); } var a1r = axis1.Range; var a2r = axis2.Range; var matx = new Matrix(1.0 / a1r, 0, 0, 1.0 / a2r, -axis1.Minimum / a1r, -axis2.Minimum / a2r); return(matx); }
static void CreateChart(ISheet sheet) { XSSFDrawing drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch(); XSSFClientAnchor anchor = (XSSFClientAnchor)drawing.CreateAnchor(0, 0, 0, 0, 3, 0, 10, 15); IChart chart = drawing.CreateChart(anchor); IChartLegend legend = chart.GetOrCreateLegend(); legend.Position = LegendPosition.Bottom; IBarChartData <string, double> data = chart.ChartDataFactory.CreateBarChartData <string, double>(); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom); bottomAxis.MajorTickMark = AxisTickMark.None; IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); leftAxis.Crosses = AxisCrosses.AutoZero; leftAxis.SetCrossBetween(AxisCrossBetween.Between); IChartDataSource <string> categories = DataSources.FromStringCellRange(sheet, new CellRangeAddress(0, GetPracas().Count() - 1, 0, 0)); // Abono IChartDataSource <double> xAbono = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(0, GetPracas().Count() - 1, 1, 1)); // Isento IChartDataSource <double> xIsento = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(0, GetPracas().Count() - 1, 2, 2)); // Violação IChartDataSource <double> xViolacao = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(0, GetPracas().Count() - 1, 3, 3)); var s1 = data.AddSeries(categories, xAbono); s1.SetTitle("Abono"); var s2 = data.AddSeries(categories, xIsento); s2.SetTitle("Isento"); var s3 = data.AddSeries(categories, xViolacao); s3.SetTitle("Violação"); chart.Plot(data, bottomAxis, leftAxis); }
/// <summary> /// Resolve axis references with error info. /// </summary> /// <param name="icrc">The context.</param> protected void EnsureAxes(IChartComponentContext icrc) { IChartErrorInfo icei = icrc as IChartErrorInfo; if (ValueAxis == null) { if (!String.IsNullOrEmpty(ValueAxisName)) { ValueAxis = icrc.Find(ValueAxisName) as IChartAxis; if (ValueAxis == null && icei != null) { icei.Report(new ChartValidationResult(NameOrType(), $"Value axis '{ValueAxisName}' was not found", new[] { nameof(ValueAxis), nameof(ValueAxisName) })); } } else { if (icei != null) { icei.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(ValueAxisName)}' was not set", new[] { nameof(ValueAxis), nameof(ValueAxisName) })); } } } if (CategoryAxis == null) { if (!String.IsNullOrEmpty(CategoryAxisName)) { CategoryAxis = icrc.Find(CategoryAxisName) as IChartAxis; if (CategoryAxis == null && icei != null) { icei.Report(new ChartValidationResult(NameOrType(), $"Value axis '{CategoryAxisName}' was not found", new[] { nameof(CategoryAxis), nameof(CategoryAxisName) })); } } else { if (icei != null) { icei.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(CategoryAxisName)}' was not set", new[] { nameof(CategoryAxis), nameof(CategoryAxisName) })); } } } }
public override void CrossAxis(IChartAxis axis) { ctValAx.crossAx.val = (uint)axis.GetId(); }
public override void CrossAxis(IChartAxis axis) { ctDateAx.crossAx.val = (uint)axis.Id; }
/// <summary> /// Ctor. /// </summary> /// <param name="ica"></param> /// <param name="rc"></param> /// <param name="labels"></param> public SelectorContext(IChartAxis ica, Rect rc, List <ICategoryLabelState> labels) { Axis = ica; Area = rc; AllLabels = labels; GeneratedLabels = new List <ICategoryLabelState>(); }
/// <summary> /// Create M and P for given bounds (Data area). /// </summary> /// <param name="a1">Axis 1.</param> /// <param name="a2">Axis 2.</param> /// <param name="area">Data area rectangle.</param> /// <param name="quad">Projection Quadrant [1..4].</param> /// <returns>Item1: M, Item2: P.</returns> public static Tuple <Matrix, Matrix> DataArea(IChartAxis a1, IChartAxis a2, Rect area, int quad = 1) { return(new Tuple <Matrix, Matrix>(ModelFor(a1.Minimum, a1.Maximum, a2.Minimum, a2.Maximum), ProjectForQuadrant(quad, area))); }
public override void CrossAxis(IChartAxis axis) { ctValAx.crossAx.val= (uint)axis.GetId(); }
public ChartAxisSerializerBase(IChartAxis axis) { this.axis = axis; }
public CartesianAxes(IChartAxis categoryAxis, IChartAxis valueAxis) { this.categoryAxis = categoryAxis; this.valueAxis = valueAxis; }
public ChartAxisSerializerBase(IChartAxis <TValue> axis) { this.axis = axis; }
static void CreateExcel(List <List <double> > inputArray, double axisCoordinateData) { string parth = $"D:\\test\\Result{axisCoordinateData.ToString()}.xlsx"; //XSSFWorkbook wb1 = null; using (var stream = new FileStream(parth, FileMode.Create, FileAccess.ReadWrite)) //using (var stream = new FileStream(@"D:\test\Result.xlsx", FileMode.Create, FileAccess.ReadWrite)) { //https://stackoverflow.com/questions/47793744/generate-excel-with-merged-header-using-npoi //https://stackoverflow.com/questions/32723483/adding-a-specific-autofilter-on-a-column //https://www.leniel.net/2009/10/npoi-with-excel-table-and-dynamic-chart.html //https://coderoad.ru/56089507/%D0%9A%D0%B0%D0%BA-%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D1%82%D1%8C-LineChart-%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B9-%D1%81%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B8%D1%82-%D0%B4%D0%B2%D0%B0-CategoryAxis-%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D1%83%D1%8F-apache-POI //https://www.csharpcodi.com/vs2/1431/NPOI/src/NPOI.OOXML/XSSF/UserModel/Charts/XSSFLineChartData.cs/ //https://itnan.ru/post.php?c=1&p=525492 //https://overcoder.net/q/3405494/%D0%BA%D0%B0%D0%BA-%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D1%82%D1%8C-%D0%BB%D0%B8%D0%BD%D0%B5%D0%B9%D0%BD%D1%83%D1%8E-%D0%B4%D0%B8%D0%B0%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83-%D0%B2%D0%BC%D0%B5%D1%81%D1%82%D0%B5-%D1%81-%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D0%BC%D0%B8-%D0%B2-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B5-excel-%D1%81-%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E //https://gist.github.com/Bykiev/2912494f5a3e4e6f91e02c12a6d6a82d //wb1 = new XSSFWorkbook(file); var wb = new XSSFWorkbook(); //var wb = new ; var sheet = wb.CreateSheet("Test wall"); //creating cell style for header var bStylehead = wb.CreateCellStyle(); bStylehead.BorderBottom = BorderStyle.Thin; bStylehead.BorderLeft = BorderStyle.Thin; bStylehead.BorderRight = BorderStyle.Thin; bStylehead.BorderTop = BorderStyle.Thin; bStylehead.Alignment = HorizontalAlignment.Center; bStylehead.VerticalAlignment = VerticalAlignment.Center; bStylehead.FillBackgroundColor = HSSFColor.Green.Index; //var cellStyle = //var cellStyle = CreateCellStyleForHeader(wb); var Drawing = sheet.CreateDrawingPatriarch(); //IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 8, 1, 18, 16); var anchor = Drawing.CreateAnchor(0, 0, 0, 0, 8, 1, 18, 16); var chart = Drawing.CreateChart(anchor); //var chart = //IChart chart = Drawing.CreateChart(anchor); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom); IChartAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); var chartData = chart.ChartDataFactory.CreateLineChartData <double, double>(); var lenCellRange = inputArray.Count + 1; IChartDataSource <double> xs = DataSources.FromNumericCellRange(sheet, CellRangeAddress.ValueOf($"B2:B{lenCellRange}")); IChartDataSource <double> ys = DataSources.FromNumericCellRange(sheet, CellRangeAddress.ValueOf($"G2:G{lenCellRange}")); //IChartDataSource<double> ys = DataSources.FromNumericCellRange(sheet, CellRangeAddress.ValueOf("G2:G20")); var series = chartData.AddSeries(xs, ys); series.SetTitle("test"); //chart.GetOrCreateLegend(); chart.Plot(chartData, bottomAxis, leftAxis); var row = sheet.CreateRow(0); row.CreateCell(0, CellType.String).SetCellValue("x"); row.CreateCell(1, CellType.String).SetCellValue("y"); row.CreateCell(2, CellType.String).SetCellValue("z"); row.CreateCell(3, CellType.String).SetCellValue("Hx"); row.CreateCell(4, CellType.String).SetCellValue("Hy"); row.CreateCell(5, CellType.String).SetCellValue("Hz"); row.CreateCell(6, CellType.String).SetCellValue("Hsum"); row.Cells[0].CellStyle = bStylehead; //filling the data var rowsCounter = 1; string fileName = @"C:\Users\Master\Documents\C_sharp\Work\wall_test.output"; var fileData = ReadFile(fileName); foreach (var rowData in inputArray) { var rowD = sheet.CreateRow(rowsCounter++); var dCounter = 0; foreach (var d in rowData) { rowD.CreateCell(dCounter++, CellType.Numeric).SetCellValue(Double.Parse(d.ToString().Replace(@".", @","))); } } wb.Write(stream); wb.Close(); //file.Close(); } }
public override void CrossAxis(IChartAxis axis) { ctCatAx.crossAx.val = (uint)axis.Id; }
public abstract void CrossAxis(IChartAxis axis);