public void DataArraysWrongSize() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Add chart with default data. Shape shape = builder.InsertChart(ChartType.Line, 432, 252); Chart chart = shape.Chart; ChartSeriesCollection seriesColl = chart.Series; seriesColl.Clear(); // Create category names array, second category will be null. string[] categories = { "Cat1", null, "Cat3", "Cat4", "Cat5", null }; // Adding new series with empty (double.NaN) values. seriesColl.Add("AW Series 1", categories, new double[] { 1, 2, double.NaN, 4, 5, 6 }); seriesColl.Add("AW Series 2", categories, new double[] { 2, 3, double.NaN, 5, 6, 7 }); Assert.That( () => seriesColl.Add("AW Series 3", categories, new[] { double.NaN, 4, 5, double.NaN, double.NaN }), Throws.TypeOf <ArgumentException>()); Assert.That( () => seriesColl.Add("AW Series 4", categories, new[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN }), Throws.TypeOf <ArgumentException>()); }
public void EmptyValuesInChartData() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Add chart with default data. Shape shape = builder.InsertChart(ChartType.Line, 432, 252); Chart chart = shape.Chart; ChartSeriesCollection seriesColl = chart.Series; seriesColl.Clear(); // Create category names array, second category will be null. string[] categories = { "Cat1", null, "Cat3", "Cat4", "Cat5", null }; // Adding new series with empty (double.NaN) values. seriesColl.Add("AW Series 1", categories, new[] { 1, 2, double.NaN, 4, 5, 6 }); seriesColl.Add("AW Series 2", categories, new[] { 2, 3, double.NaN, 5, 6, 7 }); seriesColl.Add("AW Series 3", categories, new[] { double.NaN, 4, 5, double.NaN, 7, 8 }); seriesColl.Add("AW Series 4", categories, new[] { double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, 9 }); doc.Save(ArtifactsDir + "Charts.EmptyValuesInChartData.docx"); }
public void InsertSimpleColumnChart() { //ExStart:InsertSimpleColumnChart Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // You can specify different chart types and sizes. Shape shape = builder.InsertChart(ChartType.Column, 432, 252); Chart chart = shape.Chart; //ExStart:ChartSeriesCollection ChartSeriesCollection seriesColl = chart.Series; Console.WriteLine(seriesColl.Count); //ExEnd:ChartSeriesCollection // Delete default generated series. seriesColl.Clear(); // Create category names array, in this example we have two categories. string[] categories = new string[] { "Category 1", "Category 2" }; // Please note, data arrays must not be empty and arrays must be the same size. seriesColl.Add("Aspose Series 1", categories, new double[] { 1, 2 }); seriesColl.Add("Aspose Series 2", categories, new double[] { 3, 4 }); seriesColl.Add("Aspose Series 3", categories, new double[] { 5, 6 }); seriesColl.Add("Aspose Series 4", categories, new double[] { 7, 8 }); seriesColl.Add("Aspose Series 5", categories, new double[] { 9, 10 }); doc.Save(ArtifactsDir + "WorkingWithCharts.InsertSimpleColumnChart.docx"); //ExEnd:InsertSimpleColumnChart }
/// <summary> /// 插入图表 /// </summary> static void InsertChart() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Add chart with default data. You can specify different chart types and sizes. Shape shape = builder.InsertChart(ChartType.Line, 432, 252); // Chart property of Shape contains all chart related options. Chart chart = shape.Chart; // Get chart series collection. ChartSeriesCollection seriesColl = chart.Series; // Delete default generated series. seriesColl.Clear(); // Create category names array, in this example we have two categories. string[] categories = new string[] { "AW Category 1", "AW Category 1" }; // Adding new series. Please note, data arrays must not be empty and arrays must be the same size. seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 }); seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 }); seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 }); seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 }); seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 }); doc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestInsertChartColumn.docx")); }
public ViewModel() { Data = new ObservableCollection <Model>(); Series = new ChartSeriesCollection(); var random = new Random(); for (var i = 0; i < 200; i++) { Data.Add(new Model { XValue = Date, YValue = random.Next(1, 69) }); Date = Date.AddMinutes(13); } foreach (var batch in Data.Batch(100)) { Series.Add(new FastLineSeries { ItemsSource = batch, XBindingPath = "XValue", YBindingPath = "YValue", Color = GetRandomColor() }); } }
/// <summary> /// Shows how to insert a simple column chart into the document using DocumentBuilder.InsertChart method. /// </summary> private static void InsertSimpleColumnChart(string dataDir) { // ExStart:InsertSimpleColumnChart Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Add chart with default data. You can specify different chart types and sizes. Shape shape = builder.InsertChart(ChartType.Column, 432, 252); // Chart property of Shape contains all chart related options. Chart chart = shape.Chart; // ExStart:ChartSeriesCollection // Get chart series collection. ChartSeriesCollection seriesColl = chart.Series; // Check series count. Console.WriteLine(seriesColl.Count); // ExEnd:ChartSeriesCollection // Delete default generated series. seriesColl.Clear(); // Create category names array, in this example we have two categories. string[] categories = new string[] { "AW Category 1", "AW Category 2" }; // Adding new series. Please note, data arrays must not be empty and arrays must be the same size. seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 }); seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 }); seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 }); seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 }); seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 }); dataDir = dataDir + @"TestInsertSimpleChartColumn_out.doc"; doc.Save(dataDir); // ExEnd:InsertSimpleColumnChart Console.WriteLine("\nSimple column chart created successfully.\nFile saved at " + dataDir); }