ChartNumberFormatFormatCode Property

Gets or sets the format code applied to a data label.

Namespace:  Aspose.Words.Drawing.Charts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string FormatCode { get; set; }

Property Value

Type: String
Remarks
Number formatting is used to change the way a value appears in data label and can be used in some very creative ways. The examples of number formats:

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"

Examples
Shows how to set formatting for chart values.
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);
Examples
Shows how to set number format for the data labels of the entire series.
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");
See Also