Programmer Journey - Draggable Bar

by Haze32

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<script src="https://code.highcharts.com/highcharts.js"></script>
<figure class="highcharts-figure">
    <div id="container"></div>
</figure>

<div>
Mouse over on legend to show tooltip.
</div>

CSS

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

#container {
    height: 300px;
    width: 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: "Price"
    },
    xAxis: {
        categories: ['Product A','Product B','Product C','Product D']
    },
    yAxis: {
        min: 0,
        max: 10
    },

    plotOptions: {
      bar: {
        minPointLength: 2
      }
    }, 
    legend: {
      useHTML: true,
      labelFormatter: function () {
        var tooltip;
        
        switch (this.index) {
        	case 0:
          	tooltip = 'Includes Portuguese taxes';
            break;
          case 1:
          	tooltip = 'No taxes included';
            break;
        }
        
        return '<span data-toggle="tooltip" title="' + tooltip + '">' + this.name + '</span>';
      }
    },
    series: [{
    		name: 'Portugal',
        data: [3,5,7,9]
    }, {
    		name: 'Spain',
        data: [2,4,8,10]
    }]
});