Aspose::Words::Drawing::Charts::ChartDataPoint Class Reference

Detailed Description

Allows to specify formatting of a single data point on the chart.

Examples

Shows how to work with data points on a line chart.

void ChartDataPoint_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(3, chart->get_Series()->get_Count());
ASSERT_EQ(u"Series 1", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_EQ(u"Series 2", chart->get_Series()->idx_get(1)->get_Name());
ASSERT_EQ(u"Series 3", chart->get_Series()->idx_get(2)->get_Name());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (const auto& series : System::IterateOver(chart->get_Series()))
{
ApplyDataPoints(series, 4, MarkerSymbol::Diamond, 15);
}
// Smooth out the line that represents the first data series.
chart->get_Series()->idx_get(0)->set_Smooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartDataPoint>>> enumerator =
chart->get_Series()->idx_get(0)->get_DataPoints()->GetEnumerator();
while (enumerator->MoveNext())
{
ASSERT_FALSE(enumerator->get_Current()->get_InvertIfNegative());
}
}
// For a cleaner looking graph, we can clear format individually.
chart->get_Series()->idx_get(1)->get_DataPoints()->idx_get(2)->ClearFormat();
// We can also strip an entire series of data points at once.
chart->get_Series()->idx_get(2)->get_DataPoints()->ClearFormat();
doc->Save(ArtifactsDir + u"Charts.ChartDataPoint.docx");
}
static void ApplyDataPoints(SharedPtr<ChartSeries> series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
{
for (int i = 0; i < dataPointsCount; i++)
{
SharedPtr<ChartDataPoint> point = series->get_DataPoints()->idx_get(i);
point->get_Marker()->set_Symbol(markerSymbol);
point->get_Marker()->set_Size(dataPointSize);
ASSERT_EQ(i, point->get_Index());
}
}

#include <Aspose.Words.Cpp/Drawing/Charts/ChartDataPoint.h>

+ Inheritance diagram for Aspose::Words::Drawing::Charts::ChartDataPoint:

Public Member Functions

void ClearFormat ()
 Clears format of this data point. The properties are set to the default values defined in the parent series. More...
 
bool get_Bubble3D () override
 Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them. More...
 
int32_t get_Explosion () override
 Specifies the amount the data point shall be moved from the center of the pie. Can be negative, negative means that property is not set and no explosion should be applied. Applies only to Pie charts. More...
 
SharedPtr< ChartFormatget_Format ()
 Provides access to fill and line formatting of this data point. More...
 
int32_t get_Index ()
 Index of the data point this object applies formatting to. More...
 
bool get_InvertIfNegative () override
 Specifies whether the parent element shall inverts its colors if the value is negative. More...
 
SharedPtr< ChartMarkerget_Marker () override
 Specifies a data marker. Marker is automatically created when requested. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Bubble3D (bool value) override
 Setter for get_Bubble3D. More...
 
void set_Explosion (int32_t value) override
 Setter for get_Explosion. More...
 
void set_InvertIfNegative (bool value) override
 Setter for get_InvertIfNegative. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ ClearFormat()

void Aspose::Words::Drawing::Charts::ChartDataPoint::ClearFormat ( )

Clears format of this data point. The properties are set to the default values defined in the parent series.

◆ get_Bubble3D()

bool Aspose::Words::Drawing::Charts::ChartDataPoint::get_Bubble3D ( )
overridevirtual

Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.

Examples

Shows how to use 3D effects with bubble charts.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Bubble3D, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(1, chart->get_Series()->get_Count());
ASSERT_EQ(u"Y-Values", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_TRUE(chart->get_Series()->idx_get(0)->get_Bubble3D());
// Apply a data label to each bubble that displays its diameter.
for (int i = 0; i < 3; i++)
{
chart->get_Series()->idx_get(0)->set_HasDataLabels(true);
chart->get_Series()->idx_get(0)->get_DataLabels()->idx_get(i)->set_ShowBubbleSize(true);
}
doc->Save(ArtifactsDir + u"Charts.Bubble3D.docx");

Implements Aspose::Words::Drawing::Charts::IChartDataPoint.

◆ get_Explosion()

int32_t Aspose::Words::Drawing::Charts::ChartDataPoint::get_Explosion ( )
overridevirtual

Specifies the amount the data point shall be moved from the center of the pie. Can be negative, negative means that property is not set and no explosion should be applied. Applies only to Pie charts.

Examples

Shows how to move the slices of a pie chart away from the center.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Pie, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(1, chart->get_Series()->get_Count());
ASSERT_EQ(u"Sales", chart->get_Series()->idx_get(0)->get_Name());
// "Slices" of a pie chart may be moved away from the center by a distance via the respective data point's Explosion attribute.
// Add a data point to the first portion of the pie chart and move it away from the center by 10 points.
// Aspose.Words create data points automatically if them does not exist.
SharedPtr<ChartDataPoint> dataPoint = chart->get_Series()->idx_get(0)->get_DataPoints()->idx_get(0);
dataPoint->set_Explosion(10);
// Displace the second portion by a greater distance.
dataPoint = chart->get_Series()->idx_get(0)->get_DataPoints()->idx_get(1);
dataPoint->set_Explosion(40);
doc->Save(ArtifactsDir + u"Charts.PieChartExplosion.docx");

Implements Aspose::Words::Drawing::Charts::IChartDataPoint.

◆ get_Format()

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartFormat> Aspose::Words::Drawing::Charts::ChartDataPoint::get_Format ( )

Provides access to fill and line formatting of this data point.

Examples

Shows how to set individual formatting for categories of a column chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Column, 432, 252);
SharedPtr<Chart> chart = shape->get_Chart();
// Delete default generated series.
chart->get_Series()->Clear();
// Adding new series.
SharedPtr<ChartSeries> series = chart->get_Series()->Add(u"Series 1", MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"}),
MakeArray<double>({1, 2, 3, 4}));
// Set column formatting.
SharedPtr<ChartDataPointCollection> dataPoints = series->get_DataPoints();
dataPoints->idx_get(0)->get_Format()->get_Fill()->PresetTextured(PresetTexture::Denim);
dataPoints->idx_get(1)->get_Format()->get_Fill()->set_ForeColor(System::Drawing::Color::get_Red());
dataPoints->idx_get(2)->get_Format()->get_Fill()->set_ForeColor(System::Drawing::Color::get_Yellow());
dataPoints->idx_get(3)->get_Format()->get_Fill()->set_ForeColor(System::Drawing::Color::get_Blue());
doc->Save(ArtifactsDir + u"Charts.DataPointsFormatting.docx");

◆ get_Index()

int32_t Aspose::Words::Drawing::Charts::ChartDataPoint::get_Index ( )

Index of the data point this object applies formatting to.

Examples

Shows how to work with data points on a line chart.

void ChartDataPoint_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(3, chart->get_Series()->get_Count());
ASSERT_EQ(u"Series 1", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_EQ(u"Series 2", chart->get_Series()->idx_get(1)->get_Name());
ASSERT_EQ(u"Series 3", chart->get_Series()->idx_get(2)->get_Name());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (const auto& series : System::IterateOver(chart->get_Series()))
{
ApplyDataPoints(series, 4, MarkerSymbol::Diamond, 15);
}
// Smooth out the line that represents the first data series.
chart->get_Series()->idx_get(0)->set_Smooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartDataPoint>>> enumerator =
chart->get_Series()->idx_get(0)->get_DataPoints()->GetEnumerator();
while (enumerator->MoveNext())
{
ASSERT_FALSE(enumerator->get_Current()->get_InvertIfNegative());
}
}
// For a cleaner looking graph, we can clear format individually.
chart->get_Series()->idx_get(1)->get_DataPoints()->idx_get(2)->ClearFormat();
// We can also strip an entire series of data points at once.
chart->get_Series()->idx_get(2)->get_DataPoints()->ClearFormat();
doc->Save(ArtifactsDir + u"Charts.ChartDataPoint.docx");
}
static void ApplyDataPoints(SharedPtr<ChartSeries> series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
{
for (int i = 0; i < dataPointsCount; i++)
{
SharedPtr<ChartDataPoint> point = series->get_DataPoints()->idx_get(i);
point->get_Marker()->set_Symbol(markerSymbol);
point->get_Marker()->set_Size(dataPointSize);
ASSERT_EQ(i, point->get_Index());
}
}

◆ get_InvertIfNegative()

bool Aspose::Words::Drawing::Charts::ChartDataPoint::get_InvertIfNegative ( )
overridevirtual

Specifies whether the parent element shall inverts its colors if the value is negative.

Examples

Shows how to work with data points on a line chart.

void ChartDataPoint_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(3, chart->get_Series()->get_Count());
ASSERT_EQ(u"Series 1", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_EQ(u"Series 2", chart->get_Series()->idx_get(1)->get_Name());
ASSERT_EQ(u"Series 3", chart->get_Series()->idx_get(2)->get_Name());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (const auto& series : System::IterateOver(chart->get_Series()))
{
ApplyDataPoints(series, 4, MarkerSymbol::Diamond, 15);
}
// Smooth out the line that represents the first data series.
chart->get_Series()->idx_get(0)->set_Smooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartDataPoint>>> enumerator =
chart->get_Series()->idx_get(0)->get_DataPoints()->GetEnumerator();
while (enumerator->MoveNext())
{
ASSERT_FALSE(enumerator->get_Current()->get_InvertIfNegative());
}
}
// For a cleaner looking graph, we can clear format individually.
chart->get_Series()->idx_get(1)->get_DataPoints()->idx_get(2)->ClearFormat();
// We can also strip an entire series of data points at once.
chart->get_Series()->idx_get(2)->get_DataPoints()->ClearFormat();
doc->Save(ArtifactsDir + u"Charts.ChartDataPoint.docx");
}
static void ApplyDataPoints(SharedPtr<ChartSeries> series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
{
for (int i = 0; i < dataPointsCount; i++)
{
SharedPtr<ChartDataPoint> point = series->get_DataPoints()->idx_get(i);
point->get_Marker()->set_Symbol(markerSymbol);
point->get_Marker()->set_Size(dataPointSize);
ASSERT_EQ(i, point->get_Index());
}
}

Implements Aspose::Words::Drawing::Charts::IChartDataPoint.

◆ get_Marker()

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartMarker> Aspose::Words::Drawing::Charts::ChartDataPoint::get_Marker ( )
overridevirtual

Specifies a data marker. Marker is automatically created when requested.

Examples

Shows how to work with data points on a line chart.

void ChartDataPoint_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 500, 350);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(3, chart->get_Series()->get_Count());
ASSERT_EQ(u"Series 1", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_EQ(u"Series 2", chart->get_Series()->idx_get(1)->get_Name());
ASSERT_EQ(u"Series 3", chart->get_Series()->idx_get(2)->get_Name());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (const auto& series : System::IterateOver(chart->get_Series()))
{
ApplyDataPoints(series, 4, MarkerSymbol::Diamond, 15);
}
// Smooth out the line that represents the first data series.
chart->get_Series()->idx_get(0)->set_Smooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartDataPoint>>> enumerator =
chart->get_Series()->idx_get(0)->get_DataPoints()->GetEnumerator();
while (enumerator->MoveNext())
{
ASSERT_FALSE(enumerator->get_Current()->get_InvertIfNegative());
}
}
// For a cleaner looking graph, we can clear format individually.
chart->get_Series()->idx_get(1)->get_DataPoints()->idx_get(2)->ClearFormat();
// We can also strip an entire series of data points at once.
chart->get_Series()->idx_get(2)->get_DataPoints()->ClearFormat();
doc->Save(ArtifactsDir + u"Charts.ChartDataPoint.docx");
}
static void ApplyDataPoints(SharedPtr<ChartSeries> series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
{
for (int i = 0; i < dataPointsCount; i++)
{
SharedPtr<ChartDataPoint> point = series->get_DataPoints()->idx_get(i);
point->get_Marker()->set_Symbol(markerSymbol);
point->get_Marker()->set_Size(dataPointSize);
ASSERT_EQ(i, point->get_Index());
}
}

Implements Aspose::Words::Drawing::Charts::IChartDataPoint.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Drawing::Charts::ChartDataPoint::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Drawing::Charts::ChartDataPoint::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_Bubble3D()

void Aspose::Words::Drawing::Charts::ChartDataPoint::set_Bubble3D ( bool  value)
overridevirtual

◆ set_Explosion()

void Aspose::Words::Drawing::Charts::ChartDataPoint::set_Explosion ( int32_t  value)
overridevirtual

◆ set_InvertIfNegative()

void Aspose::Words::Drawing::Charts::ChartDataPoint::set_InvertIfNegative ( bool  value)
overridevirtual

◆ Type()

static const System::TypeInfo& Aspose::Words::Drawing::Charts::ChartDataPoint::Type ( )
static