Line: Line chart

Description Usage Arguments See Also Examples

Description

The Chartist line chart can be used to draw Line or Scatter charts.

Usage

1
2
3
4
5
6
7
8
Line(x_offset = NULL, x_labelOffset = NULL, x_showLabel = NULL,
  x_showGrid = NULL, x_labelInterpolationFnc = NULL, y_offset = NULL,
  y_labelOffset = NULL, y_showLabel = NULL, y_showGrid = NULL,
  y_labelInterpolationFnc = NULL, y_scaleMinSpace = NULL, width = NULL,
  height = NULL, showLine = NULL, showPoint = NULL, showArea = NULL,
  areaBase = NULL, lineSmooth = NULL, low = NULL, high = NULL,
  chartPadding = NULL, fullWidth = NULL, classNames = NULL,
  responsiveQuery = NULL)

Arguments

x_offset

offset of the X-axis

x_labelOffset

offset of the each X-axis label (e.g. 1, c(1,2), list(x=1, y=2))

x_showLabel

if X-axis labels should be shown or not

x_showGrid

if X-axis grid should be drawn or not

x_labelInterpolationFnc

JS function to intercept the value from the X-axis label

y_offset

offset of the Y-axis labels to the chart area

y_labelOffset

offset of the X-axis labels (e.g. 1, c(1,2), list(x=1, y=2))

y_showLabel

if Y-axis labels should be shown or not

y_showGrid

if Y-axis grid should be drawn or not

y_labelInterpolationFnc

JS function to intercept the value from the Y-axis label

y_scaleMinSpace

minimum height in pixel of the scale steps

width

fixed width for the chart as a string (i.e. '100px' or '50%')

height

fixed height for the chart as a string (i.e. '100px' or '50%')

showLine

if the line should be drawn or not

showPoint

if dots should be drawn or not

showArea

if the line chart should draw an area

areaBase

base for the area chart that will be used to close the area shape (is normally 0)

lineSmooth

if the lines should be smoothed (Catmull-Rom-Splines will be used)

low

lower limit of value

high

higher limit of value

chartPadding

padding of the chart drawing area to the container element and labels

fullWidth

When set to true, the last grid line on the x-axis is not drawn and the chart elements will expand to the full available width of the chart. For the last label to be drawn correctly you might need to add chart padding or offset the last label with a draw event handler.

classNames

Override the class names that get used to generate the SVG structure of the chart

responsiveQuery

if specified, the options are used only when the query matches.

See Also

http://gionkunz.github.io/chartist-js/api-documentation.html#chartistline-function-line

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 
set.seed(324)
data <- data.frame(
  day = 1:20,
  A   = runif(20, 0, 10),
  B   = runif(20, 0, 10),
  C   = runif(20, 0, 10),
  D   = runif(20, 0, 10)
  )

chartist(data, day) + Line(showArea = TRUE, showPoint = FALSE)

# use JS function to generate axis labels
interp <- JS_interp(interval = 4, prefix = " day")
chartist(data, day) + Line(x_labelInterpolationFnc = interp)

# Of cource you can create your own JS function
interp2 <- htmlwidgets::JS("function(value, index) {
                             return index % 7 === 0 ? 'week ' + (index / 7) : null;}")
chartist(data, day) + Line(x_labelInterpolationFnc = interp2)

# these are the same
chartist(data, day) + Point()
chartist(data, day) + Line(showLine = FALSE)

# responsive chart
set.seed(324)
data <- data.frame(
  day = 1:10,
  A   = runif(10, 0, 10),
  B   = runif(10, 0, 10),
  C   = runif(10, 0, 10)
)

chartist(data, day) +
  # By default, the axis labels are day-bases
  Line(x_labelInterpolationFnc = JS_interp(interval = 1, prefix = "day")) +
  # For small screens, they are week-bases
  Line(x_labelInterpolationFnc = JS_interp(interval = 7, prefix = "week"),
       showPoint = FALSE,
       responsiveQuery = "screen and (max-width: 600px)")

## End(Not run)

yutannihilation/chartist documentation built on May 4, 2019, 7:45 p.m.