I have to do a column chart using highcharts that has 1px space between the colums and the Y axis, how can I add the 1px space that is in my desired chart to the chart I did, these is the code I did: (Sorry I don't have the reputation enough to add images that's why I haven't post then)
var data = [ 20, 29, 25, 29, 21, 17, 20, 19, 18];
createMeasuresGraph(data, "quintals-sugar-graph");
function createMeasuresGraph(data, container) {
data[0] = { color: '#55B647', y: data[0] };
data[data.length -2 ] = { color: '#F15B49', y: data[data.length -2 ] };
var chart = new Highcharts.Chart({
chart: {
marginBottom: 1,
marginLeft: 0,
marginRight: 0,
marginTop: 0,
renderTo: container,
type: 'column',
},
credits: {
enabled: false
},
legend: {
enabled: false
},
plotOptions: {
column: {
pointWidth: 5,
},
series: {
borderWidth: .1,
}
},
series: [{
data: data,
color: '#95D2F3',
shadow: false,
}],
title: {
text: ''
},
tooltip: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
title: {
enabled: false
},
lineColor: '#CBCBCB',
tickWidth: 0
},
yAxis: {
endOnTick: false,
gridLineWidth: 0,
labels: {
enabled: false
},
startOnTick: false,
minPadding: 0.5,
title: {
text: ""
}
}
});
}
I seeing also that the space between is not the same in all the columns, maybe I'm using a wrong aproch to get the spaces, what would it be best?
I have to do a column chart using highcharts that has 1px space between the colums and the Y axis, how can I add the 1px space that is in my desired chart to the chart I did, these is the code I did: (Sorry I don't have the reputation enough to add images that's why I haven't post then)
var data = [ 20, 29, 25, 29, 21, 17, 20, 19, 18];
createMeasuresGraph(data, "quintals-sugar-graph");
function createMeasuresGraph(data, container) {
data[0] = { color: '#55B647', y: data[0] };
data[data.length -2 ] = { color: '#F15B49', y: data[data.length -2 ] };
var chart = new Highcharts.Chart({
chart: {
marginBottom: 1,
marginLeft: 0,
marginRight: 0,
marginTop: 0,
renderTo: container,
type: 'column',
},
credits: {
enabled: false
},
legend: {
enabled: false
},
plotOptions: {
column: {
pointWidth: 5,
},
series: {
borderWidth: .1,
}
},
series: [{
data: data,
color: '#95D2F3',
shadow: false,
}],
title: {
text: ''
},
tooltip: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
title: {
enabled: false
},
lineColor: '#CBCBCB',
tickWidth: 0
},
yAxis: {
endOnTick: false,
gridLineWidth: 0,
labels: {
enabled: false
},
startOnTick: false,
minPadding: 0.5,
title: {
text: ""
}
}
});
}
I seeing also that the space between is not the same in all the columns, maybe I'm using a wrong aproch to get the spaces, what would it be best?
Share Improve this question edited Sep 16, 2013 at 3:19 SheetJS 22.9k12 gold badges67 silver badges76 bronze badges asked Sep 3, 2012 at 15:25 mkhuetemkhuete 8532 gold badges7 silver badges9 bronze badges3 Answers
Reset to default 13You want a 1px space between each column?
I would calculate the column width based on the size of the plot / number of columns:
var colWidth = ($('#quintals-sugar-graph').width() / data.length) + 1;
Then set the "borderWidth" to 1px to provide the space:
plotOptions: {
column: {
pointWidth: colWidth,
borderWidth: 1
},
},
Fiddle here.
Do you really need the width to be exactly 1px? If not, the following also leave minimum space between columns and would be more convenient:
plotOptions: {
column: {
pointPadding: 0,
groupPadding: 0
}
}
You can simply do:
plotOptions: {
column: {
pointPadding: 0,
groupPadding: 0,
borderWidth: 1
}
},