Table of Contents

Class BarChart

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Bar chart renderer for PDF pages: one slot per category, the bars of the series grouped inside each slot. See Example_27, of horizontal and vertical bars.

public class BarChart : IDrawable
Inheritance
BarChart
Implements
Inherited Members

Constructors

BarChart(Font, Font)

Creates a bar chart.

public BarChart(Font f1, Font f2)

Parameters

f1 Font

the font for the chart title.

f2 Font

the font for the axis titles, the labels and the legend.

Methods

AddSeries(string, float[])

Adds a series drawn in the next color of the default palette. A value that is NaN or infinite has no bar.

public BarChart AddSeries(string name, float[] values)

Parameters

name string

the series name, shown in the legend; empty for none.

values float[]

one value per category.

Returns

BarChart

this BarChart object.

AddSeries(string, float[], int)

Adds a series drawn in the specified color.

public BarChart AddSeries(string name, float[] values, int color)

Parameters

name string

the series name, shown in the legend; empty for none.

values float[]

one value per category.

color int

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

Returns

BarChart

this BarChart object.

AddSeries(string, float[], int[])

Adds a series with a color per category, for a chart whose bars each have their own color. A bar past the end of the colors has the next color of the default palette.

public BarChart AddSeries(string name, float[] values, int[] colors)

Parameters

name string

the series name, shown in the legend; empty for none.

values float[]

one value per category.

colors int[]

one 0xRRGGBB color per category.

Returns

BarChart

this BarChart object.

DrawOn(Page)

Draws this chart on the specified page.

public float[] DrawOn(Page page)

Parameters

page Page

the page to draw on.

Returns

float[]

the bottom right corner coordinates [x, y].

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, or "Bar chart" without one. Describe what the chart shows.

public BarChart SetAltDescription(string altDescription)

Parameters

altDescription string

the alternate description.

Returns

BarChart

this BarChart object.

SetAxisLineWidth(float)

Sets the width of the axis lines. The default is 0.5; 0 hides them.

public BarChart SetAxisLineWidth(float width)

Parameters

width float

the line width.

Returns

BarChart

this BarChart object.

SetBarGap(float)

Sets the gap between the bars of a group as a fraction of the bar width. The default is 0.0, so the bars of a group touch.

public BarChart SetBarGap(float gap)

Parameters

gap float

the gap.

Returns

BarChart

this BarChart object.

SetCategories(params string[])

Sets the categories, one per group of bars, in the order they are drawn: left to right in a vertical chart, top to bottom in a horizontal one.

public BarChart SetCategories(params string[] categories)

Parameters

categories string[]

the category labels.

Returns

BarChart

this BarChart object.

SetChartBorderWidth(float)

Sets the width of the outer chart border. A width of 0, the default, hides it.

public BarChart SetChartBorderWidth(float width)

Parameters

width float

the border width.

Returns

BarChart

this BarChart object.

SetDrawGridLines(bool)

Sets whether the grid lines of the value axis are drawn.

public BarChart SetDrawGridLines(bool drawGridLines)

Parameters

drawGridLines bool

true to draw them.

Returns

BarChart

this BarChart object.

SetDrawLegend(bool)

Sets whether the legend is drawn. The legend lists the series that have a name, under the title.

public BarChart SetDrawLegend(bool drawLegend)

Parameters

drawLegend bool

true to draw the legend.

Returns

BarChart

this BarChart object.

SetDrawValueLabels(bool)

Sets whether the value of each bar is written at its end, or, in a stacked chart, inside each segment that has room for it.

public BarChart SetDrawValueLabels(bool drawValueLabels)

Parameters

drawValueLabels bool

true to write the values.

Returns

BarChart

this BarChart object.

SetGridLineColor(int)

Sets the color of the grid lines. The default is black. Color.transparent leaves it unchanged.

public BarChart SetGridLineColor(int color)

Parameters

color int

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

Returns

BarChart

this BarChart object.

SetGridLineDashPattern(string)

Sets the dash pattern of the grid lines, for example "[1 1] 0".

public BarChart SetGridLineDashPattern(string pattern)

Parameters

pattern string

the dash pattern.

Returns

BarChart

this BarChart object.

SetGridLineWidth(float)

Sets the width of the grid lines. A width of 0 draws the thinnest line a viewer shows; SetDrawGridLines(false) hides them.

public BarChart SetGridLineWidth(float width)

Parameters

width float

the line width.

Returns

BarChart

this BarChart object.

SetGroupGap(float)

Sets the gap between the groups of bars as a fraction of the category slot, from 0.0 to below 1.0. The default is 0.3.

public BarChart SetGroupGap(float gap)

Parameters

gap float

the gap.

Returns

BarChart

this BarChart object.

SetGroupingUsed(bool)

Sets whether the labels group the digits in thousands with a comma, as in 6,650. The default is false.

public BarChart SetGroupingUsed(bool groupingUsed)

Parameters

groupingUsed bool

true to group the digits.

Returns

BarChart

this BarChart object.

SetHorizontal(bool)

Sets whether the bars are horizontal. The default is vertical bars.

public BarChart SetHorizontal(bool horizontal)

Parameters

horizontal bool

true for horizontal bars.

Returns

BarChart

this BarChart object.

SetInnerBorderWidth(float)

Sets the width of the plot area border. A width of 0, the default, hides it.

public BarChart SetInnerBorderWidth(float width)

Parameters

width float

the border width.

Returns

BarChart

this BarChart object.

SetLocation(float, float)

Sets the location of the top left corner of this chart.

public BarChart SetLocation(float x, float y)

Parameters

x float

the x coordinate.

y float

the y coordinate.

Returns

BarChart

this BarChart object.

SetMaximumFractionDigits(int)

Sets the maximum number of decimal places in the value labels. The default is 2.

public BarChart SetMaximumFractionDigits(int maxFractionDigits)

Parameters

maxFractionDigits int

the maximum number of decimal places.

Returns

BarChart

this BarChart object.

SetMinimumFractionDigits(int)

Sets the minimum number of decimal places in the value labels. The axis labels have at least the decimal places of the axis step. The default is 0.

public BarChart SetMinimumFractionDigits(int minFractionDigits)

Parameters

minFractionDigits int

the minimum number of decimal places.

Returns

BarChart

this BarChart object.

SetSize(float, float)

Sets the size of this chart.

public BarChart SetSize(float w, float h)

Parameters

w float

the width.

h float

the height.

Returns

BarChart

this BarChart object.

SetStacked(bool)

Sets whether the series are stacked: one bar per category, with the value of each series as a segment of it. The values above 0 stack up from 0 and the values below 0 stack down. The default is grouped bars.

public BarChart SetStacked(bool stacked)

Parameters

stacked bool

true for stacked bars.

Returns

BarChart

this BarChart object.

SetSubtitle(string)

Sets the subtitle, written in gray under the title in the second font.

public BarChart SetSubtitle(string subtitle)

Parameters

subtitle string

the subtitle.

Returns

BarChart

this BarChart object.

SetTitle(string)

Sets the chart title.

public BarChart SetTitle(string title)

Parameters

title string

the title.

Returns

BarChart

this BarChart object.

SetValueAxisMinMax(float, float, int)

Sets the range and the number of grid lines of the value axis. Without it the range is computed from the data and always includes 0.

public BarChart SetValueAxisMinMax(float min, float max, int gridLines)

Parameters

min float

the value at the start of the axis.

max float

the value at the end of the axis.

gridLines int

the number of grid lines, at least 1.

Returns

BarChart

this BarChart object.

SetValueLabelsInside(bool)

Sets whether the value labels are written inside the bars, in white at the end of each bar, instead of next to the bar ends. A bar too short for its label gets it next to its end. The default is false.

public BarChart SetValueLabelsInside(bool valueLabelsInside)

Parameters

valueLabelsInside bool

true to write the values inside the bars.

Returns

BarChart

this BarChart object.

SetXAxisTitle(string)

Sets the X axis title.

public BarChart SetXAxisTitle(string title)

Parameters

title string

the title.

Returns

BarChart

this BarChart object.

SetYAxisTitle(string)

Sets the Y axis title.

public BarChart SetYAxisTitle(string title)

Parameters

title string

the title.

Returns

BarChart

this BarChart object.