com.aspose.words

Class ChartTitle

  • java.lang.Object
    • com.aspose.words.ChartTitle
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class ChartTitle 
    extends java.lang.Object

Provides access to the chart title properties.

Example:

Shows how to insert a chart and change its title.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Use a document builder to insert a bar chart
Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);

Assert.assertEquals(chartShape.getShapeType(), ShapeType.NON_PRIMITIVE);
Assert.assertTrue(chartShape.hasChart());

// Get the chart object from the containing shape
Chart chart = chartShape.getChart();

// Set the title text, which appears at the top center of the chart and modify its appearance
ChartTitle title = chart.getTitle();
title.setText("MyChart");
title.setOverlay(true);
title.setShow(true);

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

Property Getters/Setters Summary
booleangetOverlay()
void
setOverlay(booleanvalue)
           Determines whether other chart elements shall be allowed to overlap title. By default overlay is false.
booleangetShow()
void
setShow(booleanvalue)
           Determines whether the title shall be shown for this chart. Default value is true.
java.lang.StringgetText()
void
setText(java.lang.Stringvalue)
           Gets or sets the text of the chart title. If null or empty value is specified, auto generated title will be shown.
 

    • Property Getters/Setters Detail

      • getOverlay/setOverlay

        public boolean getOverlay() / public void setOverlay(boolean value)
        
        Determines whether other chart elements shall be allowed to overlap title. By default overlay is false.

        Example:

        Shows how to insert a chart and change its title.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Use a document builder to insert a bar chart
        Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
        
        Assert.assertEquals(chartShape.getShapeType(), ShapeType.NON_PRIMITIVE);
        Assert.assertTrue(chartShape.hasChart());
        
        // Get the chart object from the containing shape
        Chart chart = chartShape.getChart();
        
        // Set the title text, which appears at the top center of the chart and modify its appearance
        ChartTitle title = chart.getTitle();
        title.setText("MyChart");
        title.setOverlay(true);
        title.setShow(true);
        
        doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
      • getShow/setShow

        public boolean getShow() / public void setShow(boolean value)
        
        Determines whether the title shall be shown for this chart. Default value is true.

        Example:

        Shows how to insert a chart and change its title.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Use a document builder to insert a bar chart
        Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
        
        Assert.assertEquals(chartShape.getShapeType(), ShapeType.NON_PRIMITIVE);
        Assert.assertTrue(chartShape.hasChart());
        
        // Get the chart object from the containing shape
        Chart chart = chartShape.getChart();
        
        // Set the title text, which appears at the top center of the chart and modify its appearance
        ChartTitle title = chart.getTitle();
        title.setText("MyChart");
        title.setOverlay(true);
        title.setShow(true);
        
        doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");
      • getText/setText

        public java.lang.String getText() / public void setText(java.lang.String value)
        
        Gets or sets the text of the chart title. If null or empty value is specified, auto generated title will be shown. Use Show option if you need to hide the Title.

        Example:

        Shows how to insert a chart and change its title.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Use a document builder to insert a bar chart
        Shape chartShape = builder.insertChart(ChartType.BAR, 400.0, 300.0);
        
        Assert.assertEquals(chartShape.getShapeType(), ShapeType.NON_PRIMITIVE);
        Assert.assertTrue(chartShape.hasChart());
        
        // Get the chart object from the containing shape
        Chart chart = chartShape.getChart();
        
        // Set the title text, which appears at the top center of the chart and modify its appearance
        ChartTitle title = chart.getTitle();
        title.setText("MyChart");
        title.setOverlay(true);
        title.setShow(true);
        
        doc.save(getArtifactsDir() + "Charts.ChartTitle.docx");