How to increase width of morris.js bar or add space between bars?
The api doc pages seem to omit several properties. You can learn about more by looking at the source, where I found these 2 guys:
barGap
and barSizeRatio
barGap
is an integer that sets the space between bars in a single bar group. It defaults to 3. Increase it to space them further, decrease it to bring them closer together. barSizeRatio
is the proportion of the width of the entire graph given to bars. It defaults to 0.75. Increase the number closer to 1 to make the bars wider, if its =1 the bars will take up the entire graph, if its > 1 bars will overlap.
Morris.Bar({
barGap:4,
barSizeRatio:0.55,
element: 'morris-chart-bar',
data: [
{ y: 'Feb', a: 75, b: 60, c: 5, d: 50 },
{ y: 'March', a: 180, b: 220, c: 140, d: 160 },
{ y: 'April', a: 300, b: 340, c: 350, d: 270 }
],
xkey: 'y',
ykeys: ['a', 'b', 'c', 'd'],
labels: ['A', 'B', 'C', 'D'],
barColors: ['#0B62A4','#f75b68','#4DA74D','#646464'],
hideHover: 'auto'
});
Morris Bar Chart consistent bar width
This feature I guess was added, but not documented on the main site. The configuration is "barSize: 50".
Bar chart horizontal bar width i want fixed or max width for each horizontal bar
You can use barSizeRatio to control the width of the bars. So, when you have few bars e.g. less than 5, set barSizeRatio to 0.2. For more than 5 bars, let don't specify barSizeRatio, let the chart control figure it out.
jsfiddle http://jsfiddle.net/bv4xezh7/1/
Morris.Bar({
barSizeRatio:0.2,
element: 'chart',
data: [
{ date: '04-02-2014', value: 3 },
{ date: '04-03-2014', value: 10 },
],
xkey: 'date',
ykeys: ['value'],
labels: ['Orders']
});
You can make it more dynamic by figuring out the width of the chart control and then decide the value of barSizeRatio to meet your maximum bar width criteria.
Using Morris Bar can't show
Your xkey (kd_spbu) is also in ykeys. You need to remove it from from the ykeys.
Also none of the xkeys / ykeys are defined in your PHP code.
Related Topics
How to Make Twitter Bootstrap Submenu to Open on the Left Side
Display a Message Within the Kendo Grid When It's Empty
How to Change Text (Not Font Size) According to Screen Size in CSS
Convert CSS Text to JavaScript Object
How to Disable a Specific Li Element Inside a Ul
CSS Reveal from Corner Animation
How to Zoom in an Image and Center It
I Need List of All Class Name of Font-Awesome
Bootstrap 3 Compatible with Current Angularjs Bootstrap Directives
How to Position a Bootstrap Popover
How to Make JavaScript Scrollintoview Smooth
Remove Specific HTML Tag with Its Content from JavaScript String
Make a <Br> Instead of <Div></Div> by Pressing Enter on a Contenteditable
Get the Height of an Element Minus Padding, Margin, Border Widths