chartbuilder

3.0.5
_applySettingsToData _handleStateUpdate _getPrevUndraggedNode ChartGrid_xScaleSettings #_handleDomainUpdate #_handleScaleUpdate _handlePropAndReparse _handlePropUpdate _handleStateUpdate Chartbuilder #_onChange config .breakpoints .chart_sizes .chart_style .default_input xy_config .display .xy_defaultProps #calculate_xy_dimensions #parseXY ChartConfig #calculateDimensions #parser chart_grid_config .chart_grid_defaultProps .display #chartGridDimensions #parseChartgrid Chartbuilder#getStateFromStores ChartbuilderDispatcher #handleServerAction #handleViewAction ChartEditorMixin ChartExport ChartGridEditor ChartMetadata ChartTypeSelctor DataInput DateScaleSettings NumericScaleSettings ScaleReset XY_yScaleSettings XYEditor RendererWrapper #ChartFooter #SvgRectLabel #SvgText ChartGrid_chartSettings ChartGrid_gridSettings ChartGrid_universalToggle ChartGridBars ChartGridXY ChartGridRenderer ChartRendererMixin XYRenderer ChartMetadataStore #clear #get #getAll ChartPropertiesStore #clear #get #getAll chartProps metadata chartProps metadata ChartServerActions .receiveModel ChartViewActions .updateAllChartProps .updateAndReparse .updateChartProp .updateInput .updateMetadata ErrorStore #clear #get #getAll helper .combine_margin_pading .compute_scale_domain .exact_ticks .merge_or_apply .precision .round_to_precision .suggest_tick_num .transform_coords .tz_offset_to_minutes .validate_chart_model editors renderers generate_scale SessionStore #get #getAll get_tick_widths LocalStorageTimer make_mults XY_chartSettings XY_resetLabels XYLabels

_applySettingsToData(_chartProps, additional)

src/js/components/mixins/ChartRendererMixin.js

_applySettingsToData Our d4 chart renderers expect any additional settings to be in the data that is passed to it, so we merge them in (from a separate chartSettings object). An optional additional parameter adds an arbitray object to this

Parameters

  • _chartProps :

    Current data and series settings

  • additional :

    Optional additional object to apply

Returns

object :

Data with settings applied

_handleStateUpdate(k, v)

src/js/components/mixins/ChartRendererMixin.js

_handleStateUpdate Update a key in the renderer component's state

Parameters

  • k :

    this.state key

  • v :

    this.state value

_getPrevUndraggedNode(ix, undraggedLabels)

src/js/components/chart-xy/XYRenderer.jsx

XYLabels#_getPrevUndraggedNode Recursively traverse through previous labels to find one that is undragged This is used to calculate the default placement of a label (ie to the right of the previous undragged node)

Parameters

  • number ix :

    The index of this undragged node in an array of undragged nodes

  • Array<object> undraggedLabels :

    Position and size settings for all undraggedlabels

ChartGrid_xScaleSettings

src/js/components/chart-grid/ChartGrid_xScaleSettings.jsx

Chart grid xScale settings parent component

Properties

_handlePropAndReparse(k, v)

src/js/components/mixins/ChartEditorMixin.js

_handlePropAndReparse Initiate a flux action that updates a prop and then triggers a reparse

Parameters

  • k :

    chartProp key

  • v :

    chartProp value

_handlePropUpdate(k, v)

src/js/components/mixins/ChartEditorMixin.js

_handlePropUpdate Initiate a flux action that updates a prop, that doesn't require reparsing

Parameters

  • k :

    chartProp key

  • v :

    chartProp value

_handleStateUpdate(k, v)

src/js/components/mixins/ChartEditorMixin.js

_handleStateUpdate Update a key in the editor component's state

Parameters

  • k :

    this.state key

  • v :

    this.state value

Chartbuilder

src/js/components/Chartbuilder.jsx

Chartbuilder parent component

Properties

config

src/js/config/chart-style.js

Global config not specific to a chart type

Static members

.breakpoints

Configuration of breakpoints for Chartbuilder renderers.

breakpoints

src/js/config/chart-breakpoints.js

Configuration of breakpoints for Chartbuilder renderers.

Properties

  • string class_name :

    Applied to the renderer at this break point

  • number min_size :

    Minimum value (most likely width) at which to apply this breakpoint

  • number em_size :

    Font size at this breakpoint. This is used to calculate relative positioning

.chart_sizes

Default dimensions for non-responsive chart sizes.

chart_sizes

src/js/config/chart-sizes.js

Default dimensions for non-responsive chart sizes.

.chart_style

Global style config that is not specific to any one chart type

chart_style

src/js/config/chart-style.js

Global style config that is not specific to any one chart type

Properties

  • Nem or number overtick_top
  • Nem or number overtick_bottom
  • number numColors
  • Nem or number xOvertick :

    Font size at this breakpoint. This is used to

  • Nem or number creditMargin :

    Distance btwn credit and the logo/text beside it

.default_input

Tabular data that is loaded in when Chartbuilder loads initially

default_input

src/js/config/default-input.js

Tabular data that is loaded in when Chartbuilder loads initially

xy_config

src/js/charts/cb-xy/xy-config.js

Configuration of an XY chart

Static members

.display

display

display

src/js/charts/cb-xy/xy-config.js

display

Properties

  • Nem or number labelRectSize :

    Size of the legend label rectangle

  • Nem or number labelXMargin :

    Horiz distance btwn labels

  • Nem or number labelTextMargin :

    Horiz distance btwn label rect and text

  • Nem or number labelRowHeight :

    Vert distance btwn rows of labels items with colors the appropriate indexed CSS class

  • Nem or number afterTitle :

    Distance btwn top of title and top of legend or chart

  • Nem or number afterLegend :

    Distance btwn top of legend and top of chart

  • Nem or number blockerRectOffset :

    Distance btwn text of axis and its background blocker

  • Nem or number columnPaddingCoefficient :

    Distance relative to width that column charts should be from edge of the chart

  • Nem or number minPaddingOuter :

    Minimum distance between the outside of a chart and a graphical element

  • Nem or number bottomPaddingWithoutFooter :

    Bottom padding if footer is not drawn

  • object aspectRatio
    • aspectRatio.wide number or fraction
    • aspectRatio.longSpot number or fraction
    • aspectRatio.smallSpot number or fraction
  • object margin :

    Distances btwn outer chart elements and container

  • object padding :

    Distances btwn inner chart elements and container

Instance members

#parseXY(config, _chartProps, callback, parseOpts)

parseXY(config, _chartProps, callback, parseOpts)

src/js/charts/cb-xy/parse-xy.js

see ChartConfig#parser

Parameters

  • config :
  • _chartProps :
  • callback :
  • parseOpts :

ChartConfig(settings)

src/js/charts/ChartConfig.js

Chart config

Set up a configuration object for a given chart type

Parameters

  • settings :

Properties

chart_grid_config

src/js/charts/cb-chart-grid/chart-grid-config.js

Configuration of a Chart grid

Static members

.display

display

display

src/js/charts/cb-chart-grid/chart-grid-config.js

display

Properties

  • Nem or number afterTitle :

    Distance btwn top of title and top of legend or chart

  • Nem or number afterLegend :

    Distance btwn top of legend and top of chart

  • Nem or number blockerRectOffset :

    Distance btwn text of axis and its background blocker

  • Nem or number paddingBerBar :

    Space btwn two bars in a bar grid

  • Nem or number barHeight :

    Height of an individual bar in a bar grid

  • Nem or number afterXYBottom :

    Vert distance btwn two chart grids that are stacked

  • Nem or number afterXYRight :

    Horiz distance btwn two chart grids that are next to each other

  • Nem or number columnExtraPadding :

    Extra padding given if a chart grid XY has columns

  • Nem or number bottomPaddingWithoutFooter :

    Bottom padding if footer is not drawn

  • Nem or number bottomPaddingWithoutFooter :

    Bottom padding if footer is not drawn

  • object xy :

    Copy of xy_config.display, used in XY chart grids

  • object margin :

    Distances btwn outer chart elements and container

  • object padding :

    Distances btwn inner chart elements and container

Instance members

#parseChartgrid(config, _chartProps, callback, parseOpts)

parseChartgrid(config, _chartProps, callback, parseOpts)

src/js/charts/cb-chart-grid/parse-chart-grid.js

see ChartConfig#parser

Parameters

  • config :
  • _chartProps :
  • callback :
  • parseOpts :

Chartbuilder#getStateFromStores

src/js/components/Chartbuilder.jsx

Function to query Flux stores for all data. Runs whenever the stores are updated, usually by the Editor but occassionally by Renderers that allow direct editing of the chart, eg draggable legend labels in XYRenderer.jsx

Returns

Object :

Chartbuilder state

ChartbuilderDispatcher

src/js/dispatcher/dispatcher.js

Flux dispatcher handles incoming payloads and sends them to flux stores. Usually data come from the UI, but can also come from localStorage or a server

Instance members

#handleServerAction(action)

Incoming server action. Normally a localStorage object See ./actions/ChartServerActions.js

handleServerAction(action)

src/js/dispatcher/dispatcher.js

Incoming server action. Normally a localStorage object See ./actions/ChartServerActions.js

Parameters

  • Object action :

    { eventName: "string", : }

#handleViewAction(action)

Incoming view action. Normally comes from a React component. See ./actions/ChartPropertiesActions.js

handleViewAction(action)

src/js/dispatcher/dispatcher.js

Incoming view action. Normally comes from a React component. See ./actions/ChartPropertiesActions.js

Parameters

  • Object action :

    { eventName: "string", : }

ChartEditorMixin(k, v)

src/js/components/mixins/ChartEditorMixin.js

Functions common to chart editors

Parameters

  • k :
  • v :

ChartExport

src/js/components/ChartExport.jsx

Buttons that allow the user to export a chart to an image or Svg.

ChartGridEditor

src/js/components/chart-grid/ChartGridEditor.jsx

Editor interface for a Chart grid

Properties

  • object chartProps :

    Properties used to draw this chart

  • number numSteps :

    Allow the rendered component to interacted with and edited

ChartMetadata

src/js/components/ChartMetadata.jsx

Edit a chart's metadata

Properties

  • object metadata :

    Current metadata

  • string stepNumber :

    Step in the editing process

  • additionalComponents :

    Additional React components. Anything passed here will be given a callback that updates the metadata field. This is useful for adding custom input fields not provided.

ChartTypeSelctor

src/js/components/ChartTypeSelector.jsx

Select a new chart type, copying shared settings over to the new type.

DataInput

src/js/components/shared/DataInput.jsx

Text area component and error messaging for data input

DateScaleSettings

src/js/components/shared/DateScaleSettings.jsx

Date scale settings for a chart editor

Properties

  • object scale :

    Scale settings, which include date scale settings

  • function onUpdate :

    Callback to send selected date options back to parent

  • string stepNumber :

    Step in the editing process

NumericScaleSettings

src/js/components/shared/NumericScaleSettings.jsx

Y scale settings for XY charts. Used in both XY and chart grid, and most likely for future charts as well

ScaleReset

src/js/components/shared/ScaleReset.jsx

Button to delete a scale, resetting it to default settings

Properties

  • object scale :

    Current chart's scale object

  • string scaleId :

    Identifier for the scale we want to delete

  • function onUpdate :

    Callback to send reset scale back to parent

XY_yScaleSettings

src/js/components/shared/XY_yScaleSettings.jsx

Y scale settings for XY charts. Used in both XY and chart grid, and most likely for future charts as well

XYEditor

src/js/components/chart-xy/XYEditor.jsx

Editor interface for a XY chart

Properties

  • object chartProps :

    Properties used to draw this chart

  • number numSteps :

    Allow the rendered component to interacted with and edited

RendererWrapper

src/js/components/RendererWrapper.jsx

RendererWrapper

Wrapper component that determines which type of chart to render, wrapping it in Svg and telling it to draw.

Instance members

#SvgRectLabel

Render labels that are either automatically placed into a legend, or can be dragged manually by the user

SvgRectLabel

src/js/components/svg/SvgRectLabel.jsx

Render labels that are either automatically placed into a legend, or can be dragged manually by the user

ChartGrid_chartSettings

src/js/components/chart-grid/ChartGridEditor.jsx

Series-specific settings drawn for each column in data

Properties

  • string name :

    Series (column) name

  • Array<object> chartSettings :

    Current settings for data series

  • boolean universalSettings :

    Whether universalSettings is currently enabled

  • number numColors :

    Total number of possible colors

ChartGrid_gridSettings

src/js/components/chart-grid/ChartGridEditor.jsx

Settings that control the grid layout and type

Properties

  • object grid :

    Set grid type and number of rows and columns

  • number numSeries :

    Number of columns, used to decide how many rows/columns are possible

ChartGrid_universalToggle

src/js/components/chart-grid/ChartGridEditor.jsx

Button to toggle universal setting that applies series settings to all series

Properties

  • string text :

    Text of universal toggle button

  • Array<object> chartSettings :

    Current settings for data series

  • boolean universalSettings :

    Whether universalSettings is currently enabled

  • function onClick :

    Callback on toggle button click

ChartGridBars

src/js/components/chart-grid/ChartGridBars.jsx

Component that renders bar (row) charts in a chart grid

Properties

  • boolean editable :

    Allow the rendered component to interacted with and edited

  • object displayConfig :

    Parsed visual display configuration for chart grid

  • object chartProps :

    Properties used to draw this chart

ChartGridXY

src/js/components/chart-grid/ChartGridXY.jsx

Component that renders xy charts in a chart grid

Properties

  • boolean editable :

    Allow the rendered component to interacted with and edited

  • object styleConfig :

    Parsed global style config

  • object displayConfig :

    Parsed visual display configuration for chart grid

  • object chartProps :

    Properties used to draw this chart

ChartGridRenderer

src/js/components/chart-grid/ChartGridRenderer.jsx

Component that decides which grid (small multiples) type to render and

passes props to that renderer

Properties

  • boolean editable :

    Allow the rendered component to interacted with and edited

  • object displayConfig :

    Parsed visual display configuration for chart grid

  • object chartProps :

    Properties used to draw this chart

ChartRendererMixin(_chartProps, additional)

src/js/components/mixins/ChartRendererMixin.js

Functions common to chart renderers

Parameters

  • _chartProps :
  • additional :

XYRenderer

src/js/components/chart-xy/XYRenderer.jsx

Component that renders XY (line, column, dot) charts

Properties

  • boolean editable :

    Allow the rendered component to interacted with and edited

  • object displayConfig :

    Parsed visual display configuration for chart grid

  • object chartProps :

    Properties used to draw this chart

  • object metadata :

    Title, data source, etc

ChartMetadataStore

src/js/stores/ChartMetadataStore.js

ChartMetadataStore.js

Flux store for chart metadata such as title, source, size, etc.

Instance members

#get(k)

get

get(k)

src/js/stores/ChartMetadataStore.js

get

Parameters

  • k :

Returns

any :

Return value at key k

#getAll

getAll

getAll

src/js/stores/ChartMetadataStore.js

getAll

Returns

object :

Return all metadata

ChartPropertiesStore

src/js/stores/ChartPropertiesStore.js

ChartProptiesStore.js

Flux store for chart properties such as data, settings, scale

Instance members

#get(k)

get

get(k)

src/js/stores/ChartPropertiesStore.js

get

Parameters

  • k :

Returns

any :

Return value at key k

#getAll

getAll

getAll

src/js/stores/ChartPropertiesStore.js

getAll

Returns

object :

Return all chartProps

chartProps

src/js/charts/cb-chart-grid/chart-grid-config.js

Properties

  • object scale :

    Default settings for date and primary scales

  • object input
  • array chartSettings :

    Default settings for a given series (column) of data

  • object extraPadding :

    Additional padding. This is a dynamic value and is mostly changed within the component itself

  • object _grid :

    Grid settings

    • _grid.rows number

      Number of rows in the grid

    • _grid.cols number

      Number of columns in the grid

    • _grid.type string

      Grid type (bars|lines|dots|columns)

  • object mobile :

    Mobile-specific override settings

chartProps

src/js/charts/cb-xy/xy-config.js

Properties

  • object scale :

    Default settings for date and primary scales

  • array data
  • object input
  • Array<object> chartSettings :

    Default settings for a given series (column) of data

  • object extraPadding :

    Additional padding. This is a dynamic value and is mostly changed within the component itself

  • object _annotations :

    Additional informative graphical elements

    • _annotations.labels object

      If labels are dragged, their position settings are saved here

  • object mobile :

    Mobile-specific override settings

metadata

src/js/charts/cb-xy/xy-config.js

Properties

ChartServerActions(chartModel)

src/js/actions/ChartServerActions.js

ChartServerActions

Send data from some external API, usually localStorage in our case

Parameters

  • chartModel :

Static members

.receiveModel(model, chartModel)

Update the whole chart model

receiveModel(model, chartModel)

src/js/actions/ChartServerActions.js

Update the whole chart model

Parameters

ChartViewActions(newChartProps)

src/js/actions/ChartViewActions.js

ChartViewActions

Send data from React views to Flux dispatcher, and on to the stores

Parameters

  • newChartProps :

Static members

.updateAllChartProps(Object, newChartProps)

Update all chart props

updateAllChartProps(Object, newChartProps)

src/js/actions/ChartViewActions.js

Update all chart props

Parameters

  • Object :

    chartProps

  • newChartProps :
.updateAndReparse(key, newProp)

Update a single chart prop and reparse the input

updateAndReparse(key, newProp)

src/js/actions/ChartViewActions.js

Update a single chart prop and reparse the input

Parameters

  • string key :

    The key used to identify this property

  • object newProp :

    The property's value

.updateChartProp(key, newProp)

Update a single chart prop

updateChartProp(key, newProp)

src/js/actions/ChartViewActions.js

Update a single chart prop

Parameters

  • string key :

    The key used to identify this property

  • object newProp :

    The property's value

.updateInput(key, newInput)

Update a data input and reparse it

updateInput(key, newInput)

src/js/actions/ChartViewActions.js

Update a data input and reparse it

Parameters

  • string key :

    The key used to identify this property

  • object newInput :

    The property's value

.updateMetadata(newMetadata, k, v)

Update metadata

updateMetadata(newMetadata, k, v)

src/js/actions/ChartViewActions.js

Update metadata

Parameters

  • object newMetadata :

    The property's value

  • k :
  • v :

ErrorStore

src/js/stores/ErrorStore.js

ErrorStore.js

Store for errors/warnings to users about the bad/dumb things they are probably doing

Instance members

#get(k)

get

get(k)

src/js/stores/ErrorStore.js

get

Parameters

  • k :

Returns

any :

Return value at key k

#getAll

getAll

getAll

src/js/stores/ErrorStore.js

getAll

Returns

object :

Return all errors

helper

src/js/util/helper.js

Helper functions!

Static members

.combine_margin_pading(m, p)

combine_margin_pading

combine_margin_pading(m, p)

src/js/util/helper.js

combine_margin_pading

Parameters

  • m :
  • p :

Returns

object
.compute_scale_domain(scaleObj, data, opts)

compute_scale_domain

compute_scale_domain(scaleObj, data, opts)

src/js/util/helper.js

compute_scale_domain

Parameters

  • scaleObj :

    Current scale before generating new domain

  • Array<number> data :

    All values in the current scale

  • object opts :

    Whether to return nice values or force a minimum of 0 or below

Returns

object :

{ domain: [min, max], custom: }

.exact_ticks(domain, numticks)

Generate an exact number of ticks given a domain

exact_ticks(domain, numticks)

src/js/util/helper.js

Generate an exact number of ticks given a domain

Parameters

  • Array<number> domain :

    min/max of the current scale

  • number numticks :

    desired number of ticks

Returns

Array<string> :

Array of ticks

.merge_or_apply(defaults, source)

Given a defaults object and a source object, copy the value from the source if it contains the same key, otherwise return the default. Skip keys that only exist in the source object.

merge_or_apply(defaults, source)

src/js/util/helper.js

Given a defaults object and a source object, copy the value from the source if it contains the same key, otherwise return the default. Skip keys that only exist in the source object.

Parameters

  • object defaults :

    Default schema

  • object source :

    Source object to copy properties from

Returns

object :

Result has identical keys to defaults

.precision(a)

precision

precision(a)

src/js/util/helper.js

precision

Parameters

  • a :

Returns

undefined
.round_to_precision(num, precision, supress_thou_sep)

round_to_precision Round a number to N decimal places

round_to_precision(num, precision, supress_thou_sep)

src/js/util/helper.js

round_to_precision Round a number to N decimal places

Parameters

  • number num :

    Number to be rounded

  • number precision :

    Desired precision

  • boolean supress_thou_sep :

Returns

number :

Rounded number

.suggest_tick_num(domain)

Given a the domain of a scale suggest the most numerous number of round number ticks that it cold be divided into while still containing values evenly divisible by 1, 2, 2.5, 5, 10, or 25.

suggest_tick_num(domain)

src/js/util/helper.js

Given a the domain of a scale suggest the most numerous number of round number ticks that it cold be divided into while still containing values evenly divisible by 1, 2, 2.5, 5, 10, or 25.

Parameters

  • array domain :

    An array of two number like objects

Returns

integer :

Result is a single integer representing a nice number of ticks to use

.transform_coords(transformString)

transform_coords

transform_coords(transformString)

src/js/util/helper.js

transform_coords

Parameters

  • transformString :

Returns

undefined
.tz_offset_to_minutes(offset)

Given a timezone offset in an hour:minute format and return the equivalent number of minutes as a number only exist in the source object.

tz_offset_to_minutes(offset)

src/js/util/helper.js

Given a timezone offset in an hour:minute format and return the equivalent number of minutes as a number only exist in the source object.

Parameters

  • object offset :

    A string in a hh:mm format or "Z" for no offset

Returns

number :

Number of minutes

.validate_chart_model(modelStr)

Test whether a string is a valid Chartbuilder model

validate_chart_model(modelStr)

src/js/util/validate-chart-model.js

Test whether a string is a valid Chartbuilder model

Parameters

  • string modelStr :

    unparsed string of chart model JSON

generate_scale(type, scaleOptions, data, range, additionalOpts)

src/js/util/scale-utils.js

generateScale

Parameters

  • type :
  • scaleOptions :
  • data :
  • range :
  • additionalOpts :

SessionStore

src/js/stores/SessionStore.js

SessionStore

Flux store for the current session, ie session data that persits regardless interaction. Includes locale-aware settings and are unrelated to the actual rendering of the chart.

Instance members

#get(k)

get

get(k)

src/js/stores/SessionStore.js

get

Parameters

  • k :

Returns

any :

Return value at key k

#getAll

getAll

getAll

src/js/stores/SessionStore.js

getAll

Returns

object :

Return all session data

get_tick_widths(scaleOptions, font)

src/js/util/scale-utils.js

get_tick_widths

Parameters

  • scaleOptions :

    object

  • font :

    string

LocalStorageTimer

src/js/components/LocalStorageTimer.jsx

Button that persists for TIMER_DURATION and allows user to re-load the chart currently saved in localStorage. On click, it updates the SessionStore.

make_mults(components, data, gridOpts, howToRender, Outer, outerProps, gridScales, renderDataFunc)

src/js/util/grid-utils.js

make_mults

Parameters

  • components :

    { array? of base components that data will be passed to }

  • data :

    { data for each chart }

  • gridOpts :

    {grid option }

  • howToRender :

    { func that tells how to evaluate the components?? }

  • Outer :
  • outerProps :
  • gridScales :
  • renderDataFunc :

XY_chartSettings

src/js/components/chart-xy/XYEditor.jsx

Series-specific settings for each column in data

Properties

  • boolean allowSecondaryAxis :

    Should a secondary axis be allowed

  • Array<object> chartSettings :

    Current settings for data series

  • function onUpdate :

    Callback that handles new series settings

  • function onUpdateReparse :

    Callback that handles new series settings, but which need to be sent back to parse-xy

  • number numColors :

    Total number of possible colors

XY_resetLabels

src/js/components/chart-xy/XYEditor.jsx

When labels are dragged, this component appears and allows you to reset them

Properties

  • object annotations :

    Current chartProps._annotations

  • function onUpdate :

    Callback that passes a reset version of chartProps._annotation

XYLabels

src/js/components/chart-xy/XYRenderer.jsx

Component that renders the legend labels for an XY chart

See React.PropTypes declaration for properties:

Examples

propTypes: {
chartProps: PropTypes.object.isRequired,
editable: PropTypes.bool,
displayConfig: PropTypes.object.isRequired,
styleConfig: PropTypes.object.isRequired,
xScale: PropTypes.func.isRequired,
yScale: PropTypes.func.isRequired,
dimensions: PropTypes.object,
labelYMax: PropTypes.number,
updateLabelYMax: PropTypes.func
},