Skip to content

BarPlot

Overview

Shows bars for numerical data (where the x-value of the bar is a number). Does not support categorical data.

@author Sam Reid (PhET Interactive Simulations)

Class BarPlot

import { BarPlot } from 'scenerystack/bamboo';

Constructor

new BarPlot( chartTransform : ChartTransform, dataSet : Vector2[], providedOptions? : BarPlotOptions )

Instance Methods

setDataSet( dataSet : Vector2[] )

Sets the dataSet and redraws the plot. If instead the dataSet array is mutated, it is the client's responsibility to call update or make sure update is called elsewhere (say, if the chart scrolls in that frame).

update()

dispose()

Instance Properties

dataSet : Vector2[]

if you change this directly, you are responsible for calling update

barWidth : number

rectangles : Rectangle[]

Type BarPlotOptions

import type { BarPlotOptions } from 'scenerystack/bamboo';
  • barWidth?: number
    width in view coordinates of each bar in the plot
  • barTailValue?: number
  • pointToPaintableFields?: ( point: Vector2 ) => PaintableOptions
    maps a point to a containing Paintable options NOTE: cannot use the "Options" suffix because merge will try to merge that as nested options.
  • & NodeOptions

Source Code

See the source for BarPlot.ts in the bamboo repository.