Table of Contents

Class DonutChart

Namespace
PDFjet.NET
Assembly
PDFjet.dll

A donut or pie chart: each slice is its value's share of the sum of the values, with a label next to it and its percentage inside it. A chart with an inner radius of 0 is a pie chart. In the look of the other charts: a title and a subtitle at the top left, thin white lines between the slices, gray leader lines, the labels in ink, and each percentage white or ink by its slice's color. See Example_28.

public class DonutChart : IDrawable
Inheritance
DonutChart
Implements
Inherited Members

Constructors

DonutChart(Font, Font)

Creates a donut chart. With an inner radius of 0 it is a pie chart. Its fonts are in the order of the other charts': the bold one first.

public DonutChart(Font bold, Font regular)

Parameters

bold Font

the bold font: the percentages inside the slices, the title and the text in the hole.

regular Font

the regular font: the slice labels, the subtitle and the legend, and the size of the title.

Methods

Add(string, float)

Adds a slice in the next color of the palette, blue first, the palette of BarChart, so that the charts of a document match; its ten colors repeat from the eleventh slice on. The slice's share of the sum of the values sets its angle; a value that is not above 0 has no slice.

public DonutChart Add(string name, float value)

Parameters

name string

the label of the slice; empty for none.

value float

the value of the slice.

Returns

DonutChart

this DonutChart object.

Add(string, float, int)

Adds a slice in the color.

public DonutChart Add(string name, float value, int color)

Parameters

name string

the label of the slice; empty for none.

value float

the value of the slice.

color int

the color as a 0xRRGGBB value, for example Color.blue.

Returns

DonutChart

this DonutChart object.

DrawOn(Page)

Draws this chart on the specified page.

public float[] DrawOn(Page page)

Parameters

page Page

the page to draw on, or null to measure the chart.

Returns

float[]

x and y coordinates of the bottom right corner of the chart: of its title, its circle, and its leader lines and labels, which can reach past the circle, or its legend. A chart with no slice above 0 draws nothing, not its title either, and returns the corner of its circle.

SetAltDescription(string)

Sets the alternate description of the chart, which a screen reader reads in a PDF/UA document, where the chart is a figure. The default is the title, the subtitle and the text in the hole, as sentences, and the label and the percentage of each slice.

public DonutChart SetAltDescription(string altDescription)

Parameters

altDescription string

the alternate description.

Returns

DonutChart

this DonutChart object.

SetCenterText(string)

Sets the text written in the hole of a donut chart, in the font of the title, as large as one and a half labels or as fits: the total, "100 crates". A text too wide for the hole at three quarters of a label is shortened with an ellipsis. A pie chart, with no hole, does not write it.

public DonutChart SetCenterText(string centerText)

Parameters

centerText string

the text.

Returns

DonutChart

this DonutChart object.

SetLegend(bool)

Draws a legend under the circle, a swatch, the label and the percentage of each slice, in rows as wide as the circle, in place of the leader lines and the labels beside the circle: for many slices, or small ones whose labels would crowd.

public DonutChart SetLegend(bool legend)

Parameters

legend bool

true to draw the legend.

Returns

DonutChart

this DonutChart object.

SetLocation(float, float)

Sets the top left corner of this chart: of its outer circle, or of its title when it has one, the circle under it. The center is one outer radius to the right of the corner of the circle and one below. The slice labels can extend past the circle.

public DonutChart SetLocation(float x, float y)

Parameters

x float

the x coordinate of the top left corner.

y float

the y coordinate of the top left corner.

Returns

DonutChart

SetRadii(float, float)

Sets the outer and inner radius of this chart; an inner radius of 0 makes a pie chart.

public DonutChart SetRadii(float outerRadius, float innerRadius)

Parameters

outerRadius float
innerRadius float

Returns

DonutChart

SetSubtitle(string)

Sets the subtitle, drawn under the title in a muted gray.

public DonutChart SetSubtitle(string subtitle)

Parameters

subtitle string

the subtitle.

Returns

DonutChart

this DonutChart object.

SetTitle(string)

Sets the title, drawn at the top left of the chart's location in the bold font at the size of the labels; the circle is drawn under it. A chart without the bold font, which draws no percentages, draws its title in the regular one. A chart without a title has the circle at its location.

public DonutChart SetTitle(string title)

Parameters

title string

the title.

Returns

DonutChart

this DonutChart object.