# Chart Title

Using DsExcel, you can easily set the formula for the chart title, set format for the chart title and font style, and set text angle for chart title.

## Content

In DsExcel Java, you can use the methods of the [IChart](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChart.html) interface in order to configure the chart title of your choice.
You can work with Chart title in the following ways:

* [Set Formula for Chart Title](/document-solutions/java-excel-api/docs/online/Features/UseChart/ConfigureChart/ChartTitle#set-formula-for-chart-title)
* [Set Format for Chart Title and Font Style](/document-solutions/java-excel-api/docs/online/Features/UseChart/ConfigureChart/ChartTitle#set-format-for-chart-title-and-font-style)
* [Set Direction of Chart Title](/document-solutions/java-excel-api/docs/online/Features/UseChart/ConfigureChart/ChartTitle#set-direction-of-chart-title)
* [Set Text Angle for Chart Title](/document-solutions/java-excel-api/docs/online/Features/UseChart/ConfigureChart/ChartTitle#set-text-angle-for-chart-title)

## Set Formula for Chart Title

To set formula for chart title, refer to the following example code.

```Java
// Set formula for chart title.
shape.getChart().setHasTitle(true);
shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().add("ChartSubtitle");
shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().add("ChartTitle", 0);
```

## Set Format for Chart Title and Font Style

To set format for chart title and font style, refer to the following example code.

```Java
// Set chart titale's format and font style.
shape.getChart().setHasTitle(true);
//shape.getChart().getChartTitle().setText("MyChartTitle");
shape.getChart().getChartTitle().getFormat().getFill().getColor().setRGB(Color.GetDarkOrange());
shape.getChart().getChartTitle().getFormat().getLine().getColor().setRGB(Color.GetCornflowerBlue());
```

## Set Direction of Chart Title

You can set the direction of the chart title to horizontal, vertical, rotated (to 90 or 270 degree), and stacked (with text reading left-to-right or right to left). The **setDirection** method in [IChartTitle](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChartTitle.html) and IChartTitle.[ITextFrame](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/ITextFrame.html) interfaces allows you to set the direction of the chart title using [TextDirection](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/TextDirection.html) enumeration.
Refer to the following example code to set vertical chart title:

```Java
// Create chart.
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true);

// Display the chart title.
shape.getChart().setHasTitle(true);

// Set the chart title name.
shape.getChart().getChartTitle().setText("Chart Title");

// Set the direction of chart title to vertical.
shape.getChart().getChartTitle().getTextFrame().setDirection(TextDirection.Vertical);

// OR
shape.getChart().getChartTitle().setDirection(TextDirection.Vertical);
```

## Set Text Angle for Chart Title

You can also configure the text angle for chart title by using the [setOrientation](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChartTitle.html#setOrientation) method of [IChartTitle](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IChartTitle.html) interface. The text angle can also be exported or imported to JSON.
Refer to the following example code to set text angle for chart title.

```Java
//create a new workbook
  Workbook workbook = new Workbook();
 // Fetch default worksheet
 IWorksheet worksheet = workbook.getWorksheets().get(0);

 //add chart
 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230);
 worksheet.getRange("A1:D6").setValue(new Object[][]
 {
{null, "S1", "S2", "S3"},
{"Item1", 10, 25, 25},
{"Item2", -20, 36, 27},
{"Item3", 62, 70, -30},
{"Item4", 22, 65, 65},
{"Item5", 23, 50, 50}
 });
 shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true);

 //add chart title
 shape.getChart().setHasTitle(true);
 
 shape.getChart().getChartTitle().setText("MyChartTitle");

 //config chart title angle
 shape.getChart().getChartTitle().setOrientation(30);

 //save to an excel file
 workbook.save("configcharttitleangle.xlsx");
```

> !type=note
> **Note**: The setOrientation method only applies if the value of setDirection method is Horizontal. However, the direction and orientation of the chart title can be exported or imported into a JSON file.