com.aspose.words

Class ChartFormat

  • java.lang.Object
    • com.aspose.words.ChartFormat
public class ChartFormat 
extends java.lang.Object

Represents the formatting of a chart element.

Property Getters/Setters Summary
FillgetFill()
Gets fill formatting for the parent chart element.
StrokegetStroke()
Gets line formatting for the parent chart element.
 

    • Property Getters/Setters Detail

      • getFill

        public Fill getFill()
        
        Gets fill formatting for the parent chart element.

        Example:

        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");
      • getStroke

        public Stroke getStroke()
        
        Gets line formatting for the parent chart element.

        Example:

        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");