public class ChartTitle
extends java.lang.Object
To learn more, visit the Working with Charts documentation article.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
| Modifier and Type | Method and Description |
|---|---|
Font |
getFont()
Provides access to the font formatting of the chart title.
|
ChartFormat |
getFormat()
Provides access to fill and line formatting of the chart title.
|
boolean |
getOverlay()
Determines whether other chart elements shall be allowed to overlap title.
|
boolean |
getShow()
Determines whether the title shall be shown for this chart.
|
java.lang.String |
getText()
Gets the text of the chart title.
|
void |
setOverlay(boolean value)
Determines whether other chart elements shall be allowed to overlap title.
|
void |
setShow(boolean value)
Determines whether the title shall be shown for this chart.
|
void |
setText(java.lang.String value)
Sets the text of the chart title.
|
public java.lang.String getText()
null or empty value is specified, auto generated title will be shown.
Remarks:
Use getShow() / setShow(boolean) option if you need to hide the Title.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
public void setText(java.lang.String value)
null or empty value is specified, auto generated title will be shown.
Remarks:
Use getShow() / setShow(boolean) option if you need to hide the Title.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
value - The text of the chart title.public boolean getOverlay()
false.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
boolean value.public void setOverlay(boolean value)
false.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
value - The corresponding boolean value.public boolean getShow()
true.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
boolean value.public void setShow(boolean value)
true.
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
value - The corresponding boolean value.public Font getFont()
Examples:
Shows how to insert a chart and set a title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a chart shape with a document builder and get its chart.
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
Chart chart = chartShape.getChart();
// Use the "Title" property to give our chart a title, which appears at the top center of the chart area.
ChartTitle title = chart.getTitle();
title.setText("My Chart");
title.getFont().setSize(15.0);
title.getFont().setColor(Color.BLUE);
// Set the "Show" property to "true" to make the title visible.
title.setShow(true);
// Set the "Overlay" property to "true" Give other chart elements more room by allowing them to overlap the title
title.setOverlay(true);
doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
Font value.public ChartFormat getFormat()
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");
ChartFormat value.