Highcharts Demo

author(s): Torstein Hønsi

by ninachroscicka

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

CSS

.dataLabel { max-height: 15px; min-width: 150px; max-width: 15px; text-overflow: ellipsis; overflow: hidden; }

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: ''
    },
    xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas','Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
        title: {text: null},
        lineWidth: 0,
        minorGridLineWidth: 0,
        lineColor: 'transparent',
        minorTickLength: 0,
        tickLength: 0,
        labels: {
          style: {
            color: '#001630',
            fontWeight: '400',
            textTransform: "capitalize",
            fontSize: '1rem',
            fontFamily: "\"Raleway\", sans-serif"
          },
          formatter: function () {
            if (this.value.desc != null) {
              return '<span title="' + this.value.desc + '">' + this.value.y + '</span>';
            } else {
              return this.value.y;
            }
          }
        }
      },
    yAxis: {visible:false
    },
    legend: {
        align: 'right',
        x: -30,
        verticalAlign: 'top',
        y: 25,
        floating: true,
        backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
        borderColor: '#CCC',
        borderWidth: 1,
        shadow: false
    },
    tooltip: {
        headerFormat: '<b>{point.x}</b><br/>',
        pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
    },
    plotOptions: {
        /*series: {
            stacking: 'percent'
        },*/
        bar: {
            groupPadding:1,
            pointWidth:10,
            borderRadius: 5,
            dataLabels: {
                enabled: true,
                crop: false,
                overflow: 'none'
            }
        }
    },
    series: [{
        data: [5, 3, 4, 7, 2,5, 3, 4, 7, 2]
    }]
});