bb

bb

Source:
Version:
  • 3.2.2

Members

(static) instance

Source:
Properties:
Name Type Description
instance Array

instance array

An array containing instance created

Example
// generate charts
 var chart1 = bb.generate(...);
 var chart2 = bb.generate(...);

 bb.instance;  // [ chart1, chart2, ... ]

(static) plugin

Source:
Properties:
Name Type Description
plugin object

plugin namespace

Namespace for plugins

Example
// Stanford diagram plugin
 bb.plugin.stanford;

(static) version

Source:
Properties:
Name Type Description
version string

version

Version information

Example
bb.version;  // "1.0.0"

Methods

(static) defaults(options) → {Options}

Source:
See:

Set or get global default options.

  • NOTE:
    • The options values settings are valid within page context only.
    • If is called multiple times, will override the last value.
Example
// Set same option value as for `.generate()`
bb.defaults({
  data: {
    type: "bar"
  }
});

bb.defaults();  // {data:{type: "bar"}}

// data.type defaults to 'bar'
var chart = bb.generate({ ... });
Parameters:
Name Type Description
options Options

chart options

Returns:
Type
Options

(static) generate(config) → {Chart}

Source:
See:
  • Options for different generation options
  • Chart for different methods API

Generate chart

  • NOTE: Bear in mind for the possiblity of throwing an error, during the generation when:
    • Unused option value is given.
      • ex) For data.type="pie" option, setting 'axis' option can cause unexpected generation error.
    • Insufficient value is given for certain option used.
      • ex) data: { x: "x", columns: [["x"], ["data1", 30, 200, 100]] }
Examples
<!-- chart holder -->
<div id="LineChart"></div>
// Generate chart with options
 var chart = bb.generate({
     "bindto": "#LineChart"
     "data": {
         "columns": [
             ["data1", 30, 200, 100, 400, 150, 250],
             ["data2", 50, 20, 10, 40, 15, 25]
          ],
         "type": "line"
     }
 });

 // call some API
 // ex) get the data of 'data1'
 chart.data("data1");
// Generate chart by importing ESM
// Import types to be used only, where this will make smaller bundle size.
import bb, {
  area,
  areaLineRange,
  areaSpline,
  areaSplineRange,
  areaStep,
  bar,
  bubble,
  donut,
  gauge,
  line,
  pie,
  radar,
  scatter,
  spline,
  step
}

bb.generate({
     "bindto": "#LineChart"
     "data": {
         "columns": [
             ["data1", 30, 200, 100, 400, 150, 250],
             ["data2", 50, 20, 10, 40, 15, 25]
          ]
     },
     type: line(),

     // or
     types: {
       data1: bar(),
       data2: step()
     }
});
Parameters:
Name Type Description
config Options

chart options

Returns:
Type
Chart