bar-chart

The component can display statistics related to data records (categorical variables) represented in a bar chart. This can show a single or multiple data series for comparative purposes and highlight specific regions or ranges on the chart to make it easier for users to interpret and analyze the data. This component is mostly used in jig.default or jig.list

Configuration options

Some properties are common to all components, see Common component properties for a list and their configuration options.

Core structure

series

color - defines the color of the bar used in the chart.

data

values to be used in the chart.

yAxis

min and max values that display on the y-axis. The max property doesn't have to be defined, in this case, it will automatically be calculated depending on your data.

xAxis

categories to display on the x-axis

Other options

chart

  • titleand subtitle - Name and a short description of your chart.

  • height and width - The parameters of the graph displayed (in pixels).

legend

isHidden - The setting of a boolean value if the legend (naming of the series) should be displayed under the chart.

plotBands

The from and to properties define the area to be filled with color. Specify the range using the from and to properties with numeric values. color Sets the color of the band for the y-axis, choose a color from the provided color palette. Use plotbands to highlight specific regions or ranges on the chart, making it easier for users to interpret and analyze the data.

plotOptions

series - Different properties available to manipulate the data shown in the bar such as width of columns, the interval between two points, option to hide markers.

series

name - The naming of the actual series.

xAxis

  • isFirstLabelHidden value is either true to hide the first label or false to display the first label. The property doesn't have to be defined, by default the first label is shown.

  • isFirstTickHidden value is either true/false. Set to true hides the whole axis.

  • isHidden value is either true/false.

  • isLastLabelHidden value is either true to hide the last label or false to display the last label. The property doesn't have to be defined, by default the last label are shown.

  • isLastTickHidden value is either true to hide the last line and label or false to display the last line and label. The property doesn't have to be defined, by default the last label and line are shown.

  • labels - Label of axis, a selection of different formats such as dateFormat, currency, unit, and signDisplay are available.

  • min and max - Minimum and maximum values that should be displayed on the x-axis.

  • minPadding - When no categories set, a 1% space is made on the left and right of the chart so the id doesn't start on the left or ends on the right edge exactly. The default is set to 0.02 (x-axis) and 0.05 (y-axis).

  • tickAmount - The number of ticks to display on the x-axis. The final amount doesn't have to be exactly the same number as you pass into it. Round up to 6 to give the chart a good set of numbers 0, 20, 40, 60, 80, 100. Set ticks to 3 will be honored and shows 0, 50, and 100.

yAxis

  • isFirstLabelHidden value is either true/false. Set to true hides the first label. The property doesn't have to be defined, by default the first label is shown.

  • isFirstTickHidden value is either true/false. Set to true hides the whole axis.

  • isHidden value is either true/false. Set to true the last label is hidden.

  • isLastLabelHidden value is either true to hide the last label and line or false to display the last label and line. The property doesn't have to be defined, by default the last label and line are shown.

  • isLastTickHidden value is either true to hide the last line and label or false to display the last line and label. The property doesn't have to be defined, by default the last label and line are shown.

  • labels - Label of axis, a selection of different formats such as currency, numberStyle, compactDisplay and notation is available.

  • minPadding - When no categories set, a 1% space is made on the left and right of the chart so the id doesn't start on the left or ends on the right edge exactly. The default is set to 0.02 (x-axis) and 0.05 (y-axis).

  • min and max - Minimum and maximum values that should be displayed on the y-axis.

  • tickAmount - The number of ticks to display on the x-axis. The final amount doesn't have to be exactly the same number as you pass into it. Round up to 6 to give the chart a good set of numbers 0, 20, 40, 60, 80, 100. Set ticks to 3 will be honored and shows 0, 50, and 100

Examples and code snippets

Bar-chart finance static

Finance bar-chart
Finance bar-chart

The jig displays a bar chart with an annual overview of finances. The x-axis shows the months and the y-axis the monetary amount. Using number formatting, we can have any currency displayed.

Examples: See the full code sample using static data in GitHub. See the full code sample using dynamic data in GitHub.

Datasources: See the full datasource code sample for dynamic data in GitHub.

title: Current account overview
type: jig.default

datasources:
  finance: 
    type: datasource.static
    options:
      data:
        - date: Jun
          amount: 1851
        - date: Jul
          amount: 1483
        - date: Aug
          amount: 1250  
        - date: Sep
          amount: 2067
        - date: Oct
          amount: 1650
        - date: Nov
          amount: 1280
        - date: Dec
          amount: 1430
        - date: Jan
          amount: 1398
        - date: Feb
          amount: 1763
        - date: Mar
          amount: 2151
        - date: Apr
          amount: 1543
        - date: May
          amount: 1475    
                  
children:
  - type: component.bar-chart
    options:
      chart:
        title:
          text: 12 months overview
        height: 260
# Define the format and labels for and their values to display on the y axis
      yAxis:
        min: 0
        max: 2500
        labels: 
          format:
            numberStyle: currency
            currency: USD
            compactDisplay: short
            notation: compact
        tickAmount: 5
      # Define the data categories to display on the x axis
      xAxis:
        categories: [email protected]       
      # Define the data to show in the bars on the chart known as the series. 
      series:
        - data: [email protected]
          name: 2021/2022
          color: color1 
      legend:
        isHidden: false

Bar-chart multiple series

Chart with multiple series
Chart with multiple series

The jig displays a bar chart with four series that compares amounts for three years per quarter. In this example the Legend is shown.

Examples: See the full code sample using static data in GitHub. See the full code sample using dynamic data in GitHub.

Datasources in order series1 and series2: See the full datasource code sample for dynamic data series 1 and series 2 in GitHub.

title: Multiple series
type: jig.default
# Define the data to be used in the chart
datasources:
  multi:
    type: datasource.static
    options:
      data:
        - Q1: 12000
          Q2: 48000
          Q3: 36000
          Q4: 12000
          Year: "2020"
        - Q1: 34000
          Q2: 22000
          Q3: 40000
          Q4: 51000
          Year: "2021"
        - Q1: 25000
          Q2: 32000
          Q3: 45000
          Q4: 86000
          Year: "2019"              

children:
  - type: component.bar-chart
    options:
      chart:
        height: 250
      legend:
        isHidden: false
        # Define the format, labels to display on the y axis
      yAxis: 
        max: 90000
        min: 0
        labels:  
          format:
            currency: USD
            numberStyle: currency
            compactDisplay: short
            notation: compact
        tickAmount: 8
      # Define the data categories to display on the x axis   
      xAxis:   
        categories: [email protected]
        # Define the data to show in the bars on the chart known as the series. 
      series: 
        - data: [email protected]
          name: Q1
          color: color2
          
        - data: [email protected]
          name: Q2
          color: color3
         
        - data: [email protected]
          name: Q3
          color: color4
          
        - data: [email protected]
          name: Q4
          color: color5

Bar-chart with plot bands

The jig displays a bar chart with an annual overview of finances. The x-axis shows the months and the y-axis the monetary amount. The data points are easy to see as we used the plotBands property to add color. In this example multiple bands are defined by adding the form, to and color properties.

Examples: See the full code sample in GitHub.

Bar-chart with plot bands
Bar-chart with plot bands
bar-chart-plotbands
title: Current account overview
type: jig.default

datasources:
  finance: 
    type: datasource.static
    options:
      data:
        - date: Jun
          amount: 1851
        - date: Jul
          amount: 1483
        - date: Aug
          amount: 1250  
        - date: Sep
          amount: 2067
        - date: Oct
          amount: 1650
        - date: Nov
          amount: 1280
        - date: Dec
          amount: 1430
        - date: Jan
          amount: 1398
        - date: Feb
          amount: 1763
        - date: Mar
          amount: 2151
        - date: Apr
          amount: 1543
        - date: May
          amount: 1475    
                  
children:
  - type: component.bar-chart
    options:
      chart:
        title:
          text: 12 months overview
        height: 260
# Define the format and labels for and their values to display on the y axis
      yAxis:
        min: 0
        max: 2500
        labels: 
          format:
            numberStyle: currency
            currency: USD
            compactDisplay: short
            notation: compact
        tickAmount: 5
    # add four bands of different color to the bar chart     
        plotBands:
          - from: 0
            to: 500
            color: color4
          - from: 500
            to: 1000
            color: color5
          - from: 1000
            to: 1500
            color: color6
          - from: 1500
            to: 2000
            color: color7
      # Define the data categories to display on the x axis
      xAxis:
        categories: [email protected]       
      # Define the data to show in the bars on the chart known as the series. 
      series:
        - data: [email protected]
          name: 2021/2022
          color: color1 
      legend:
        isHidden: false

Bar-chart using expressions

Chart using expressions
Chart using expressions

In this example expressions are used to dertermine the series, categories, min, max, and tickAmount of a bar chart . The x-axis shows the quarters and the y-axis the monetary amount using the format property to display the currency.

Examples: See the full code sample in GitHub.

Datasources See the full datasource code sample for series 1 and series 2 in GitHub.

#Add file to the jigs folder
title: Multiple series dynamic
type: jig.default
children:
  - type: component.bar-chart
    options:
      chart:
        height: 250
      series:
        - data: [email protected]
        - data: [email protected]
      xAxis:
        categories: 
          - [email protected][0].x
          - [email protected][1].x
          - [email protected][2].x
          - [email protected][3].x
      yAxis: 
        labels:
          format:
            compactDisplay: short
            currency: USD
            notation: compact
            numberStyle: currency
        min: [email protected][0].min
        tickAmount: [email protected][0].tickAmount
        max: [email protected][0].max 

Last updated

Was this helpful?