diff --git a/File-Formats/DocIO/Charts/Chart-Title.md b/File-Formats/DocIO/Charts/Chart-Title.md index 5b5817933..6a47a805d 100644 --- a/File-Formats/DocIO/Charts/Chart-Title.md +++ b/File-Formats/DocIO/Charts/Chart-Title.md @@ -196,4 +196,112 @@ End Using {% endhighlight %} {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Charts/Format-Chart-Title/.NET). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Charts/Format-Chart-Title/.NET). + +## Remove Chart Title + +The following code example illustrates how to remove the chart title from the Word document. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} +//Creates a new instance of WordDocument. +using (WordDocument document = new WordDocument()) +{ + //Adds section to the document. + IWSection sec = document.AddSection(); + //Adds paragraph to the section. + IWParagraph paragraph = sec.AddParagraph(); + //Creates and Appends chart to the paragraph. + WChart chart = paragraph.AppendChart(446, 270); + //Sets chart type. + chart.ChartType = OfficeChartType.Pie; + //Sets chart title. + chart.ChartTitle = string.Empty; + //Sets data for chart. + chart.ChartData.SetValue(1, 1, ""); + chart.ChartData.SetValue(1, 2, "Sales"); + chart.ChartData.SetValue(2, 1, "Phyllis Lapin"); + chart.ChartData.SetValue(2, 2, 141.396); + chart.ChartData.SetValue(3, 1, "Stanley Hudson"); + chart.ChartData.SetValue(3, 2, 80.368); + //Creates a new chart series with the name “Sales”. + IOfficeChartSerie pieSeries = chart.Series.Add("Sales"); + pieSeries.Values = chart.ChartData[2, 2, 3, 2]; + //Sets category labels. + chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 3, 1]; + //Saves the Word document to MemoryStream. + MemoryStream stream = new MemoryStream(); + document.Save(stream, FormatType.Docx); + //Closes the document. + document.Close(); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Creates a new instance of WordDocument. +using (WordDocument document = new WordDocument()) +{ + //Adds section to the document. + IWSection sec = document.AddSection(); + //Adds paragraph to the section. + IWParagraph paragraph = sec.AddParagraph(); + //Creates and Appends chart to the paragraph. + WChart chart = paragraph.AppendChart(446, 270); + //Sets chart type. + chart.ChartType = OfficeChartType.Pie; + //Sets chart title. + chart.ChartTitle = string.Empty; + //Sets data for chart. + chart.ChartData.SetValue(1, 1, ""); + chart.ChartData.SetValue(1, 2, "Sales"); + chart.ChartData.SetValue(2, 1, "Phyllis Lapin"); + chart.ChartData.SetValue(2, 2, 141.396); + chart.ChartData.SetValue(3, 1, "Stanley Hudson"); + chart.ChartData.SetValue(3, 2, 80.368); + //Creates a new chart series with the name “Sales”. + IOfficeChartSerie pieSeries = chart.Series.Add("Sales"); + pieSeries.Values = chart.ChartData[2, 2, 3, 2]; + //Sets category labels. + chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 3, 1]; + //Saves the document + document.Save("Sample.docx"); + //Closes the document. + document.Close(); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Creates an empty WordDocument instance + Dim document As New WordDocument() +'Adds section to the document. + Dim sec As IWSection = document.AddSection() +'Adds paragraph to the section. + Dim paragraph As IWParagraph = sec.AddParagraph() +'Creates and Appends chart to the paragraph. + Dim chart As WChart = paragraph.AppendChart(446,270) +'Sets chart type. + chart.ChartType = OfficeChartType.Pie +'Sets chart title. + chart.ChartTitle = String.Empty +'Sets data for chart. + chart.ChartData.SetValue(1, 1, "") + chart.ChartData.SetValue(1, 2, "Sales") + chart.ChartData.SetValue(2, 1, "Phyllis Lapin") + chart.ChartData.SetValue(2, 2, 141.396) + chart.ChartData.SetValue(3, 1, "Stanley Hudson") + chart.ChartData.SetValue(3, 2, 80.368) +'Creates a new chart series with the name “Sales”. + Dim pieSeries As IOfficeChartSerie = chart.Series.Add("Sales") + pieSeries.Values = chart.ChartData(2, 2, 3, 2) +'Sets category labels. + chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData(2, 1, 3, 1) +'Saves the document + document.Save("Sample.docx", FormatType.Docx) +'Closes the document + document.Close() +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Charts/Remove-chart-title). diff --git a/File-Formats/DocIO/Working-with-Charts.md b/File-Formats/DocIO/Working-with-Charts.md index f5b08d62c..082b28bcd 100644 --- a/File-Formats/DocIO/Working-with-Charts.md +++ b/File-Formats/DocIO/Working-with-Charts.md @@ -1257,4 +1257,4 @@ The following chart types are supported in DocIO. * [How to create line chart with different color series in Word document using C#?](https://support.syncfusion.com/kb/article/12275/how-to-create-line-chart-with-different-color-series-in-word-document-using-c) * [How to set column space for column charts in Word document?](https://support.syncfusion.com/kb/article/12296/how-to-set-column-space-for-column-charts-in-word-document) * [How to set Y-axis interval for column charts in Word document?](https://support.syncfusion.com/kb/article/12294/how-to-set-y-axis-interval-for-column-charts-in-word-document) -* [How to change chart title position in the Word document?](https://support.syncfusion.com/kb/article/12292/how-to-change-chart-title-position-in-the-word-document) \ No newline at end of file +* [How to change chart title position in the Word document?](https://support.syncfusion.com/kb/article/12292/how-to-change-chart-title-position-in-the-word-document)