public class ChartFormat
extends java.lang.Object
To learn more, visit the Working with Charts documentation article.
Examples:
Shows how to use chart formating.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Delete series generated by default.
ChartSeriesCollection series = chart.getSeries();
series.clear();
String[] categories = new String[] { "Category 1", "Category 2" };
series.add("Series 1", categories, new double[] { 1.0, 2.0 });
series.add("Series 2", categories, new double[] { 3.0, 4.0 });
// Format chart background.
chart.getFormat().getFill().solid(Color.darkGray);
// Hide axis tick labels.
chart.getAxisX().getTickLabels().setPosition(AxisTickLabelPosition.NONE);
chart.getAxisY().getTickLabels().setPosition(AxisTickLabelPosition.NONE);
// Format chart title.
chart.getTitle().getFormat().getFill().solid(Color.yellow);
// Format axis title.
chart.getAxisX().getTitle().setShow(true);
chart.getAxisX().getTitle().getFormat().getFill().solid(Color.yellow);
// Format legend.
chart.getLegend().getFormat().getFill().solid(Color.yellow);
doc.save(getArtifactsDir() + "Charts.ChartFormat.docx");
| Modifier and Type | Method and Description |
|---|---|
int |
getDashStyle() |
int |
getEndArrowLength() |
int |
getEndArrowType() |
int |
getEndArrowWidth() |
int |
getEndCap() |
Fill |
getFill()
Gets fill formatting for the parent chart element.
|
java.awt.Color |
getFillableBackColor() |
int |
getFillableBackThemeColor() |
double |
getFillableBackTintAndShade() |
java.awt.Color |
getFillableBaseForeColor() |
java.awt.Color |
getFillableForeColor() |
int |
getFillableForeThemeColor() |
double |
getFillableForeTintAndShade() |
byte[] |
getFillableImageBytes() |
double |
getFillableTransparency() |
boolean |
getFillableVisible() |
java.awt.Color |
getFilledColor() |
int |
getFillType() |
double |
getGradientAngle() |
GradientStopCollection |
getGradientStops() |
int |
getGradientStyle() |
int |
getGradientVariant() |
int |
getJoinStyle() |
int |
getLineFillType() |
int |
getLineStyle() |
boolean |
getOldOn() |
double |
getOldOpacity() |
int |
getPatternType() |
int |
getPresetTexture() |
boolean |
getRotateWithObject() |
int |
getShapeType()
Gets the shape type of the parent chart element.
|
int |
getStartArrowLength() |
int |
getStartArrowType() |
int |
getStartArrowWidth() |
Stroke |
getStroke()
Gets line formatting for the parent chart element.
|
int |
getStrokeBackThemeColor() |
double |
getStrokeBackTintAndShade() |
int |
getStrokeForeThemeColor() |
double |
getStrokeForeTintAndShade() |
byte[] |
getStrokeImageBytes() |
double |
getStrokeTransparency() |
boolean |
getStrokeVisible() |
int |
getTextureAlignment() |
double |
getWeight() |
boolean |
isDefined()
Gets a flag indicating whether any format is defined.
|
void |
oneColorGradient(int style,
int variant,
double degree) |
void |
patterned(int patternType) |
void |
presetTextured(int presetTexture) |
void |
setDashStyle(int value) |
void |
setDefaultFill()
Resets the fill of the chart element to have the default value.
|
void |
setEndArrowLength(int value) |
void |
setEndArrowType(int value) |
void |
setEndArrowWidth(int value) |
void |
setEndCap(int value) |
void |
setFillableBackColor(java.awt.Color value) |
void |
setFillableBackThemeColor(int value) |
void |
setFillableBackTintAndShade(double value) |
void |
setFillableForeColor(java.awt.Color value) |
void |
setFillableForeThemeColor(int value) |
void |
setFillableForeTintAndShade(double value) |
void |
setFillableTransparency(double value) |
void |
setFillableVisible(boolean value) |
void |
setFilledColor(java.awt.Color value) |
void |
setGradientAngle(double value) |
void |
setImage(byte[] imageBytes) |
void |
setJoinStyle(int value) |
void |
setLineFillType(int value) |
void |
setLineStyle(int value) |
void |
setOldOn(boolean value) |
void |
setOldOpacity(double value) |
void |
setRotateWithObject(boolean value) |
void |
setShapeType(int value)
Sets the shape type of the parent chart element.
|
void |
setStartArrowLength(int value) |
void |
setStartArrowType(int value) |
void |
setStartArrowWidth(int value) |
void |
setStrokeBackThemeColor(int value) |
void |
setStrokeBackTintAndShade(double value) |
void |
setStrokeForeThemeColor(int value) |
void |
setStrokeForeTintAndShade(double value) |
void |
setStrokeTransparency(double value) |
void |
setStrokeVisible(boolean value) |
void |
setTextureAlignment(int value) |
void |
setWeight(double value) |
void |
solid() |
void |
twoColorGradient(int style,
int variant) |
public void setDefaultFill()
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");
public void solid()
public void presetTextured(int presetTexture)
public void patterned(int patternType)
public int getPresetTexture()
throws java.lang.Exception
java.lang.Exceptionpublic int getPatternType()
public void oneColorGradient(int style,
int variant,
double degree)
public void twoColorGradient(int style,
int variant)
public void setImage(byte[] imageBytes)
public java.awt.Color getFilledColor()
public void setFilledColor(java.awt.Color value)
public boolean getOldOn()
public void setOldOn(boolean value)
public double getOldOpacity()
public void setOldOpacity(double value)
public byte[] getFillableImageBytes()
public java.awt.Color getFillableForeColor()
public void setFillableForeColor(java.awt.Color value)
public java.awt.Color getFillableBaseForeColor()
public java.awt.Color getFillableBackColor()
public void setFillableBackColor(java.awt.Color value)
public int getFillableForeThemeColor()
public void setFillableForeThemeColor(int value)
public int getFillableBackThemeColor()
public void setFillableBackThemeColor(int value)
public double getFillableForeTintAndShade()
public void setFillableForeTintAndShade(double value)
public double getFillableBackTintAndShade()
public void setFillableBackTintAndShade(double value)
public boolean getFillableVisible()
public void setFillableVisible(boolean value)
public double getFillableTransparency()
public void setFillableTransparency(double value)
public boolean getRotateWithObject()
public void setRotateWithObject(boolean value)
public int getFillType()
public int getTextureAlignment()
public void setTextureAlignment(int value)
public double getGradientAngle()
public void setGradientAngle(double value)
public int getGradientVariant()
public int getGradientStyle()
public GradientStopCollection getGradientStops()
public int getStrokeForeThemeColor()
public void setStrokeForeThemeColor(int value)
public int getStrokeBackThemeColor()
public void setStrokeBackThemeColor(int value)
public double getStrokeForeTintAndShade()
public void setStrokeForeTintAndShade(double value)
public double getStrokeBackTintAndShade()
public void setStrokeBackTintAndShade(double value)
public boolean getStrokeVisible()
public void setStrokeVisible(boolean value)
public double getStrokeTransparency()
public void setStrokeTransparency(double value)
public double getWeight()
public void setWeight(double value)
public int getDashStyle()
public void setDashStyle(int value)
public int getJoinStyle()
public void setJoinStyle(int value)
public int getEndCap()
public void setEndCap(int value)
public int getLineStyle()
public void setLineStyle(int value)
public int getStartArrowType()
public void setStartArrowType(int value)
public int getEndArrowType()
public void setEndArrowType(int value)
public int getStartArrowWidth()
public void setStartArrowWidth(int value)
public int getStartArrowLength()
public void setStartArrowLength(int value)
public int getEndArrowWidth()
public void setEndArrowWidth(int value)
public int getEndArrowLength()
public void setEndArrowLength(int value)
public int getLineFillType()
public void setLineFillType(int value)
public byte[] getStrokeImageBytes()
throws java.lang.Exception
java.lang.Exceptionpublic Fill getFill()
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");
public Stroke getStroke()
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");
public int getShapeType()
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");
ChartShapeType constants.public void setShapeType(int value)
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");
value - The shape type of the parent chart element. The value must be one of ChartShapeType constants.public boolean isDefined()
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");