I'm using Flot library with angular-flot. I have a fixed sized chart which doesn't look nice when having f.e. 1 or 2 bars. You can see the example below for 2 bars:
The bars try to spread over the whole length of the x axis. I want the to be centered - they should "start" in the middle and spread horizontally. Is that possible in Flot?
My options for bars:
options: {
series: {
bars: {
show: true,
barWidth: 0.4,
lineWidth: 1,
align: 'center',
fillColor: {
colors: [{
opacity: 0.5
}, {
opacity: 0.1
}]
}
}
},
xaxis: {
mode: 'categories',
axisLabel: 'Machines',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 14,
axisLabelFontFamily: 'RobotoLight, Helvetica Neue, Helvetica',
axisLabelPadding: 10
},
yaxis: {
axisLabel: metricName,
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 14,
axisLabelFontFamily: 'RobotoLight, Helvetica Neue, Helvetica',
axisLabelPadding: 10
},
grid: {
hoverable: true,
clickable: false,
borderWidth: 1
}
}
Just set an intelligent min/max on the xAxis options. For instance, on a plot with two bars:
min: -0.5,
max: 1.5,
For each additional bar increase the max by one.
Here's a fiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With