Skip to content

Sample: Currency ticks

Value axis with $ prefix, preferred interval, solid gridlines, and an axis title.

Live preview

Code

html
<div id="chart" style="width:800px;height:480px"></div>
<script type="module">
  import { Insight } from 'https://unpkg.com/@chartbuddy.io/embed';

  new Insight('#chart', {
    chartData: {
      chartType: 'clusteredBar',
      isDataTransposed: true,
      seriesData: [
        ['', 'Q1', 'Q2', 'Q3', 'Q4'],
        ['Revenue', 120, 145, 160, 188],
        ['Costs', 70, 82, 90, 98],
      ],
      title: { visible: true, text: 'Revenue vs Costs' },
      subtitle: { visible: false, text: '' },
      axes: {
        left: {
          labels: {
            preferredTickInterval: 50,
            numberFormat: {
              mode: 'custom',
              customFormat: {
                prefix: '$',
                postfix: '',
                thousandSeparator: ',',
                decimalSeparator: '.',
                decimalPlaces: 0,
                forceDecimals: false,
                signDisplay: 'auto',
                scaleDown: 0,
              },
            },
          },
          axisTitle: { visible: true, text: 'USD' },
          gridlines: { visible: true, dashArray: '' },
        },
      },
    },
  });
</script>

Docs: Value axis · Titles & chrome

Developer documentation for ChartBuddy Embed · Not the end-user Help Center · Help Center