Class SimpleLineChart
A chart of a few lines over time, or over any categories in their order: the categories left to right, each line labeled at its right end with its name and its last value, so that it needs no legend; one line highlighted in navy, its label bold, the others gray. A light horizontal grid alone, no border, on a light panel, with a title and a subtitle at the top left, in the look of SimpleBarChart and SimpleScatterChart. A value that is NaN leaves a gap in its line. A value outside a range that is set cuts its line at the edge of the plot, and the chart says how many are: "2 values outside the range", small, under the plot at its right end, and in its description, in that alone when the plot would not be left room to draw.
In a PDF/UA document the chart is one figure, described from its data: the lines, their first and last values and their highest, and the values outside a range, unless an alternate description is set, which is then followed by those values alone. It draws with the page alone, and needs no other chart. Please see Example_25.
public class SimpleLineChart : IDrawable
- Inheritance
-
SimpleLineChart
- Implements
- Inherited Members
Constructors
SimpleLineChart(Font, Font)
Creates a simple line chart, 400 by 300 points.
public SimpleLineChart(Font f1, Font f2)
Parameters
f1Fontthe font of the title and of the highlighted line's label, a bold one.
f2Fontthe font of the subtitle, the axis titles, the numbers, the categories and the other labels.
Methods
AddLine(string, float[])
Adds a line: its name, and a value for each category, NaN where it has none. The chart keeps a copy of the values: a caller that reused one array for every line drew every line with the last values (the review of 28 October 2026).
public SimpleLineChart AddLine(string name, float[] values)
Parameters
Returns
- SimpleLineChart
this chart.
DrawOn(Page)
Draws the chart on the page. A chart too small for its plot, its numbers and its labels draws nothing.
public float[] DrawOn(Page page)
Parameters
pagePagethe page to draw on.
Returns
- float[]
the x and y coordinates of the bottom right corner of the chart.
SetAltDescription(string)
Sets the alternate description of the chart in a PDF/UA document. Without one the chart is described from its data. The number of values outside a range that is set follows it, as the chart prints it.
public SimpleLineChart SetAltDescription(string altDescription)
Parameters
altDescriptionstringthe alternate description.
Returns
- SimpleLineChart
this chart.
SetAreaFilled(bool)
Fills the area between each line and 0, or the edge of the plot nearest 0 when 0 is outside it, in a light tint of the line's color, which makes an area chart. The highlighted line's area is drawn last, over the others.
public SimpleLineChart SetAreaFilled(bool areaFilled)
Parameters
areaFilledbooltrue to fill the areas.
Returns
- SimpleLineChart
this chart.
SetCategories(params string[])
Sets the categories, the years or the months, in their order left to right. The chart keeps a copy of them, a null category an empty one, which crashed DrawOn (the review of 28 October 2026).
public SimpleLineChart SetCategories(params string[] categories)
Parameters
categoriesstring[]the categories.
Returns
- SimpleLineChart
this chart.
SetHighlight(int)
Highlights the line of the index, the first line 0: navy and a little wider, its label bold.
public SimpleLineChart SetHighlight(int index)
Parameters
indexintthe index of the line.
Returns
- SimpleLineChart
this chart.
SetHighlightColor(int)
Sets the color of the highlighted line and of its label. It is navy, 0x1F3A5F, unless set.
public SimpleLineChart SetHighlightColor(int color)
Parameters
colorintthe color.
Returns
- SimpleLineChart
this chart.
SetLineColor(int)
Sets the color of the lines that are not highlighted. It is gray, 0x8C96A3, unless set.
public SimpleLineChart SetLineColor(int color)
Parameters
colorintthe color.
Returns
- SimpleLineChart
this chart.
SetLocation(float, float)
Sets the top left corner of the chart.
public SimpleLineChart SetLocation(float x, float y)
Parameters
Returns
- SimpleLineChart
this chart.
SetMarkers(bool)
Draws a dot at each value of the lines.
public SimpleLineChart SetMarkers(bool markers)
Parameters
markersbooltrue to draw them.
Returns
- SimpleLineChart
this chart.
SetPanelColor(int)
Sets the color of the panel behind the chart. It is light gray, 0xF1F3F6, unless set. Color.transparent, -1, draws no panel: the one color setter where it does not leave the color as it was.
public SimpleLineChart SetPanelColor(int color)
Parameters
colorintthe color.
Returns
- SimpleLineChart
this chart.
SetSize(float, float)
Sets the width and the height of the chart.
public SimpleLineChart SetSize(float w, float h)
Parameters
Returns
- SimpleLineChart
this chart.
SetSubtitle(string)
Sets the subtitle, drawn small and gray under the title.
public SimpleLineChart SetSubtitle(string subtitle)
Parameters
subtitlestringthe subtitle.
Returns
- SimpleLineChart
this chart.
SetTitle(string)
Sets the title, drawn at the top left of the chart.
public SimpleLineChart SetTitle(string title)
Parameters
titlestringthe title.
Returns
- SimpleLineChart
this chart.
SetValueLabels(bool)
Writes each value of the lines by its point, small, where the line leaves it room: above a peak, under a valley, before or after a point on a rise or a fall; but the last of each line, which its label at the end of the line has, and a value outside a range set with SetYAxisRange, whose point is not drawn.
public SimpleLineChart SetValueLabels(bool valueLabels)
Parameters
valueLabelsbooltrue to write them.
Returns
- SimpleLineChart
this chart.
SetXAxisTitle(string)
Sets the title of the categories, drawn under them.
public SimpleLineChart SetXAxisTitle(string title)
Parameters
titlestringthe title.
Returns
- SimpleLineChart
this chart.
SetYAxisRange(float, float)
Sets the range of the vertical axis. Without it the range is that of the values, rounded to steps. A range whose end is not past its start is not set. A value outside the range is drawn past the plot, which clips it, and the chart says how many are, under the plot, which is that much lower, and in its description.
public SimpleLineChart SetYAxisRange(float min, float max)
Parameters
Returns
- SimpleLineChart
this chart.
SetYAxisTitle(string)
Sets the title of the vertical axis, drawn up its left side.
public SimpleLineChart SetYAxisTitle(string title)
Parameters
titlestringthe title.
Returns
- SimpleLineChart
this chart.