Options


bindto

The CSS selector or the element which the chart will be set to. D3 selection object can be specified. If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).


If this option is not specified, the chart will be generated but not be set. Instead, we can access the element by chart.element and set it by ourselves.

Note:

When chart is not binded, c3 starts observing if chart.element is binded by MutationObserver. In this case, polyfill is required in IE9 and IE10 because they do not support MutationObserver. On the other hand, if chart always will be binded, polyfill will not be required because MutationObserver will never be called.

Default:
#chart
Format:
bindto: '#myContainer'
// or element
bindto: document.getElementById('myContainer')
// or D3 selection object
bindto: d3.select('#myContainer')

size.width

The desired width of the chart element.


If this option is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.

Default:
undefined
Format:
size: {
  width: 640
}
Note:

This option should be specified if possible because it can improve its performance because some size calculations will be skipped by an explicit value.


size.height

The desired height of the chart element.


If this option is not specified, the height of the chart will be calculated by the size of the parent element it's appended to.

Default:
undefined
Format:
size: {
  height: 480
}

padding.top

The padding on the top of the chart.

Default:
undefined
Format:
padding: {
  top: 20
}
Example:

padding.right

The padding on the right of the chart.

Default:
undefined
Format:
padding: {
  right: 20
}
Example:

padding.bottom

The padding on the bottom of the chart.

Default:
undefined
Format:
padding: {
  bottom: 20
}
Example:

padding.left

The padding on the left of the chart.

Default:
undefined
Format:
padding: {
  left: 20
}
Example:
Note:

This option should be specified if possible because it can improve its performance because some size calculations will be skipped by an explicit value.


color.pattern

Set custom color pattern.

Default:
undefined
Format:
color: {
  pattern: ['#1f77b4', '#aec7e8', ...]
}
Example:

color.threshold

not yet


interaction.enabled

Indicate if the chart should have interactions.


If false is set, all of interactions (showing/hiding tooltip, selection, mouse events, etc) will be disabled.

Default:
true
Format:
interaction: {
  enabled: false
}

transition.duration

Set duration of transition (in milliseconds) for chart animation.

Note:

If 0 or null set, transition will be skipped. So, this makes initial rendering faster especially in case you have a lot of data.

Default:
350
Format:
transition: {
  duration: 500
}
Example:

oninit

Set a callback to execute when the chart is initialized.

Default:
function () {}
Format:
oninit: function () { ... }

onrendered

Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is redrawed.

Default:
function () {}
Format:
onrendered: function () { ... }

onmouseover

Set a callback to execute when mouse enters the chart.

Default:
function () {}
Format:
onmouseover: function () { ... }

onmouseout

Set a callback to execute when mouse leaves the chart.

Default:
function () {}
Format:
onmouseout: function () { ... }

onresize

Set a callback to execute when user resizes the screen.

Default:
function () {}
Format:
onresize: function () { ... }

onresized

Set a callback to execute when screen resize finished.

Default:
function () {}
Format:
onresized: function () { ... }

data.url

Load a CSV or JSON file from a URL. Note that this will not work if loading via the "file://" protocol as the most browsers will block XMLHTTPRequests.

Format:
var chart = c3.generate({
  data: {
    url: '/data/c3_test.csv'
  }
});

data.json

Parse a JSON object for data. See also data.keys.

Format:
var chart = c3.generate({
  data: {
    json: [
      {name: 'www.site1.com', upload: 200, download: 200, total: 400},
      {name: 'www.site2.com', upload: 100, download: 300, total: 400},
      {name: 'www.site3.com', upload: 300, download: 200, total: 500},
      {name: 'www.site4.com', upload: 400, download: 100, total: 500}
    ],
    keys: {
      // x: 'name', // it's possible to specify 'x' when category axis
      value: ['upload', 'download']
    }
  },
  axis: {
    x: {
      // type: 'category'
    }
  }
});

data.rows

Load data from a multidimensional array, with the first element containing the data names, the following containing related data in that order.

Format:
rows: [
  ['data1', 'data2', 'data3'],
  [90, 120, 300],
  [40, 160, 240],
  [50, 200, 290],
  [120, 160, 230],
  [80, 130, 300],
  [90, 220, 320]
]

data.columns

Load data from a multidimensional array, with each element containing an array consisting of a datum name and associated data values.

Format:
columns: [
  ['data1', 30, 20, 50, 40, 60, 50],
  ['data2', 200, 130, 90, 240, 130, 220],
  ['data3', 300, 200, 160, 400, 250, 250]
]

data.mimeType

Used if loading JSON via data.url:

{data: {mimeType: 'json'}}

data.keys

Choose which JSON object keys correspond to desired data.

Format:
var chart = c3.generate({
  data: {
    json: [
      {name: 'www.site1.com', upload: 200, download: 200, total: 400},
      {name: 'www.site2.com', upload: 100, download: 300, total: 400},
      {name: 'www.site3.com', upload: 300, download: 200, total: 500},
      {name: 'www.site4.com', upload: 400, download: 100, total: 500}
    ],
    keys: {
      // x: 'name', // it's possible to specify 'x' when category axis
      value: ['upload', 'download']
    }
  },
  axis: {
    x: {
      // type: 'category'
    }
  }
});

data.x

Specify the key of x values in the data.


We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.

Default:
undefined
Format:
data: {
  x: 'date'
}
Example:

data.xs

Specify the keys of the x values for each data.


This option can be used if we want to show the data that has different x values.

Default:
{}
Format:
data: {
  xs: {
    data1: 'x1',
    data2: 'x2'
  }
}
Example:
Note:

data.x should be used if the all of data have same x values.


data.xFormat

Set a format to parse string specified as x.

Default:
%Y-%m-%d
Format:
data: {
  xFormat: '%Y-%m-%d %H:%M:%S'
}
Example:

data.xLocaltime

not yet


data.xSort

not yet


data.names

Set custom data name.

Default:
{}
Format:
data: {
  names: {
    data1: 'Data Name 1',
    data2: 'Data Name 2'
  }
}
Example:

data.classes

Set custom data class.


If this option is specified, the element g for the data has an additional class that has the prefix c3-target- (e.g. c3-target-additional-data1-class).

Default:
{}
Format:
data: {
  classes: {
    data1: 'additional-data1-class',
    data2: 'additional-data2-class'
  }
}

data.groups

Set groups for the data for stacking.

Default:
[]
Format:
data: {
  groups: [
    ['data1', 'data2'],
    ['data3']
  ]
}
Example:

data.axes

Set y axis the data related to. y and y2 can be used.

Default:
{}
Format:
data: {
  axes: {
    data1: 'y',
    data2: 'y2'
  }
}
Example:

data.type

Set chart type at once.


If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.

Available Values:
  • line
  • spline
  • step
  • area
  • area-spline
  • area-step
  • bar
  • scatter
  • stanford
  • pie
  • donut
  • gauge
Default:
line
Format:
data: {
  type: 'bar'
}
Example:

data.types

Set chart type for each data.


This setting overwrites data.type setting.

Default:
{}
Format:
data: {
  types: {
    data1: 'bar'
    data2: 'spline'
  }
}
Example:

data.labels

Show labels on each data points.

Default:
false
Format:
data: {
  labels: true
}
Example:

data.labels.format

Set formatter function for data labels.


The formatter function receives 4 arguments such as v, id, i, j and it must return a string that will be shown as the label. The arguments are:


  • v is the value of the data point where the label is shown.
  • id is the id of the data where the label is shown.
  • i is the index of the data point where the label is shown.
  • j is the sub index of the data point where the label is shown.

Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (e.g. d3.format('$'))

Default:
{}
Format:
data: {
  labels: {
    format: function (v, id, i, j) { ... }
    // it's possible to set for each data
    //format: {
    //    data1: function (v, id, i, j) { ... },
    //    ...
    //}
  }
}
Example:

data.order

Define the order of the data.


This option changes the order of stacking the data and pieces of pie/donut. If null specified, it will be the order the data loaded. If function specified, it will be used to sort the data and it will receive the data as argument.

Available Values:
  • desc
  • asc
  • function (data1, data2) { ... }
  • null
Default:
desc
Format:
data: {
  order: 'asc'
}
Example:

data.regions

Define regions for each data.


The values must be an array for each data and it should include an object that has start, end, style. If start is not set, the start will be the first data point. If end is not set, the end will be the last data point.


Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.


An optional label property can be provided to display a label for the region. If a label option is not specified, no label will be displayed for the region. For each region, you may also specify the paddingY and paddingX options to control the position of label text. Finally, a vertical option can be used to identify whether or not the label text should be rotated 90 degrees.

Default:
{}
Format:
data: {
  regions: {
    data1: [
      {'start':1, 'end':2, 'style':'dashed'},
      {'start':3, label:"Region 2", paddingX:2, paddingY:2, vertical=true}
    ],
    ...
  }
}
Example:

data.color

Set color converter function.


This option should a function and the specified function receives color (e.g. '#ff0000') and d that has data parameters like id, value, index, etc. And it must return a string that represents color (e.g. '#00ff00').

Default:
undefined
Format:
data: {
  color: function (color, d) { ... }
}
Example:

data.colors

Set color for each data.

Default:
{}
Format:
data: {
  colors: {
    data1: '#ff0000',
    ...
  }
}
Example:

data.hide

Hide each data when the chart appears.


If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.

Default:
false
Format:
data: {
  // all of data will be hidden
  hide: true
  // specified data will be hidden
  hide: ['data1', ...]
}
Note:

This option does not hide legends, so we need to use legend.hide option together if we want to hide legend too.


data.empty.label.text

Set text displayed when empty data.

Default:
""
Format:
data: {
  empty: {
    label: {
      text: "No Data"
    }
  }
}

data.selection.enabled

Set data selection enabled.


If this option is set true, we can select the data points and get/set its state of selection by API (e.g. select, unselect, selected).

Default:
false
Format:
data: {
  selection: {
    enabled: true
  }
}

data.selection.grouped

Set grouped selection enabled.


If this option set true, multiple data points that have same x value will be selected by one selection.

Default:
false
Format:
data: {
  selection: {
    grouped: true
  }
}

data.selection.multiple

Set multiple data points selection enabled.


If this option set true, multiple data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.

Default:
true
Format:
data: {
  selection: {
    multiple: true
  }
}

data.selection.draggable

Enable to select data points by dragging.


If this option set true, data points can be selected by dragging.

Note:

If this option set true, scrolling on the chart will be disabled because dragging event will handle the event.

Default:
false
Format:
data: {
  selection: {
    draggable: true
  }
}

data.selection.isselectable

Set a callback for each data point to determine if it's selectable or not.


The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.

Default:
function () { return true; }
Format:
data: {
  selection: {
    isselectable: function (d) { ... }
  }
}

data.stack.normalize

Set the stacking to be normalized


For stacking, the `data.groups` option should be set and have positive values. The yAxis will be set in percentage value (0 ~ 100%).

Default:
false
Format:
data: {
  stack: {
    normalize: true
  }
}

data.onclick

Set a callback for click event on each data point.


This callback will be called when each data point clicked and will receive d and element as the arguments. d is the data clicked and element is the element clicked. In this callback, this will be the Chart object.

Default:
function () {}
Format:
data: {
  onclick: function (d, element) { ... }
}

data.onmouseover

Set a callback for mouseover event on each data point.


This callback will be called when mouse cursor moves onto each data point and will receive d as the argument. d is the data where mouse cursor moves onto. In this callback, this will be the Chart object.

Default:
function () {}
Format:
data: {
  onmouseover: function (d) { ... }
}

data.onmouseout

Set a callback for mouseout event on each data point.


This callback will be called when mouse cursor moves out each data point and will receive d as the argument. d is the data where mouse cursor moves out. In this callback, this will be the Chart object.

Default:
function () {}
Format:
data: {
  onmouseout: function (d) { ... }
}

data.onselected

not yet


data.onunselected

not yet


data.ondragstart

not yet


data.ondragend

not yet


axis.rotated

Switch x and y axis position.

Default:
false
Format:
axis: {
  rotated: true
}
Example:

axis.x.show

Show or hide x axis.

Default:
true
Format:
axis: {
  x: {
    show: true
  }
}

axis.x.type

Set type of x axis.

Available Values
  • timeseries
  • category
  • indexed
Default:
indexed
Format:
axis: {
  x: {
    type: 'timeseries'
  }
}
Example:

axis.x.localtime

Set how to treat the timezone of x values.


If true, treat x value as localtime. If false, convert to UTC internally.

Default:
true
Format:
axis: {
  x: {
    localtime: true
  }
}
Example:

axis.x.categories

Set category names on category axis.


This must be an array that includes category names in string. If category names are included in the date by data.x option, this is not required.

Default:
[]
Format:
axis: {
  x: {
    categories: ['Category 1', 'Category 2', ...]
  }
}
Example:

axis.x.tick.centered

Centerise ticks on category axis.

Default:
false
Format:
axis: {
  x: {
    tick: {
      centered: true
    }
  }
}

axis.x.tick.format

A function to format tick value. Format string is also available for timeseries data.

Default:
undefined
Format:
axis: {
  x: {
    tick: {
      format: function (x) { return x.getFullYear(); }
    }
  }
}

axis.x.tick.culling

Setting for culling ticks.


If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.


We can change the number of ticks to be shown by axis.x.tick.culling.max.

Default:
  • true for indexed axis and timeseries axis
  • false for category axis
Format:
axis: {
  x: {
    tick: {
      culling: false
    }
  }
}
Example:

axis.x.tick.culling.max

The number of tick texts will be adjusted to less than this value.

Default:
10
Format:
axis: {
  x: {
    tick: {
      culling: {
        max: 5
      }
    }
  }
}
Example:

axis.x.tick.count

The number of x axis ticks to show.


This option hides tick lines together with tick text. If this option is used on timeseries axis, the ticks position will be determined precisely and not nicely positioned (e.g. it will have rough second value).

Default:
undefined
Format:
axis: {
  x: {
    tick: {
      count: 5
    }
  }
}
Example:

axis.x.tick.fit

Fit x axis ticks.


If true set, the ticks will be positioned nicely. If false set, the ticks will be positioned according to x value of the data points.

Default:
true
Format:
axis: {
  x: {
    tick: {
      fit: true
    }
  }
}
Example:

axis.x.tick.values

Set the x values of ticks manually.


If this option is provided, the position of the ticks will be determined based on those values. This option works with timeseries data and the x values will be parsed accoding to the type of the value and data.xFormat option.

Default:
null
Format:
axis: {
  x: {
    tick: {
      values: [1, 2, 4, 8, 16, 32, ...]
    }
  }
}
Example:

axis.x.tick.rotate

Rotate x axis tick text.


If you set negative value, it will rotate to opposite direction.

Default:
0
Format:
axis: {
  x: {
    tick: {
      rotate: 60
    }
  }
}
Example:

axis.x.tick.outer

Show x axis outer tick.

Default:
true
Format:
axis: {
  x: {
    tick: {
      outer: false
    }
  }
}

axis.x.tick.multiline

Enable multiline.


If this option is set true, when a tick's text on the x-axis is too long, it splits the text into multiple lines in order to avoid text overlapping.

Default:
true
Format:
axis: {
  x: {
    tick: {
     multiline: true
   }
  }
}

axis.x.tick.multilineMax

If this option is set and is above 0, the number of lines will be adjusted to less than this value and tick's text is ellipsified.


Default:
0
Format:
axis: {
  x: {
    tick: {
     multiline: true,
     multilineMax: 2,
   }
  }
}

axis.x.tick.width

not yet


axis.x.max

Set max value of x axis range.

Default:
undefined
Format:
axis: {
  x: {
    max: 100
  }
}

axis.x.min

Set min value of x axis range.

Default:
undefined
Format:
axis: {
  x: {
    min: -100
  }
}

axis.x.padding

Set padding for x axis.


If this option is set, the range of the x axis will increase/decrease by the values. If no padding is needed for the x axis, set the values to 0. This option is ignored when the axis type is category.

Default:
{}
Format:
axis: {
  x: {
    padding: {
      left: 0,
      right: 0
    }
  }
}

axis.x.height

Set height of x axis.


The height of x axis can be set manually by this option. If you need more space for x axis, please use this option for that. The unit is pixel.

Default:
undefined
Format:
axis: {
  x: {
    height: 20
  }
}

axis.x.extent

Set default extent for subchart and zoom. This can be an array or function that returns an array.

Default:
undefined
Format:
axis: {
  x: {
    extent: [5, 10]
  }
}

axis.x.label

Set label on x axis.


You can set x axis label and change its position by this option. string and object can be passed and we can change the position by passing object that has position key. Available position differs according to the axis direction (vertical or horizontal). If string set, the position will be the default.


If it's horizontal axis:

  • inner-right [default]
  • inner-center
  • inner-left
  • outer-right
  • outer-center
  • outer-left

If it's vertical axis:

  • inner-top [default]
  • inner-middle
  • inner-bottom
  • outer-top
  • outer-middle
  • outer-bottom
Default:
undefined
Format:
axis: {
  x: {
    label: 'Your X Axis'
  }
}
axis: {
  x: {
    label: {
      text: 'Your X Axis',
      position: 'outer-center'
    }
  }
}
Example:

axis.y.show

Show or hide y axis.

Default:
true
Format:
axis: {
  y: {
    show: false
  }
}

axis.y.inner

Show y axis inside of the chart.

Default:
false
Format:
axis: {
  y: {
    inner: true
  }
}

axis.y.type

Scale type for Y axis.

Available Values:
  • linear
  • time¹
  • timeseries¹
  • log² Experimental

¹: The timeseries scale is an alias of time.

²: The log scale is experimental and may not work in all cases (stacked, etc.)

Default:
linear
Format:
axis: {
  y: {
    type: 'linear'
  }
}

axis.y.max

Set max value of y axis.

Note:

Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).

Default:
undefined
Format:
axis: {
  y: {
    max: 1000
  }
}
Example:

axis.y.min

Set min value of y axis.

Note:

Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).

Default:
undefined
Format:
axis: {
  y: {
    min: 1000
  }
}
Example:

axis.y.inverted

Change the direction of y axis.


If true set, the direction will be from the top to the bottom.

Default:
false
Format:
axis: {
  y: {
    inverted: true
  }
}

axis.y.center

Set center value of y axis.

Default:
undefined
Format:
axis: {
  y: {
    center: 0
  }
}

axis.y.label

Set label on y axis.


You can set y axis label and change its position by this option. This option works in the same way as axis.x.label.

Default:
undefined
Format:
axis: {
  y: {
    label: 'Your Y Axis'
  }
}
axis: {
  y: {
    label: {
      text: 'Your Y Axis',
      position: 'outer-middle'
    }
  }
}
Example:

axis.y.tick.format

Set formatter for y axis tick text.


This option accepts d3.format object as well as a function you define.

Default:
undefined
Format:
axis: {
  y: {
    tick: {
      format: d3.format('$,')
      //or format: function (d) { return '$' + d; }
    }
  }
}
Example:

axis.y.tick.outer

Show or hide outer tick.

Default:
undefined
Format:
axis: {
  y: {
    tick: {
      outer: false
    }
  }
}

axis.y.tick.values

Set y axis tick values manually.

Default:
undefined
Format:
axis: {
  y: {
    tick: {
      values: [100, 1000, 10000]
    }
  }
}

axis.y.tick.count

Set the number of y axis ticks.

Note:

The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely. In the case, axis.y.tick.format or axis.y.tick.values will be helpful.

Default:
undefined
Format:
axis: {
  y: {
    tick: {
      count: 5
    }
  }
}

axis.y.tick.time.value

not yet


axis.y.tick.time.interval

not yet


axis.y.padding

Set padding for y axis.


You can set padding for y axis to create more space on the edge of the axis. This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.

Default:
undefined
Format:
axis: {
  y: {
    padding: {
      top: 100,
      bottom: 100
    }
  }
}
Example:

axis.y.default

Set default range of y axis.


This option set the default value for y axis when there is no data on init.

Default:
undefined
Format:
axis: {
  y: {
    default: [0, 1000]
  }
}

axis.y2.show

Show or hide y2 axis.

Default:
false
Format:
axis: {
  y2: {
    show: true
  }
}

axis.y2.inner

Show y2 axis inside of the chart.

Default:
false
Format:
axis: {
  y2: {
    inner: true
  }
}

axis.y2.type

Scale type for Y2 axis.

Available Values:
  • linear
  • time¹
  • timeseries¹
  • log² Experimental

¹: The timeseries scale is an alias of time.

²: The log scale is experimental and may not work in all cases (stacked, etc.)

Default:
linear
Format:
axis: {
  y2: {
    type: 'linear'
  }
}

axis.y2.max

Set max value of y2 axis.

Default:
undefined
Format:
axis: {
  y2: {
    max: 1000
  }
}

axis.y2.min

Set min value of y2 axis.

Default:
undefined
Format:
axis: {
  y2: {
    min: -1000
  }
}

axis.y2.inverted

Change the direction of y2 axis.


If true set, the direction will be from the top to the bottom.

Default:
false
Format:
axis: {
  y2: {
    inverted: true
  }
}

axis.y2.center

Set center value of y2 axis.

Default:
undefined
Format:
axis: {
  y2: {
    center: 0
  }
}

axis.y2.label

Set label on y2 axis.


You can set y2 axis label and change its position by this option. This option works in the same way as axis.x.label.

Default:
undefined
Format:
axis: {
  y2: {
    label: 'Your Y2 Axis'
  }
}
axis: {
  y2: {
    label: {
      text: 'Your Y2 Axis',
      position: 'outer-middle'
    }
  }
}
Example:

axis.y2.tick.format

Set formatter for y axis tick text.


This option works in the same way as axis.y.format.

Default:
undefined
Format:
axis: {
  y2: {
    tick: {
      format: d3.format('$,')
      //or format: function (d) { return '$' + d; }
    }
  }
}

axis.y2.tick.outer

Show or hide y2 axis outer tick.

Default:
undefined
Format:
axis: {
  y2: {
    tick: {
      outer: false
    }
  }
}

axis.y2.tick.values

Set y2 axis tick values manually.

Default:
undefined
Format:
axis: {
  y2: {
    tick: {
      values: [100, 1000, 10000]
    }
  }
}

axis.y2.tick.count

Set the number of y2 axis ticks.

Note:

This works in the same way as axis.y.tick.count.

Default:
undefined
Format:
axis: {
  y2: {
    tick: {
      count: 5
    }
  }
}

axis.y2.padding

Set padding for y2 axis.


This works in the same way as axis.y.padding.

Default:
undefined
Format:
axis: {
  y2: {
    padding: {
      top: 100,
      bottom: 100
    }
  }
}

axis.y2.default

Set default range of y2 axis.


This option set the default value for y2 axis when there is no data on init.

Default:
undefined
Format:
axis: {
  y2: {
    default: [0, 1000]
  }
}

grid.x.show

Show grids along x axis.


Default:
false
Format:
grid: {
  x: {
    show: true
  }
}
Example:

grid.x.lines

Show additional grid lines along x axis.


This option accepts array including object that has value, text, position and class. text, position and class are optional. For position, start, middle and end (default) are available.

If x axis is category axis, value can be category name. If x axis is timeseries axis, value can be date string, Date object and unixtime integer.

Default:
[]
Format:
grid: {
  x: {
    lines: [
      {value: 2, text: 'Label on 2'},
      {value: 5, text: 'Label on 5', class: 'label-5'},
      {value: 6, text: 'Label on 6', position: 'start'}
    ]
  }
}
Example:

grid.y.show

Show grids along y axis.


Default:
false
Format:
grid: {
  y: {
    show: true
  }
}
Example:

grid.y.lines

Show additional grid lines along y axis.


This option accepts array including object that has value, text, position and class.

Default:
[]
Format:
grid: {
  y: {
    lines: [
      {value: 100, text: 'Label on 100'},
      {value: 200, text: 'Label on 200', class: 'label-200'},
      {value: 300, text: 'Label on 300', position: 'middle'}
    ]
  }
}
Example:

grid.y.ticks

not yet


regions

Show rectangles inside the chart.


This option accepts array including object that has axis, start, end and class. The keys start, end and class are optional.

axis must be x, y or y2. start and end should be the value where regions start and end. If not specified, the edge values will be used. If timeseries x axis, date string, Date object and unixtime integer can be used. If class is set, the region element will have it as class.

Default:
[]
Format:
regions: [
  {axis: 'x', start: 1, end: 4, class: 'region-1-4'}
]
Example:

legend.show

Show or hide legend.

Default:
true
Format:
legend: {
  show: true
}
Example:

legend.hide

Hide legend


If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.

Default:
false
Format:
legend: {
  hide: true
  //or hide: 'data1'
  //or hide: ['data1', 'data2']
}

legend.position

Change the position of legend.


Currently bottom, right and inset are supported.

Default:
bottom
Format:
legend: {
  position: 'bottom'
}
Example:

legend.inset

Change inset legend attributes.


This option accepts object that has the keys anchor, x, y and step.

anchor decides the position of the legend. These anchors are available:

  • top-left
  • top-right
  • bottom-left
  • bottom-right

x and y set the position of the legend based on the anchor.

step defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).

Default:
{
  anchor: 'top-left',
  x: 10,
  y: 0,
  step: undefined
}
Format:
legend: {
  inset: {
    anchor: 'top-right',
    x: 20,
    y: 10,
    step: 2
  }
}

legend.item.onclick

Set click event handler to the legend item.

Default:
undefined
Format:
legend: {
  item: {
    onclick: function (id) { ... }
  }
}
Example:

legend.item.onmouseover

Set mouseover event handler to the legend item.

Default:
undefined
Format:
legend: {
  item: {
    onmouseover: function (id) { ... }
  }
}
Example:

legend.item.onmouseout

Set mouseout event handler to the legend item.

Default:
undefined
Format:
legend: {
  item: {
    onmouseout: function (id) { ... }
  }
}
Example:

tooltip.show

Show or hide tooltip.

Default:
true
Format:
tooltip: {
  show: false
}
Example:

tooltip.grouped

Set if tooltip is grouped or not for the data points.

Default:
true
Format:
tooltip: {
  grouped: false
}
Example:

tooltip.format.title

Set format for the title of tooltip.


Specified function receives x and index of the data point to show.

Default:
undefined
Format:
tooltip: {
  format: {
    title: function (x, index) { return 'Data ' + x; }
  }
}
Example:

tooltip.format.name

Set format for the name of each data in tooltip.


Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.

Default:
undefined
Format:
tooltip: {
  format: {
    name: function (name, ratio, id, index) { return name; }
  }
}
Example:

tooltip.format.value

Set format for the value of each data in tooltip.


Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.

If undefined returned, the row of that value will be skipped.

Default:
undefined
Format:
tooltip: {
  format: {
    value: function (value, ratio, id, index) { return ratio; }
  }
}
Example:

tooltip.position

Set custom position for the tooltip.


This option can be used to modify the tooltip position by returning object that has top and left.

Default:
undefined
Format:
tooltip: {
  position: function (data, width, height, element) {
    return {top: 0, left: 0};
  }
}
Reference:

tooltip.contents

Set custom HTML for the tooltip.


Specified function receives data, defaultTitleFormat, defaultValueFormat and color of the data point to show. If tooltip.grouped is true, data includes multiple data points.

Default:
undefined
Format:
tooltip: {
  contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
    return ... // formatted html as you want
  }
}

tooltip.horizontal

Show the tooltips based on the horizontal position of the mouse.

Default:
undefined
Format:
tooltip: {
  horizontal: true
}
Example:

subchart.show Experimental

Show sub chart on the bottom of the chart.

Default:
false
Format:
subchart: {
  show: true
}
Example:

subchart.size.height Experimental

Change the height of the subchart.

Default:
undefined
Format:
subchart: {
  size: {
    height: 20
  }
}

subchart.onbrush Experimental

Set callback for brush event.


Specified function receives the current zoomed x domain.

Default:
undefined
Format:
subchart: {
  onbrush: function (domain) { ... }
}

subchart.axis.x.show Experimental

Show or hide x axis of subchart.

Default:
true
Format:
subchart: {
  axis: {
    x: {
      show: true
    }
  }
}

zoom.enabled Experimental

Enable zooming.

Default:
false
Format:
zoom: {
  enabled: false
}
Example:

zoom.type Experimental

There are two types of zoom behavior: 'scroll' and 'drag'

Default:
'scroll'
Format:
zoom: {
  type: 'drag'
}
Example:

zoom.rescale Experimental

Enable to rescale after zooming.


If true set, y domain will be updated according to the zoomed region.

Default:
false
Format:
zoom: {
  rescale: true
}

zoom.extent Experimental

Change zoom extent.

Default:
[1, 10]
Format:
zoom: {
  extent: [1, 100] // enable more zooming
}

zoom.onzoom Experimental

Set callback that is called when the chart is zooming.


Specified function receives the zoomed domain.

Default:
undefined
Format:
zoom: {
  onzoom: function (domain) { ... }
}

zoom.onzoomstart Experimental

Set callback that is called when zooming starts.


Specified function receives the zoom event.

Default:
undefined
Format:
zoom: {
  onzoomstart: function (event) { ... }
}

zoom.onzoomend Experimental

Set callback that is called when zooming ends.


Specified function receives the zoomed domain.

Default:
undefined
Format:
zoom: {
  onzoomend: function (domain) { ... }
}

zoom.disableDefaultBehavior Experimental

Disable the default animation of zoom. This option is useful when you want to get the zoomed domain by onzoom or onzoomend handlers and override the default animation behavior. See #2439 for details.

Default:
false
Format:
zoom: {
  enabled: true,
  disableDefaultBehavior: true,
  onzoomend: d => console.log(d)
}

point.show

Whether to show each point in line.

Default:
true
Format:
point: {
  show: false
}

point.r

The radius size of each point.

Default:
2.5
Format:
point: {
  r: 5
}

point.focus.expand.enabled

Whether to expand each point on focus.

Default:
true
Format:
point: {
  focus: {
    expand: {
      enabled: true
    }
  }
}

point.focus.expand.r

The radius size of each point on focus.

Default:
point.r * 1.75
Format:
point: {
  focus: {
    expand: {
      r: 1
    }
  }
}

point.select.r

The radius size of each point on selected.

Default:
point.r * 4
Format:
point: {
  select: {
    r: 3
  }
}

line.connectNull

Set if null data point will be connected or not.


If true set, the region of null data will be connected without any data point. If false set, the region of null data will not be connected and get empty.

Default:
false
Format:
line: {
  connectNull: true
}

line.step.type

Change step type for step chart.


step, step-before and step-after can be used.

Default:
'step'
Format:
line: {
  step: {
    type: 'step-after'
  }
}

area.zerobased

Set if min or max value will be 0 on area chart.

Default:
true
Format:
area: {
  zerobased: false
}

bar.width

Change the width of bar chart.

Default:
auto
Format:
bar: {
  width: 10
}
Example:

bar.width.ratio

Change the width of bar chart by ratio.

Default:
0.6
Format:
bar: {
  width: {
    ratio: 0.2
  }
}
Example:

bar.zerobased

Set if min or max value will be 0 on bar chart.

Default:
true
Format:
bar: {
  zerobased: false
}

pie.label.show

Show or hide label on each pie piece.

Default:
true
Format:
pie: {
  label: {
    show: false
  }
}

pie.label.format

Set formatter for the label on each pie piece.

Default:
undefined
Format:
pie: {
  label: {
    format: function (value, ratio, id) {
      return d3.format('$')(value);
    }
  }
}
Example:

pie.label.threshold

Set threshold to show/hide labels.

Default:
0.05
Format:
pie: {
  label: {
    threshold: 0.1
  }
}

pie.expand

Enable or disable expanding pie pieces.

Default:
true
Format:
pie: {
  expand: false
}

pie.padAngle

Sets the angular separation between each adjacent arc.

Default:
0
Format:
pie: {
  padAngle: .1
}

donut.label.show

Show or hide label on each donut piece.

Default:
true
Format:
donut: {
  label: {
    show: false
  }
}

donut.label.format

Set formatter for the label on each donut piece.

Default:
undefined
Format:
donut: {
  label: {
    format: function (value, ratio, id) {
      return d3.format('$')(value);
    }
  }
}

donut.label.threshold

Set threshold to show/hide labels.

Default:
0.05
Format:
donut: {
  label: {
    threshold: 0.1
  }
}

donut.expand

Enable or disable expanding donut pieces.

Default:
true
Format:
donut: {
  expand: false
}

donut.padAngle

Sets the angular separation between each adjacent arc.

Default:
0
Format:
donut: {
  padAngle: .1
}

donut.width

Set width of donut chart.

Default:
auto
Format:
donut: {
  width: 10
}

donut.title

Set title of donut chart.

Default:
''
Format:
donut: {
  title: 'Title'
}

gauge.label.show

Show or hide label on gauge.

Default:
true
Format:
gauge: {
  label: {
    show: false
  }
}

gauge.label.format

Set formatter for the label on gauge.

Default:
undefined
Format:
gauge: {
  label: {
    format: function (value, ratio) {
      return value;
    }
  }
}
Example:

gauge.expand

Enable or disable expanding gauge.

Default:
true
Format:
gauge: {
  expand: false
}

gauge.min

Set min value of the gauge.

Default:
0
Format:
gauge: {
  min: -100
}

gauge.max

Set max value of the gauge.

Default:
100
Format:
gauge: {
  max: 200
}

gauge.units

Set units of the gauge.

Default:
undefined
Format:
gauge: {
  units: ' %'
}

gauge.width

Set width of gauge chart.

Default:
auto
Format:
gauge: {
  width: 10
}

spline.interpolation.type

Set type of curve interpolation.

Default:
cardinal

Available interpolation are:

  • linear
  • linear-closed
  • basis
  • basis-open
  • basis-closed
  • bundle
  • cardinal [default]
  • cardinal-open
  • cardinal-closed
  • monotone
  • step
  • step-before
  • step-after
Format:
interpolation: {
  type: "monotone"
}

stanford.scaleMin

Change the minimum value of the stanford color scale.

Default:
auto
Format:
stanford: {
  scaleMin: 1
}
Example:

stanford.scaleMax

Change the maximum value of the stanford color scale.

Default:
auto
Format:
stanford: {
  scaleMax: 10000
}
Example:

stanford.scaleWidth

Change the width of the stanford color scale.

Default:
20
Format:
stanford: {
  scaleWidth: 20
}
Example:

stanford.scaleFormat

Set formatter for stanford color scale axis tick text.


This option accepts the string 'pow10', a d3.format object and any function you define.

Default:
d3.format("d") - decimal notation, rounded to integer
Format:
stanford: {
  scaleFormat: 'pow10'
  // or d3.format("d")
  // or a function
}
Example:

stanford.scaleValues

Set the values for stanford color scale axis tick text.


This option accepts a function that returns an array of numbers.

Default:
undefined
Format:
stanford: {
  scaleValues: (minValue, maxValue) => {
    const step = (maxValue - minValue) / 10;
    return d3.range(minValue, maxValue + step, step);
  }
}
Example:

stanford.colors

Set the color interpolator for stanford color scale.


This option is a d3.interpolate* object or any function you define that receives a value between 0 and 1, and returns a color as string.

Default:
d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5))
Format:
stanford: {
  colors: d3.interpolatePlasma
}
Example:

stanford.padding

Set the padding for the stanford color scale.

This option accepts array including object that has top, right, bottom and left.

Default:
undefined
Format:
stanford: {
  padding: {
    top: 15,
    right: 0,
    bottom: 0,
    left: 0
  }
}
Example:

stanford.texts

Show text anywhere inside the chart.


This option accepts array including object that has x, y, content and class. The key class is optional.

x and y are the starting position of the text, content is the text content to show. If class is set, the text element will have it as class.

Default:
[]
Format:
stanford: {
  texts: [
    {x: 1, y: 4, content: 'my custom text here', class: 'text-1-4'}
  ]
}

stanford.lines

Show lines anywhere inside the chart.


This option accepts array including object that has value_x1, value_y1, value_x2, value_y2 and class. The key class is optional.

value_x1 and value_y1 are the starting position of the line, value_x2 and value_y2 are the ending position of the line. If class is set, the line element will have it as class.

Default:
[]
Format:
stanford: {
  lines: [
    {value_x1: 0, value_y1: 0, value_x2: 65, value_y2: 65, class: "line-0-65"}
  ]
}

stanford.regions

Show regions anywhere inside the chart.


This option accepts array including object that has points, text, opacity and class. The keys text, opacity and class are optional.

points accepts array including object that has x and y that represent the coordinates of each point.

text accepts function that returns a string with the text to show. If the current chart type is stanford the function receives value and percentage as parameters that represent the number of points in this region.

opacity accepts a number between 0 and 1, the default opacity is 0.2.

If class is set, the line element will have it as class.

Note:

Points should be added in a counter-clockwise direction to close the polygon.

Default:
[]
Format:
stanford: {
  regions: [
    {
      points: [ // add points counter-clockwise
        {x: 0, y: 0},
        {x: 40, y: 40},
        {x: 0, y: 40}
      ],
      text: function (value, percentage) {
        return "Normal Operations: " + value + " (" + percentage + "%)";
      },
      opacity: 0.2, // 0 to 1
      class: "region-triangle-1"
    }
  ]
}


API


focus

This API highlights specified targets and fade out the others.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be highlighted.

Arguments:
.focus(targetIds)

targetIds  String or Array

Target ids to be highlighted.

Example:
// data1 will be highlighted and the others will be faded out
chart.focus('data1');

// data1 and data2 will be highlighted and the others will be faded out
chart.focus(['data1', 'data2']);

// all targets will be highlighted
chart.focus();

defocus

This API fades out specified targets and reverts the others.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be faded out.

Arguments:
.defocus(targetIds)

targetIds  String or Array

Target ids to be faded out.

Example:
// data1 will be faded out and the others will be reverted.
chart.defocus('data1');

// data1 and data2 will be faded out and the others will be reverted.
chart.defocus(['data1', 'data2']);

// all targets will be faded out.
chart.defocus();

revert

This API reverts specified targets.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be reverted.

Arguments:
.revert(targetIds)

targetIds  String or Array

Target ids to be reverted.

Example:
// data1 will be reverted.
chart.revert('data1');

// data1 and data2 will be reverted.
chart.revert(['data1', 'data2']);

// all targets will be reverted.
chart.revert();

show

This API shows specified targets.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be shown.

Arguments:
.show(targetIds, options)

targetIds  String or Array

Target ids to be shown.


options  Object

If withLegend is set true, legend will be shown together with the specified data.

Example:
// data1 will be shown.
chart.show('data1');

// data1 and data2 will be shown.
chart.show(['data1', 'data2']);

// all targets will be shown.
chart.show();

// data1 will be shown together with its legend.
chart.show('data1', {withLegend: true});

hide

This API hides specified targets.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be hidden.

Arguments:
.hide(targetIds, options)

targetIds  String or Array

Target ids to be hidden.


options  Object

If withLegend is set true, legend will be hidden together with the specified data.

Example:
// data1 will be hidden.
chart.hide('data1');

// data1 and data2 will be hidden.
chart.hide(['data1', 'data2']);

// all targets will be hidden.
chart.hide();

// data1 will be hidden together with its legend.
chart.hide('data1', {withLegend: true});

toggle

This API toggles (shows or hides) specified targets.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be toggles.

Arguments:
.toggle(targetIds, options)

targetIds  String or Array

Target ids to be toggled.


options  Object

If withLegend is set true, legend will be toggled together with the specified data.

Example:
// data1 will be toggled.
chart.toggle('data1');

// data1 and data2 will be toggled.
chart.toggle(['data1', 'data2']);

// all targets will be toggled.
chart.toggle();

// data1 will be toggled together with its legend.
chart.toggle('data1', {withLegend: true});

load

Load data to the chart.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be toggles.

Arguments:
.load(args)

args  Object

If url, json, rows and columns given, the data will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added.


If classes given, the classes specified by data.classes will be updated. classes must be Object that has target id as keys.


If categories given, the categories specified by axis.x.categories or data.x will be updated. categories must be Array.


If axes given, the axes specified by data.axes will be updated. axes must be Object that has target id as keys.


If colors given, the colors specified by data.colors will be updated. colors must be Object that has target id as keys.


If type or types given, the type of targets will be updated. type must be String and types must be Object.


If unload given, data will be unloaded before loading new data. If true given, all of data will be unloaded. If target ids given as String or Array, specified targets will be unloaded.


If done given, the specified function will be called after data loded.

Note:

unload should be used if some data needs to be unloaded simultaneously. If you call unload API soon after/before load instead of unload param, chart will not be rendered properly because of cancel of animation.


done will be called after data loaded, but it's not after rendering. It's because rendering will finish after some transition and there is some time lag between loading and rendering.

Example:
// Load data1 and unload data2 and data3
chart.load({
  columns: [
    ['data1', 100, 200, 150, ...],
    ...
  ],
  unload: ['data2', 'data3']
});

unload

Unload data to the chart.


You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be toggles.

Arguments:
.unload(args)

args  Object

If ids given, the data that has specified target id will be unloaded. ids should be String or Array. If ids is not specified, all data will be unloaded.


If done given, the specified function will be called after data loded.

Note:

If you call load API soon after/before unload, unload param of load should be used. Otherwise chart will not be rendered properly because of cancel of animation.


done will be called after data loaded, but it's not after rendering. It's because rendering will finish after some transition and there is some time lag between loading and rendering.

Example:
// Unload data2 and data3
chart.unload({
  ids: ['data2', 'data3']
});

flow

Flow data to the chart.


By this API, you can append new data points to the chart.

Arguments:
.flow(args)

args  Object

If json, rows and columns given, the data will be loaded. If data that has the same target id is given, the chart will be appended. Otherwise, new target will be added. One of these is required when calling. If json specified, keys is required as well as data.json


If to is given, the lower x edge will move to that point. If not given, the lower x edge will move by the number of given data points.


If length is given, the lower x edge will move by the number of this argument.


If duration is given, the duration of the transition will be specified value. If not given, transition.duration will be used as default.


If done is given, the specified function will be called when flow ends.

Example:
// 2 data points will be apprended to the tail and popped from the head.
// After that, 4 data points will be appended and no data points will be poppoed.
chart.flow({
  columns: [
    ['x', '2013-01-11', '2013-01-21'],
    ['data1', 500, 200],
    ['data2', 100, 300],
    ['data3', 200, 120]
  ],
  done: function () {
    chart.flow({
      columns: [
        ['x', '2013-02-11', '2013-02-12', '2013-02-13', '2013-02-14'],
        ['data1', 200, 300, 100, 250],
        ['data2', 100, 90, 40, 120],
        ['data3', 100, 100, 300, 500]
      ],
      length: 0
    });
  }
});

select

Change data point state to selected.


By this API, you can select data points. To use this API, data.selection.enabled needs to be set true.

Arguments:
.select(ids, indices, resetOthers)

ids  Array

Specify target ids to be selected. If this argument is not given, all targets will be the candidate.


indices  Array

Specify indices to be selected. If this argument is not given, all data points will be the candidate.


resetOthers  boolean

If this argument is set true, the data points that are not specified by ids, indices will be unselected.

Example:
// all data points of data1 will be selected.
chart.select(['data1']);

// 3 data points on index 1, 3, 5 of data1 will be selected.
chart.select(['data1'], [1,3,5]);

unselect

Change data point state to unselected.


By this API, you can unselect data points. To use this API, data.selection.enabled needs to be set true.

Arguments:
.unselect(ids, indices)

ids  Array

Specify target ids to be unselected. If this argument is not given, all targets will be the candidate.


indices  Array

Specify indices to be unselected. If this argument is not given, all data points will be the candidate.

Example:
// all data points of data1 will be unselected.
chart.unselect(['data1']);

// 3 data points on index 1, 3, 5 of data1 will be unselected.
chart.unselect(['data1'], [1,3,5]);

selected

Get selected data points.


By this API, you can get selected data points information. To use this API, data.selection.enabled needs to be set true.

Arguments:
.selected(targetId)

targetId  String

You can filter the result by giving target id that you want to get. If not given, all of data points will be returned.

Example:
// all selected data points will be returned.
chart.selected();

// all selected data points of data1 will be returned.
chart.selected('data1');

transform

Change the type of the chart.

Arguments:
.transform(type, targetIds)

type  String

Specify the type to be transformed. The types listed in data.type can be used.


targetIds  String or Array

Specify targets to be transformed. If not given, all targets will be the candidate.

Example:
// all targets will be bar chart.
chart.transform('bar');

// only data1 will be bar chart.
chart.transform('bar', 'data1');

// only data1 and data2 will be bar chart.
chart.transform('bar', ['data1', 'data2']);

groups

Update groups for the targets.

Arguments:
.groups(groups)

groups  Array

This argument needs to be an Array that includes one or more Array that includes target ids to be grouped.

Example:
// data1 and data2 will be a new group.
chart.groups([['data1', 'data2']]);

xgrids

Update x grid lines.

Arguments:
.xgrids(grids)

grids  Array

X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.

Example:
// Show 2 x grid lines
chart.xgrids([
  {value: 1, text:'Label 1'},
  {value: 4, text: 'Label 4'}
]);

xgrids.add

Add x grid lines.


This API adds new x grid lines instead of replacing like xgrids.

Arguments:
.xgrids.add(grids)

grids  Array or Object

New x grid lines will be added. The format of this argument is the same as grid.x.lines and it's possible to give an Object if only one line will be added.

Example:
// Add a new x grid line
chart.xgrids.add(
  {value: 4, text: 'Label 4'}
);

// Add new x grid lines
chart.xgrids.add([
  {value: 2, text: 'Label 2'},
  {value: 4, text: 'Label 4'}
]);

xgrids.remove

Remove x grid lines.


This API removes x grid lines.

Arguments:
.xgrids.remove(args)

args  Object

This argument should include value or class. If value is given, the x grid lines that have specified x value will be removed. If class is given, the x grid lines that have specified class will be removed. If args is not given, all of x grid lines will be removed.

Example:
// x grid line on x = 2 will be removed
chart.xgrids.remove({value: 2});

// x grid lines that have 'grid-A' will be removed
chart.xgrids.remove({class: 'grid-A'});

// all of x grid lines will be removed
chart.xgrids.remove();

ygrids

Update y grid lines.

Arguments:
.ygrids(grids)

grids  Array

X grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines.

Example:
// Show 2 y grid lines
chart.ygrids([
  {value: 100, text:'Label 1'},
  {value: 400, text: 'Label 4'}
]);

ygrids.add

Add y grid lines.


This API adds new y grid lines instead of replacing like ygrids.

Arguments:
.ygrids.add(grids)

grids  Array or Object

New y grid lines will be added. The format of this argument is the same as grid.y.lines and it's possible to give an Object if only one line will be added.

Example:
// Add a new y grid line
chart.ygrids.add(
  {value: 400, text: 'Label 4'}
);

// Add new y grid lines
chart.ygrids.add([
  {value: 200, text: 'Label 2'},
  {value: 400, text: 'Label 4'}
]);

ygrids.remove

Remove y grid lines.


This API removes y grid lines.

Arguments:
.ygrids.remove(args)

args  Object

This argument should include value or class. If value is given, the y grid lines that have specified y value will be removed. If class is given, the y grid lines that have specified class will be removed. If args is not given, all of y grid lines will be removed.

Example:
// y grid line on y = 200 will be removed
chart.ygrids.remove({value: 200});

// y grid lines that have 'grid-A' will be removed
chart.ygrids.remove({class: 'grid-A'});

// all of y grid lines will be removed
chart.ygrids.remove();

regions

Update regions.

Arguments:
.regions(regions)

regions  Array

Regions will be replaced with this argument. The format of this argument is the same as regions.

Example:
// Show 2 regions
chart.regions([
  {axis: 'x', start: 5, class: 'regionX'},
  {axis: 'y', end: 50, class: 'regionY'}
]);

regions.add

Add new region.


This API adds new region instead of replacing like regions.

Arguments:
.regions.add(regions)

regions  Array or Object

New region will be added. The format of this argument is the same as regions and it's possible to give an Object if only one region will be added.

Example:
// Add a new region
chart.regions.add(
  {axis: 'x', start: 5, class: 'regionX'}
);

// Add new regions
chart.regions.add([
  {axis: 'x', start: 5, class: 'regionX'},
  {axis: 'y', end: 50, class: 'regionY'}
]);

regions.remove

Remove regions.


This API removes regions.

Arguments:
.regions.remove(args)

args  Object

This argument should include classes. If classes is given, the regions that have one of the specified classes will be removed. If args is not given, all of regions will be removed.

Example:
// regions that have 'region-A' or 'region-B' will be removed.
chart.regions.remove({classes: ['region-A', 'region-B']});

// all of regions will be removed.
chart.regions.remove();

data

Get data loaded in the chart.

Arguments:
.data(targetIds)

targetIds  String or Array

If this argument is given, this API returns the specified target data. If this argument is not given, all of data will be returned.

Example:
// Get only data1 data
chart.data('data1');

// Get data1 and data2 data
chart.data(['data1', 'data2']);

// Get all data
chart.data();

data.shown

Get data shown in the chart.

Arguments:
.data.shown(targetIds)

targetIds  String or Array

If this argument is given, this API filters the data with specified target ids. If this argument is not given, all shown data will be returned.

Example:
// Get shown data by filtering to include only data1 data
chart.data.shown('data1');

// Get shown data by filtering to include data1 and data2 data
chart.data.shown(['data1', 'data2']);

// Get all shown data
chart.data.shown();

data.values

Get values of the data loaded in the chart.

Arguments:
.data.values(targetId)

targetId  String

This API returns the values of specified target. If this argument is not given, null will be retruned.

Example:
// Get data1 values
chart.data.values('data1');

data.names

Get and set names of the data loaded in the chart.

Arguments:
.data.names(names)

names  Object

If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as data.names.

Example:
// Get current names
chart.data.names();

// Update names
chart.data.names({
  data1: 'New Name 1',
  data2: 'New Name 2'
});

data.colors

Get and set colors of the data loaded in the chart.

Arguments:
.data.colors(colors)

colors  Object

If this argument is given, the colors of data will be updated. If not given, the current colors will be returned. The format of this argument is the same as data.colors.

Example:
// Get current colors
chart.data.colors();

// Update colors
chart.data.colors({
  data1: '#FFFFFF',
  data2: '#000000'
});

data.axes

Get and set axes of the data loaded in the chart.

Arguments:
.data.axes(axes)

axes  Object

If this argument is given, the axes of data will be updated. If not given, the current axes will be returned. The format of this argument is the same as data.axes.

Example:
// Get current axes
chart.data.axes();

// Update axes
chart.data.axes({
  data1: 'y',
  data2: 'y2'
});

x

Get and set x values for the chart.

Arguments:
.x(x)

x  Array

If x is given, x values of every target will be updated. If no argument is given, current x values will be returned as an Object whose keys are the target ids.

Example:
// Get current x values
chart.x();

// Update x values for all targets
chart.x([100, 200, 300, 400, ...]);

xs

Get and set x values for the chart.

Arguments:
.xs(xs)

xs  Object

If xs is given, specified target's x values will be updated. If no argument is given, current x values will be returned as an Object whose keys are the target ids.

Example:
// Get current x values
chart.xs();

// Update x values for all targets
chart.xs({
  data1: [10, 20, 30, 40, ...],
  data2: [100, 200, 300, 400, ...]
});

axis.labels

Get and set axis labels.

Arguments:
.axis.labels(labels)

labels  Object

If labels is given, specified axis' label will be updated.

Example:
// Update axis' label
chart.axis.labels({
  x: 'New X Axis Label',
  y: 'New Y Axis Label'
});

axis.min

Get and set axis min value.

Arguments:
.axis.min(min)

min  Object

If min is given, specified axis' min value will be updated. If no argument is given, the current min values for each axis will be returned.

Example:
// Update axis' min
chart.axis.min({
  x: -10,
  y: 1000,
  y2: 100
});

axis.max

Get and set axis max value.

Arguments:
.axis.max(max)

max  Object

If max is given, specified axis' max value will be updated. If no argument is given, the current max values for each axis will be returned.

Example:
// Update axis' max
chart.axis.max({
  x: 100,
  y: 1000,
  y2: 10000
});

axis.range

Get and set axis min and max value.

Arguments:
.axis.range(range)

range  Object

If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.

Example:
// Update axis' min and max values
chart.axis.range({
  min: {
    x: -10,
    y: -1000,
    y2: -10000
  },
  max: {
    x: 100,
    y: 1000,
    y2: 10000
  }
});

axis.types

Get and set axis y/y2 types.

Arguments:
.axis.types(types)

types  Object

If types is given, specified axis' type value will be updated. If no argument is given, the current types for y/y2 axis will be returned.

Example:
// Update axis' types
chart.axis.types({
  y: 'linear',
  y2: 'log'
});

legend.show

Show legend for each target.

Arguments:
.legend.show(targetIds)

targetIds  Array or String

If targetIds is given, specified target's legend will be shown. If only one target is the candidate, String can be passed. If no argument is given, all of target's legend will be shown.

Example:
// Show legend for data1.
chart.legend.show('data1');

// Show legend for data1 and data2.
chart.legend.show(['data1', 'data2']);

// Show all legend.
chart.legend.show();

legend.hide

Hide legend for each target.

.legend.hide(targetIds)

targetIds  Array or String

If targetIds is given, specified target's legend will be hidden. If only one target is the candidate, String can be passed. If no argument is given, all of target's legend will be hidden.

Example:
// Hide legend for data1.
chart.legend.hide('data1');

// Hide legend for data1 and data2.
chart.legend.hide(['data1', 'data2']);

// Hide all legend.
chart.legend.hide();

subchart.isShown

Returns true if the sub chart is shown.

Example:
if (chart.subchart.isShown()) {
  // Sub chart is shown
}

subchart.show

Shows sub chart at the bottom of the chart.

Example:
// Show sub chart
chart.subchart.show();

subchart.hide

Hides sub chart.

Example:
// Hide sub chart
chart.subchart.hide();

zoom

Zoom by giving x domain.

Arguments:
.zoom(domain)

domain  Array

If domain is given, the chart will be zoomed to the given domain. If no argument is given, the current zoomed domain will be returned.

Example:
// Zoom to specified domain
chart.zoom([10, 20]);

// Get the current zoomed domain
chart.zoom();

unzoom

Unzoom to the original domain.

Arguments:
.unzoom()
Example:
// Unzoom to the original domain
chart.unzoom();

zoom.enable

Enable and disable zooming.

Arguments:
.zoom.enable(enabled)

enabled  Boolean

If enabled is true, the feature of zooming will be enabled. If false is given, it will be disabled.

Example:
// Enable zooming
chart.zoom.enable(true);

resize

Resize the chart.

Arguments:
.resize(size)

size  Object

This argument should include width and height in pixels.

Example:
// Resize to 640x480
chart.resize({
  height: 640,
  width: 480
});

flush

Force to redraw.

Arguments:
.flush()
Example:
// Force to redraw
chart.flush();

destroy

Reset the chart object and remove element and events completely.

Arguments:
.destroy()
Example:
// Destroy the chart
chart.destroy();

// If you have a reference to the chart make sure to call destroy in the following manner
chart = chart.destroy();


CLASS


c3-chart

...


c3-chart-line

...


c3-chart-lines

...


c3-chart-bar

...


c3-chart-bars

...


c3-chart-text

...


c3-chart-texts

...


c3-chart-arc

...


c3-chart-arcs

...


c3-chart-arcs-title

...


c3-chart-arcs-background

...


c3-chart-arcs-gauge-unit

...


c3-chart-arcs-gauge-max

...


c3-chart-arcs-gauge-min

...


c3-selected-circle

...


c3-selected-circles

...


c3-event-rect

...


c3-event-rects

...


c3-event-rects-single

...


c3-event-rects-multiple

...


c3-zoom-rect

...


c3-brush

...


c3-focused

...


c3-region

...


c3-regions

...


c3-tooltip

...


c3-tooltip-name

...


c3-shape

...


c3-shapes

...


c3-line

...


c3-lines

...


c3-bar

...


c3-bars

...


c3-circle

...


c3-circles

...


c3-arc

...


c3-arcs

...


c3-area

...


c3-areas

...


c3-empty

...


c3-text

...


c3-texts

...


c3-gauge-value

...


c3-grid

...


c3-xgrid

...


c3-xgrids

...


c3-xgrid-line

...


c3-xgrid-lines

...


c3-xgrid-focus

...


c3-ygrid

...


c3-ygrids

...


c3-ygrid-line

...


c3-ygrid-lines

...


c3-stanford-elements

...


c3-stanford-line

...


c3-stanford-lines

...


c3-stanford-region

...


c3-stanford-regions

...


c3-stanford-text

...


c3-stanford-texts

...


c3-axis

...


c3-axis-x

...


c3-axis-x-label

...


c3-axis-y

...


c3-axis-y-label

...


c3-axis-y2

...


c3-axis-y2-label

...


c3-legend-item

...


c3-legend-item-event

...


c3-legend-item-tile

...


c3-legend-item-hidden

...


c3-legend-item-focused

...