Skip to content

Bar

  • Type: Two-dimensional chart with horizontal bars
  • Dimensions: Y-axis (categories), X-axis (values)
  • Use cases: Rank items, show top N performers, compare categories when names are long, display best/worst lists
  • Special features: Horizontal orientation makes long category names more readable than vertical columns
  • Visual: Horizontal bars proportional to values, making ranking and comparison easy

Bar graph

The image shows a horizontal bar chart displaying the top 10 customers by revenue percentage, with bars extending horizontally to show relative values.

To create a Bar chart, initialize the graph, add an axis, and use addGraphData with chart_type: "bar".

$olap.addGraph("5","Best 10 customers ?period.getYear()","[invoice_year]","[invoice_year]=?period.getYear()","0");
$olap.addGraphAxis("5","1","%","");
$olap.addGraphData("5","1","","[customer_name]","sum([invoiced_amount_dcur])","bar","","","10","M");
$olap.setGraphSize('5','XS12','SM4','MD4','LG4')

This produces a horizontal bar chart showing the top 10 customers ranked by revenue, sorted descending (M = measure descending).

Bar charts require one Y-axis (horizontal axis in bar charts). The X-axis (values) is automatic.

Required axis setup:

$olap.addGraphAxis('graph_id', 'axis_id', 'Axis Label', 'false')

Parameters:

  • graph_id: Your graph identifier
  • axis_id: Unique identifier for this axis
  • Axis Label: Text displayed on the axis (typically the measure unit)
  • false: Standard position (left side for values)

Example:

$olap.addGraphAxis("5","1","%","")

Add data using addGraphData with chart_type: "bar". The series column creates the bars (one per category).

Syntax:

$olap.addGraphData(
"graph_id",
"axis_id",
"dataseries_label",
"series",
"measure",
"bar",
"",
"filter",
"limit",
"orderby"
)

Parameters:

ParameterRequiredDescriptionExample
graph_idYesUnique graph identifier"5"
axis_idYesThe axis ID"1"
dataseries_labelYesLabel (use "" or "-" for simple bars)""
seriesYesColumn for categories (creates bars)"[customer_name]"
measureYesValue to display"sum([amount])"
chart_typeYesMust be "bar""bar"
aggregationNoNot typically used (use "")""
filterNoAdditional filter"[status] = 1"
limitNoLimit number of bars (top N)"10"
orderbyNoSort method. "M" for measure descending"M"

Example - Top 10:

$olap.addGraphData("5","1","","[customer_name]","sum([invoiced_amount_dcur])","bar","","","10","M");

Example - All items sorted:

$olap.addGraphData("5","1","Revenue","[product]","sum([sales])","bar","","","","M");

Example - With filter:

$olap.addGraphData("5","1","","[region]","sum([amount])","bar","","[year] = 2024","","M");

Control responsive width using setGraphSize. Bar charts work well at medium sizes.

$olap.setGraphSize("graph_id", "XS12", "SM4", "MD4", "LG4")

Common sizes:

  • Medium: "XS12", "SM4", "MD4", "LG4" (third width)
  • Half: "XS12", "SM6", "MD6", "LG6" (half width)
  • Full: "XS12", "SM12", "MD12", "LG12" (full width)

Show only the best performers:

$olap.addGraph("1", "Top 10 Products", "[year]", "[year] = 2024","0");
$olap.addGraphAxis("1","1","Sales","");
$olap.addGraphData("1","1","","[product_name]","sum([sales])","bar","","","10","M");

Create two graphs or use filters:

// Best
$olap.addGraphData("1","1","Best","[item]","sum([value])","bar","","","10","M");
// Worst (ascending would need different approach)

Show values as percentages:

$olap.addGraphData("1","1","%","[category]","sum([amount]) / sum(sum([amount])) * 100","bar","","","","M");

Rank items within each time period:

$olap.addGraph("1", "Monthly Top 5", "[month]:[product]", "","0");
$olap.addGraphData("1","1","","[product]","sum([sales])","bar","","","5","M");

Bar charts excel when category names are long:

$olap.addGraphData("1","1","","[full_product_description]","sum([revenue])","bar","","","","M");
  • Check: Ensure chart_type is exactly "bar" (lowercase)
  • Check: Verify series column has valid values
  • Check: Confirm measure returns numeric values
  • Issue: Bars not in expected order
  • Fix: Use orderby: "M" for descending by measure
  • Fix: Remove orderby for data order, or use "A" for ascending (if supported)
  • Issue: Chart cluttered with many bars
  • Fix: Use limit parameter to show top N only:
    $olap.addGraphData("1","1","","[category]","sum([amount])","bar","","","10","M")
  • Issue: Category labels truncated
  • Fix: Increase chart width with setGraphSize (use SM6/MD6 or larger)
  • Fix: Consider abbreviating category names in data
  • Issue: Values too close to distinguish
  • Fix: Check if measure scale is appropriate (may need normalization)
  • Fix: Use different measure or filter to relevant range

Q: What’s the difference between bar and column charts?
A: Bar charts are horizontal (good for long names), column charts are vertical (good for time series). Use bar for ranking, column for trends.

Q: Can I stack bars like columns?
A: Bar charts typically don’t use stacking. Use column charts if you need stacked visualization.

Q: How do I show bottom N instead of top N?
A: Use ascending sort if supported, or calculate inverse measure. Typically bar charts show top performers.

Q: Can I have multiple bar series?
A: Bar charts work best with single series. For multiple measures, consider column charts or combined charts.

Q: How do I format the axis labels?
A: Axis label comes from addGraphAxis. For value formatting, ensure your measure returns appropriately formatted numbers.

Q: Can I use bar charts for time series?
A: Not recommended. Use column or spline charts for time-based data. Bar charts are for ranking/categorization.

Q: What if I have negative values?
A: Negative values will extend bars in the opposite direction, which may be confusing. Filter or transform negative values if not desired.

Q: How do I limit to top 10?
A: Use limit: "10" and orderby: "M" in addGraphData:

$olap.addGraphData("1","1","","[item]","sum([value])","bar","","","10","M")