Skip to content

Instantly share code, notes, and snippets.

@bas080
Last active July 26, 2016 14:37
Show Gist options
  • Select an option

  • Save bas080/9fa2c75cc228874298d9a02127db438a to your computer and use it in GitHub Desktop.

Select an option

Save bas080/9fa2c75cc228874298d9a02127db438a to your computer and use it in GitHub Desktop.

Settings

Aurelia charts standardizes the way data that is passed to charts is defined. It does so by allowing data of any dimension to be labeled. Let me show you several examples.

Line chart 2-dimensions

const commitsPerDay = ['Day', 'Number of commits'];

const lineChartSettings = {
  labels: {
    anna:  commitsPerDay,
    berta: commitsPerDay,
    clara: commitsPerDay
  },
  data: [
    [[1,2],[3,4]],
    [[4,3],[2,1]],
    [[3,2],[1,4]]
  ]
};

Bar chart 1-dimensional

const barChartSettings = {
  labels: ['arnold', 'bruce', 'charles'],
  data: [
    1,
    2,
    3
  ]
};

Stacked bar chart 2-dimensional

const halves = ['first-half', 'second-half'];

const stackedBarChartSettings = {
  labels: {
    arnold:  halves,
    bruce:   halves,
    charles: halves
  },
  data: [
    [1, 3],
    [2, 5],
    [3, 1]
  ]
};

Pie chart 1-dimensional

const pieChartSettings = {
  labels: ['china', 'peru', 'russia'],
  data: [
    30,
    10,
    60,
  ]
};

Scatter plot 3-dimensional

const salesLabels = ['hour', 'sales', 'revenue'];

const scatterPlotSettings = {
  labels: {
    Hema:     salesLabels,
    Kruidvat: salesLabels,
    'V&D':    salesLabels
  },
  data: []
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment