ChartNumberFormatFormatCode Property |
Namespace: Aspose.Words.Drawing.Charts
Number - "#,##0.00"
Currency - "\"$\"#,##0.00"
Time - "[$-x-systime]h:mm:ss AM/PM"
Date - "d/mm/yyyy"
Percentage - "0.00%"
Fraction - "# ?/?"
Scientific - "0.00E+00"
Text - "@"
Accounting - "_-\"$\"* #,##0.00_-;-\"$\"* #,##0.00_-;_-\"$\"* \"-\"??_-;_-@_-"
Custom with color - "[Red]-#,##0.0"
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert chart Shape shape = builder.InsertChart(ChartType.Column, 432, 252); Chart chart = shape.Chart; // Clear demo data chart.Series.Clear(); chart.Series.Add("Aspose Test Series", new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Note" }, new double[] { 1900000, 850000, 2100000, 600000, 1500000 }); // Set number format chart.AxisY.NumberFormat.FormatCode = "#,##0"; // Set this to override the above value and draw the number format from the source cell Assert.False(chart.AxisY.NumberFormat.IsLinkedToSource);
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Add chart with default data Shape shape = builder.InsertChart(ChartType.Line, 432, 252); // Delete default generated series shape.Chart.Series.Clear(); ChartSeries series = shape.Chart.Series.Add("Aspose Test Series", new[] { "Word", "PDF", "Excel" }, new[] { 2.5, 1.5, 3.5 }); ChartDataLabelCollection dataLabels = series.DataLabels; // Display chart values in the data labels, by default it is false dataLabels.ShowValue = true; // Set currency format for the data labels of the entire series dataLabels.NumberFormat.FormatCode = "\"$\"#,##0.00"; doc.Save(ArtifactsDir + "Charts.DefineNumberFormatForDataLabels.docx");