highstock - Highcharts : How do i align data labels above the axis in column chart? -
i plotting values dynamically in highcharts column charts. have displayed data labels -90 degree rotation avoid overlapping. has issues values cut off axis.
have tried y offset option. values plotted dynamically. couldn't set value fixed one.
js fiddle : a link
highcharts.chart('container', { chart: { type: 'column' }, title: { text: 'world\'s largest cities per 2014' }, subtitle: { text: 'source: <a href="http://en.wikipedia.org/wiki/list_of_cities_proper_by_population">wikipedia</a>' }, xaxis: { type: 'category', labels: { rotation: -45, style: { fontsize: '13px', fontfamily: 'verdana, sans-serif' } } }, yaxis: { min: 0, title: { text: 'population (millions)' } }, legend: { enabled: false }, tooltip: { pointformat: 'population in 2008: <b>{point.y:.1f} millions</b>' }, series: [{ name: 'population', data: [ ['shanghai', 2341.7], ['lagos', 165.1], ['istanbul', 14.2], ['karachi', 14.0], ['mumbai', 12.5], ['moscow', 12.1], ['são paulo', 11.8], ['beijing', 11.7], ['guangzhou', 11.1], ['delhi', 11.1], ['shenzhen', 10.5], ['seoul', 10.4], ['jakarta', 10.0], ['kinshasa', 9.3], ['tianjin', 9.3], ['tokyo', 9.0], ['cairo', 8.9], ['dhaka', 8.9], ['mexico city', 8.9], ['lima', 8.9] ], datalabels: { usehtml:true, crop:false, enabled: true, rotation: -90, color: '#000000', inside:true, style: { fontfamily: 'verdana, sans-serif', fontweight: "bold" , fontsize: "15px" } } }]
});
`
<div id="container" style="min-width: 300px; height: 400px; margin: 0 auto"> </div> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script>
`
try set yaxis type logarithmic, , minortickinterval 0.1. logarithmic scale fits type of data perfectly. lets @ code below:
yaxis: { type: 'logarithmic', minortickinterval: 0.1, title: { text: 'population (millions)' } },
here refactored jsfiddle: https://jsfiddle.net/daniel_s/x5oxyt2v/
best regards!
Comments
Post a Comment