Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
New InsertChart method was added into the DocumentBuilder class. So, let’s see how to insert a simple column chart into the document using the InsertChart method.
In this section we will learn how to insert a chart into a document.
The following code example shows how to insert column chart:
The code produces the following result:
There are four different overloads for series Add method, which was exposed to cover all possible variants of data sources for all chart types:
The code produces the following result:
The following code example shows how to insert a scatter chart:
The code produces the following result:
The following code example shows how to insert an area chart:
The code produces the following result:
The following code example shows how to insert a bubble chart:
The code produces the following result:
Shape.Chart
ObjectOnce the chart was inserted and filled with data, you are able to change its appearance. Shape.Chart
property contains all chart related options available through the public API.
For example, let’s change Chart title or legend behavior:
The code generates the followings results:
Let’s look into ChartSeries collection. All chart series are available through chart.Series collection, which is IEnumerable:
You can remove series one by one or clear all of them as well as add a new one if needed. The newly inserted chart has some default series added to this collection. To remove them you need to call the chart.Series.Clear() method.
Here is how to work with a particular series:
Please see the result below:
All single ChartSeries have default ChartDataPoint options, please try using the following code to change them:
Please see the result below:
ChartSeries
Using ChartDataPoint you are able to customize the formatting of a single data point of the chart series:
Please see the result below:
Using ChartDataLabel you are able to specify the formatting of a single data label of the chart series, like show/hide LegendKey, CategoryName, SeriesName, Value etc:
Please see the result below:
The ChartDataLabelCollection class defines properties which can be used to set default options for ChartDataLabels for Chart Series. These properties include ShowCategoryName, ShowBubbleSize, ShowPercentage, ShowSeriesName, ShowValue etc:
Please see the result below:
Using NumberFormat you are able to specify number formatting of a single data label of the chart.
The following code example shows how to format a number of the data label:
If you want to work with chart axis, scaling, and display units for the value axis, please use ChartAxis, AxisDisplayUnit, and AxisScaling classes.
The following code example shows how to define X and Y-axis properties:
The following code example shows how to set date/time values to axis properties:
The following code example shows how to change the format of numbers on the value axis:
The AxisBound
class represents a minimum or maximum bound of axis values. Bound can be specified as a numeric, date-time or a special “auto” value.
The following code example shows how to set bounds of an axis:
The following code example shows how to set the interval unit between labels on an axis:
If you want to show or hide the chart axis, you can simply achieve this by setting the value of ChartAxis.Hidden
property.
The following code example shows how to hide the Y-axis of the chart:
If you want to set a text alignment for multi-line labels, you can simply achieve this by setting the value of the TickLabels.Alignment property.
The following code example shows how to tick label alignment:
Fill and stroke formatting can be set for chart series, data points, and markers. To do this, you need to use the properties of the ChartFormat type in the ChartSeries, ChartDataPoint, and ChartMarker classes, as well as aliases for some properties, such as ForeColor, BackColor, Visible, and Transparency in the Stroke
class.
The following code example shows how to set series color:
The following code example shows how to set line color and weight:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.