Aspose::Words::Drawing::Charts::ChartYValueCollection::get_FormatCode method
Contents
[
Hide
]ChartYValueCollection::get_FormatCode method
Gets or sets the format code applied to the Y values.
System::String Aspose::Words::Drawing::Charts::ChartYValueCollection::get_FormatCode()
Remarks
Number formatting is used to change the way values appears in the chart. 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”
Accounting - “-"$\”* #,##0.00-;-"$\"* #,##0.00_-;-"$\"* "-\"??-;-@-"
Custom with color - “[Red]-#,##0.0”
Examples
Shows how to work with the format code of the chart data.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Insert a Bubble chart.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertChart(Aspose::Words::Drawing::Charts::ChartType::Bubble, 432, 252);
System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> chart = shape->get_Chart();
// Delete default generated series.
chart->get_Series()->Clear();
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> series = chart->get_Series()->Add(u"Series1", System::MakeArray<double>({1, 1.9, 2.45, 3}), System::MakeArray<double>({1, -0.9, 1.82, 0}), System::MakeArray<double>({2, 1.1, 2.95, 2}));
// Show data labels.
series->set_HasDataLabels(true);
series->get_DataLabels()->set_ShowCategoryName(true);
series->get_DataLabels()->set_ShowValue(true);
series->get_DataLabels()->set_ShowBubbleSize(true);
// Set data format codes.
series->get_XValues()->set_FormatCode(u"#,##0.0#");
series->get_YValues()->set_FormatCode(u"#,##0.0#;[Red]\\-#,##0.0#");
series->get_BubbleSizes()->set_FormatCode(u"#,##0.0#");
doc->Save(get_ArtifactsDir() + u"Charts.FormatCode.docx");
See Also
- Class ChartYValueCollection
- Namespace Aspose::Words::Drawing::Charts
- Library Aspose.Words for C++