BarChart.js

Summary
BarChart.js
BarChartA visualization that displays stacked bar charts.
Functions
loadJSONLoads JSON data into the visualization.
updateJSONUse this method when updating values for the current JSON data.
getLegendReturns an object containing as keys the legend names and as values hex strings with color values.
getMaxValueReturns the maximum accumulated value for the stacks.

BarChart

A visualization that displays stacked bar charts.

Constructor Options

See Options.BarChart.

Summary
Functions
loadJSONLoads JSON data into the visualization.
updateJSONUse this method when updating values for the current JSON data.
getLegendReturns an object containing as keys the legend names and as values hex strings with color values.
getMaxValueReturns the maximum accumulated value for the stacks.

Functions

loadJSON

loadJSON: function(json)

Loads JSON data into the visualization.

Parameters

jsonThe JSON data format.  This format is described in http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/#json-data-format.

Example

var barChart = new $jit.BarChart(options);
barChart.loadJSON(json);

updateJSON

updateJSON: function(json,
onComplete)

Use this method when updating values for the current JSON data.  If the items specified by the JSON data already exist in the graph then their values will be updated.

Parameters

json(object) JSON data to be updated.  The JSON format corresponds to the one described in BarChart.loadJSON.
onComplete(object) A callback object to be called when the animation transition when updating the data end.

Example

barChart.updateJSON(json, {
  onComplete: function() {
    alert('update complete!');
  }
});

getLegend

getLegend: function()

Returns an object containing as keys the legend names and as values hex strings with color values.

Example

var legend = barChart.getLegend();

getMaxValue

getMaxValue: function()

Returns the maximum accumulated value for the stacks.  This method is used for normalizing the graph heights according to the canvas height.

Example

var ans = barChart.getMaxValue();

In some cases it could be useful to override this method to normalize heights for a group of BarCharts, like when doing small multiples.

Example

//will return 100 for all BarChart instances,
//displaying all of them with the same scale
$jit.BarChart.implement({
  'getMaxValue': function() {
    return 100;
  }
});
loadJSON: function(json)
Loads JSON data into the visualization.
updateJSON: function(json,
onComplete)
Use this method when updating values for the current JSON data.
getLegend: function()
Returns an object containing as keys the legend names and as values hex strings with color values.
getMaxValue: function()
Returns the maximum accumulated value for the stacks.
BarChart options.
Close