ChartFormat

Inheritance: java.lang.Object

public class ChartFormat

Represents the formatting of a chart element.

To learn more, visit the Working with Charts documentation article.

Methods

MethodDescription
getDashStyle()
getEndArrowLength()
getEndArrowType()
getEndArrowWidth()
getEndCap()
getFill()Gets fill formatting for the parent chart element.
getFillType()
getFillableBackColor()
getFillableBackThemeColor()
getFillableBackTintAndShade()
getFillableBaseForeColor()
getFillableForeColor()
getFillableForeThemeColor()
getFillableForeTintAndShade()
getFillableImageBytes()
getFillableTransparency()
getFillableVisible()
getFilledColor()
getGradientAngle()
getGradientStops()
getGradientStyle()
getGradientVariant()
getJoinStyle()
getLineFillType()
getLineStyle()
getOldOn()
getOldOpacity()
getPatternType()
getPresetTexture()
getRotateWithObject()
getShapeType()Gets the shape type of the parent chart element.
getStartArrowLength()
getStartArrowType()
getStartArrowWidth()
getStroke()Gets line formatting for the parent chart element.
getStrokeBackThemeColor()
getStrokeBackTintAndShade()
getStrokeForeThemeColor()
getStrokeForeTintAndShade()
getStrokeImageBytes()
getStrokeTransparency()
getStrokeVisible()
getTextureAlignment()
getWeight()
isDefined()Gets a flag indicating whether any format is defined.
oneColorGradient(int style, int variant, double degree)
patterned(int patternType)
presetTextured(int presetTexture)
setDashStyle(int value)
setDefaultFill()Resets the fill of the chart element to have the default value.
setEndArrowLength(int value)
setEndArrowType(int value)
setEndArrowWidth(int value)
setEndCap(int value)
setFillableBackColor(Color value)
setFillableBackThemeColor(int value)
setFillableBackTintAndShade(double value)
setFillableForeColor(Color value)
setFillableForeThemeColor(int value)
setFillableForeTintAndShade(double value)
setFillableTransparency(double value)
setFillableVisible(boolean value)
setFilledColor(Color value)
setGradientAngle(double value)
setImage(byte[] imageBytes)
setJoinStyle(int value)
setLineFillType(int value)
setLineStyle(int value)
setOldOn(boolean value)
setOldOpacity(double value)
setRotateWithObject(boolean value)
setShapeType(int value)Sets the shape type of the parent chart element.
setStartArrowLength(int value)
setStartArrowType(int value)
setStartArrowWidth(int value)
setStrokeBackThemeColor(int value)
setStrokeBackTintAndShade(double value)
setStrokeForeThemeColor(int value)
setStrokeForeTintAndShade(double value)
setStrokeTransparency(double value)
setStrokeVisible(boolean value)
setTextureAlignment(int value)
setWeight(double value)
solid()
twoColorGradient(int style, int variant)

getDashStyle()

public int getDashStyle()

Returns: int

getEndArrowLength()

public int getEndArrowLength()

Returns: int

getEndArrowType()

public int getEndArrowType()

Returns: int

getEndArrowWidth()

public int getEndArrowWidth()

Returns: int

getEndCap()

public int getEndCap()

Returns: int

getFill()

public Fill getFill()

Gets fill formatting for the parent chart element.

Examples:

Show how to set marker formatting.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.SCATTER, 432.0, 252.0);
 Chart chart = shape.getChart();

 // Delete default generated series.
 chart.getSeries().clear();
 ChartSeries series = chart.getSeries().add("AW Series 1", new double[] { 0.7, 1.8, 2.6, 3.9 },
         new double[] { 2.7, 3.2, 0.8, 1.7 });

 // Set marker formatting.
 series.getMarker().setSize(40);
 series.getMarker().setSymbol(MarkerSymbol.SQUARE);
 ChartDataPointCollection dataPoints = series.getDataPoints();
 dataPoints.get(0).getMarker().getFormat().getFill().presetTextured(PresetTexture.DENIM);
 dataPoints.get(0).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(0).getMarker().getFormat().getStroke().setBackColor(Color.RED);
 dataPoints.get(1).getMarker().getFormat().getFill().presetTextured(PresetTexture.WATER_DROPLETS);
 dataPoints.get(1).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(1).getMarker().getFormat().getStroke().setVisible(false);
 dataPoints.get(2).getMarker().getFormat().getFill().presetTextured(PresetTexture.GREEN_MARBLE);
 dataPoints.get(2).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(3).getMarker().getFormat().getFill().presetTextured(PresetTexture.OAK);
 dataPoints.get(3).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(3).getMarker().getFormat().getStroke().setTransparency(0.5);

 doc.save(getArtifactsDir() + "Charts.MarkerFormatting.docx");
 

Returns: Fill - Fill formatting for the parent chart element.

getFillType()

public int getFillType()

Returns: int

getFillableBackColor()

public Color getFillableBackColor()

Returns: java.awt.Color

getFillableBackThemeColor()

public int getFillableBackThemeColor()

Returns: int

getFillableBackTintAndShade()

public double getFillableBackTintAndShade()

Returns: double

getFillableBaseForeColor()

public Color getFillableBaseForeColor()

Returns: java.awt.Color

getFillableForeColor()

public Color getFillableForeColor()

Returns: java.awt.Color

getFillableForeThemeColor()

public int getFillableForeThemeColor()

Returns: int

getFillableForeTintAndShade()

public double getFillableForeTintAndShade()

Returns: double

getFillableImageBytes()

public byte[] getFillableImageBytes()

Returns: byte[]

getFillableTransparency()

public double getFillableTransparency()

Returns: double

getFillableVisible()

public boolean getFillableVisible()

Returns: boolean

getFilledColor()

public Color getFilledColor()

Returns: java.awt.Color

getGradientAngle()

public double getGradientAngle()

Returns: double

getGradientStops()

public GradientStopCollection getGradientStops()

Returns: GradientStopCollection

getGradientStyle()

public int getGradientStyle()

Returns: int

getGradientVariant()

public int getGradientVariant()

Returns: int

getJoinStyle()

public int getJoinStyle()

Returns: int

getLineFillType()

public int getLineFillType()

Returns: int

getLineStyle()

public int getLineStyle()

Returns: int

getOldOn()

public boolean getOldOn()

Returns: boolean

getOldOpacity()

public double getOldOpacity()

Returns: double

getPatternType()

public int getPatternType()

Returns: int

getPresetTexture()

public int getPresetTexture()

Returns: int

getRotateWithObject()

public boolean getRotateWithObject()

Returns: boolean

getShapeType()

public int getShapeType()

Gets the shape type of the parent chart element.

Remarks:

Currently, the property can only be used for data labels.

Examples:

Shows how to set fill, stroke and callout formatting for chart data labels.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
 Chart chart = shape.getChart();

 // Delete default generated series.
 chart.getSeries().clear();

 // Add new series.
 ChartSeries series = chart.getSeries().add("AW Series 1",
         new String[] { "AW Category 1", "AW Category 2", "AW Category 3", "AW Category 4" },
         new double[] { 100.0, 200.0, 300.0, 400.0 });

 // Show data labels.
 series.hasDataLabels(true);
 series.getDataLabels().setShowValue(true);

 // Format data labels as callouts.
 ChartFormat format = series.getDataLabels().getFormat();
 format.setShapeType(ChartShapeType.WEDGE_RECT_CALLOUT);
 format.getStroke().setColor(Color.lightGray);
 format.getFill().solid(Color.GREEN);
 series.getDataLabels().getFont().setColor(Color.YELLOW);

 // Change fill and stroke of an individual data label.
 ChartFormat labelFormat = series.getDataLabels().get(0).getFormat();
 labelFormat.getStroke().setColor(Color.BLUE);
 labelFormat.getFill().solid(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.FormatDataLables.docx");
 

Returns: int - The shape type of the parent chart element. The returned value is one of ChartShapeType constants.

getStartArrowLength()

public int getStartArrowLength()

Returns: int

getStartArrowType()

public int getStartArrowType()

Returns: int

getStartArrowWidth()

public int getStartArrowWidth()

Returns: int

getStroke()

public Stroke getStroke()

Gets line formatting for the parent chart element.

Examples:

Show how to set marker formatting.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.SCATTER, 432.0, 252.0);
 Chart chart = shape.getChart();

 // Delete default generated series.
 chart.getSeries().clear();
 ChartSeries series = chart.getSeries().add("AW Series 1", new double[] { 0.7, 1.8, 2.6, 3.9 },
         new double[] { 2.7, 3.2, 0.8, 1.7 });

 // Set marker formatting.
 series.getMarker().setSize(40);
 series.getMarker().setSymbol(MarkerSymbol.SQUARE);
 ChartDataPointCollection dataPoints = series.getDataPoints();
 dataPoints.get(0).getMarker().getFormat().getFill().presetTextured(PresetTexture.DENIM);
 dataPoints.get(0).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(0).getMarker().getFormat().getStroke().setBackColor(Color.RED);
 dataPoints.get(1).getMarker().getFormat().getFill().presetTextured(PresetTexture.WATER_DROPLETS);
 dataPoints.get(1).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(1).getMarker().getFormat().getStroke().setVisible(false);
 dataPoints.get(2).getMarker().getFormat().getFill().presetTextured(PresetTexture.GREEN_MARBLE);
 dataPoints.get(2).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(3).getMarker().getFormat().getFill().presetTextured(PresetTexture.OAK);
 dataPoints.get(3).getMarker().getFormat().getStroke().setForeColor(Color.YELLOW);
 dataPoints.get(3).getMarker().getFormat().getStroke().setTransparency(0.5);

 doc.save(getArtifactsDir() + "Charts.MarkerFormatting.docx");
 

Returns: Stroke - Line formatting for the parent chart element.

getStrokeBackThemeColor()

public int getStrokeBackThemeColor()

Returns: int

getStrokeBackTintAndShade()

public double getStrokeBackTintAndShade()

Returns: double

getStrokeForeThemeColor()

public int getStrokeForeThemeColor()

Returns: int

getStrokeForeTintAndShade()

public double getStrokeForeTintAndShade()

Returns: double

getStrokeImageBytes()

public byte[] getStrokeImageBytes()

Returns: byte[]

getStrokeTransparency()

public double getStrokeTransparency()

Returns: double

getStrokeVisible()

public boolean getStrokeVisible()

Returns: boolean

getTextureAlignment()

public int getTextureAlignment()

Returns: int

getWeight()

public double getWeight()

Returns: double

isDefined()

public boolean isDefined()

Gets a flag indicating whether any format is defined.

Examples:

Shows how to reset the fill to the default value defined in the series.


 Document doc = new Document(getMyDir() + "DataPoint format.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 ChartSeries series = shape.getChart().getSeries().get(0);
 ChartDataPoint dataPoint = series.getDataPoints().get(1);

 Assert.assertTrue(dataPoint.getFormat().isDefined());

 dataPoint.getFormat().setDefaultFill();

 doc.save(getArtifactsDir() + "Charts.ResetDataPointFill.docx");
 

Returns: boolean - A flag indicating whether any format is defined.

oneColorGradient(int style, int variant, double degree)

public void oneColorGradient(int style, int variant, double degree)

Parameters:

ParameterTypeDescription
styleint
variantint
degreedouble

patterned(int patternType)

public void patterned(int patternType)

Parameters:

ParameterTypeDescription
patternTypeint

presetTextured(int presetTexture)

public void presetTextured(int presetTexture)

Parameters:

ParameterTypeDescription
presetTextureint

setDashStyle(int value)

public void setDashStyle(int value)

Parameters:

ParameterTypeDescription
valueint

setDefaultFill()

public void setDefaultFill()

Resets the fill of the chart element to have the default value.

Examples:

Shows how to reset the fill to the default value defined in the series.


 Document doc = new Document(getMyDir() + "DataPoint format.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 ChartSeries series = shape.getChart().getSeries().get(0);
 ChartDataPoint dataPoint = series.getDataPoints().get(1);

 Assert.assertTrue(dataPoint.getFormat().isDefined());

 dataPoint.getFormat().setDefaultFill();

 doc.save(getArtifactsDir() + "Charts.ResetDataPointFill.docx");
 

setEndArrowLength(int value)

public void setEndArrowLength(int value)

Parameters:

ParameterTypeDescription
valueint

setEndArrowType(int value)

public void setEndArrowType(int value)

Parameters:

ParameterTypeDescription
valueint

setEndArrowWidth(int value)

public void setEndArrowWidth(int value)

Parameters:

ParameterTypeDescription
valueint

setEndCap(int value)

public void setEndCap(int value)

Parameters:

ParameterTypeDescription
valueint

setFillableBackColor(Color value)

public void setFillableBackColor(Color value)

Parameters:

ParameterTypeDescription
valuejava.awt.Color

setFillableBackThemeColor(int value)

public void setFillableBackThemeColor(int value)

Parameters:

ParameterTypeDescription
valueint

setFillableBackTintAndShade(double value)

public void setFillableBackTintAndShade(double value)

Parameters:

ParameterTypeDescription
valuedouble

setFillableForeColor(Color value)

public void setFillableForeColor(Color value)

Parameters:

ParameterTypeDescription
valuejava.awt.Color

setFillableForeThemeColor(int value)

public void setFillableForeThemeColor(int value)

Parameters:

ParameterTypeDescription
valueint

setFillableForeTintAndShade(double value)

public void setFillableForeTintAndShade(double value)

Parameters:

ParameterTypeDescription
valuedouble

setFillableTransparency(double value)

public void setFillableTransparency(double value)

Parameters:

ParameterTypeDescription
valuedouble

setFillableVisible(boolean value)

public void setFillableVisible(boolean value)

Parameters:

ParameterTypeDescription
valueboolean

setFilledColor(Color value)

public void setFilledColor(Color value)

Parameters:

ParameterTypeDescription
valuejava.awt.Color

setGradientAngle(double value)

public void setGradientAngle(double value)

Parameters:

ParameterTypeDescription
valuedouble

setImage(byte[] imageBytes)

public void setImage(byte[] imageBytes)

Parameters:

ParameterTypeDescription
imageBytesbyte[]

setJoinStyle(int value)

public void setJoinStyle(int value)

Parameters:

ParameterTypeDescription
valueint

setLineFillType(int value)

public void setLineFillType(int value)

Parameters:

ParameterTypeDescription
valueint

setLineStyle(int value)

public void setLineStyle(int value)

Parameters:

ParameterTypeDescription
valueint

setOldOn(boolean value)

public void setOldOn(boolean value)

Parameters:

ParameterTypeDescription
valueboolean

setOldOpacity(double value)

public void setOldOpacity(double value)

Parameters:

ParameterTypeDescription
valuedouble

setRotateWithObject(boolean value)

public void setRotateWithObject(boolean value)

Parameters:

ParameterTypeDescription
valueboolean

setShapeType(int value)

public void setShapeType(int value)

Sets the shape type of the parent chart element.

Remarks:

Currently, the property can only be used for data labels.

Examples:

Shows how to set fill, stroke and callout formatting for chart data labels.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
 Chart chart = shape.getChart();

 // Delete default generated series.
 chart.getSeries().clear();

 // Add new series.
 ChartSeries series = chart.getSeries().add("AW Series 1",
         new String[] { "AW Category 1", "AW Category 2", "AW Category 3", "AW Category 4" },
         new double[] { 100.0, 200.0, 300.0, 400.0 });

 // Show data labels.
 series.hasDataLabels(true);
 series.getDataLabels().setShowValue(true);

 // Format data labels as callouts.
 ChartFormat format = series.getDataLabels().getFormat();
 format.setShapeType(ChartShapeType.WEDGE_RECT_CALLOUT);
 format.getStroke().setColor(Color.lightGray);
 format.getFill().solid(Color.GREEN);
 series.getDataLabels().getFont().setColor(Color.YELLOW);

 // Change fill and stroke of an individual data label.
 ChartFormat labelFormat = series.getDataLabels().get(0).getFormat();
 labelFormat.getStroke().setColor(Color.BLUE);
 labelFormat.getFill().solid(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.FormatDataLables.docx");
 

Parameters:

ParameterTypeDescription
valueintThe shape type of the parent chart element. The value must be one of ChartShapeType constants.

setStartArrowLength(int value)

public void setStartArrowLength(int value)

Parameters:

ParameterTypeDescription
valueint

setStartArrowType(int value)

public void setStartArrowType(int value)

Parameters:

ParameterTypeDescription
valueint

setStartArrowWidth(int value)

public void setStartArrowWidth(int value)

Parameters:

ParameterTypeDescription
valueint

setStrokeBackThemeColor(int value)

public void setStrokeBackThemeColor(int value)

Parameters:

ParameterTypeDescription
valueint

setStrokeBackTintAndShade(double value)

public void setStrokeBackTintAndShade(double value)

Parameters:

ParameterTypeDescription
valuedouble

setStrokeForeThemeColor(int value)

public void setStrokeForeThemeColor(int value)

Parameters:

ParameterTypeDescription
valueint

setStrokeForeTintAndShade(double value)

public void setStrokeForeTintAndShade(double value)

Parameters:

ParameterTypeDescription
valuedouble

setStrokeTransparency(double value)

public void setStrokeTransparency(double value)

Parameters:

ParameterTypeDescription
valuedouble

setStrokeVisible(boolean value)

public void setStrokeVisible(boolean value)

Parameters:

ParameterTypeDescription
valueboolean

setTextureAlignment(int value)

public void setTextureAlignment(int value)

Parameters:

ParameterTypeDescription
valueint

setWeight(double value)

public void setWeight(double value)

Parameters:

ParameterTypeDescription
valuedouble

solid()

public void solid()

twoColorGradient(int style, int variant)

public void twoColorGradient(int style, int variant)

Parameters:

ParameterTypeDescription
styleint
variantint