Basic bar

author(s): Torstein Hønsi

by kikkoma

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>


<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Bar chart showing horizontal columns. This chart type is often
        beneficial for smaller screens, as the user can scroll through the data
        vertically, and axis labels are easy to read.
    </p>
</figure>

CSS

.highcharts-figure, .highcharts-data-table table {
    min-width: 340px; 
    max-width: 800px;
    margin: 1em auto;
}

#container {
    height: 400px;
}

.highcharts-data-table table {
	font-family: Verdana, sans-serif;
	border-collapse: collapse;
	border: 1px solid #EBEBEB;
	margin: 10px auto;
	text-align: center;
	width: 100%;
	max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: ''
    },
  subtitle: {
    text: '統計區間 2021/2/18 ~ 2021/3/1'
  },
    xAxis: {
    	type: 'category'
    },
    yAxis: {
        min: 0,
        title: {
            text: '功能使用次數'
        },
        labels: {
            overflow: 'justify'
        }
    },
    plotOptions: {
        bar: {
            dataLabels: {
                enabled: true
            }
        }
    },
    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'top',
        x: -40,
        y: 80,
        floating: true,
        borderWidth: 1,
        backgroundColor:
            Highcharts.defaultOptions.legend.backgroundColor || '#FFFFFF',
        shadow: true,
        enabled: false
    },
    credits: {
        enabled: true
    },
    series: [{
        name: 'Year 2016',
        data: [
                {
                    "name": "儀錶板",
                    "y": 1201
                },
                {
                    "name": "平面配置圖",
                    "y": 999
                },
                {
                    "name": "圖資查詢",
                    "y": 711
                },
                {
                    "name": "地圖展示",
                    "y": 254
                },
                {
                    "name": "設備控制",
                    "y": 116
                },
                {
                    "name": "圖資管理",
                    "y": 54
                }
            ]
    }]
});