javascript - Add additional bar lines in highcharts x axis -
i have 1 chart in application.i have customize chart below image
here working fine how draw bar lines in x axis,whether possible or not.i adding 1 fiddler can me draw bar line every bar
code
highcharts.chart('container', { chart: { type: 'column' }, title: { text: 'stacked column chart' }, xaxis: { categories: ['apples', 'oranges', 'pears', 'grapes', 'bananas'] }, yaxis: { min: 0, title: { text: 'total fruit consumption' }, stacklabels: { enabled: true, style: { fontweight: 'bold', color: (highcharts.theme && highcharts.theme.textcolor) || 'gray' } } }, 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: { column: { stacking: 'normal', datalabels: { enabled: true, color: (highcharts.theme && highcharts.theme.datalabelscolor) || 'white' } } }, series: [{ name: 'john', data: [5, 3, 4, 7, 2] }, { name: 'jane', data: [2, 2, 3, 2, 1] }, { name: 'joe', data: [1, 1, 1, 1, 1] }] });
you can draw lines renderer. access points's graphic attribute height, width,x, y use chart.series[seriesindex].data[pointindex].shapeargs
function getlinepaths(chart) { var series = chart.series, extensionfactor = 0.3, linepaths = []; series[series.length - 1].data.foreach(function(point) { var shapeargs = point.shapeargs, left = chart.plotleft + shapeargs.x, right = left + shapeargs.width, y = chart.plottop + shapeargs.y + shapeargs.height, length = right - left; linepaths.push([ 'm', left - (length * extensionfactor), y, 'l', right + (length * extensionfactor), y ]); }); return linepaths; } function renderlines() { var chart = this, customlines = this.customlines = [], linepaths = getlinepaths(chart); linepaths.foreach(function(linepath) { customlines.push( chart.renderer.path(linepath) .attr({ 'stroke-width': 3, stroke: 'red', zindex: 6 }) .add() ); }); } function animatelines() { var chart = this, customlines = chart.customlines, linepaths = getlinepaths(chart); customlines.foreach(function (line, i) { line.animate({ d: linepaths[i] }); }); }
example: http://jsfiddle.net/tcr8rrrh/1/
if not want use renderer, add line series.
series: [ { type: 'line', data: [[-0.3, 0], [0.3, 0]], color: 'red' }], plotoptions: { line: { marker: { enabled: false }, enablemousetracking: false, showinlegend: false } }
example: http://jsfiddle.net/tcr8rrrh/2/
Comments
Post a Comment