javascript - JqPlot- How to decrease the width of grids and ticks -
i trying deploy barchart using jqplot. how decrease width of grids , ticks? have removed gridline setting showgridline false, still showing vertically.
my screen.
i want x-axis ticks appear this.
my js code.
$(document).ready(function () { var s1 = [10, 20, 30, 40]; // can specify custom tick array. // ticks should match 1 each y value (category) in series. var ticks = [1, 2, 3, 4]; var plot1 = $.jqplot('chart1', [s1], { // "seriesdefaults" option options object // applied series in chart. seriesdefaults: { renderer: $.jqplot.barrenderer, rendereroptions: { barmargin: 2, barwidth: 15 } }, grid: { drawborder: false, background: '#ffffff', // css color spec background color of grid }, axesdefaults: { tickrenderer: $.jqplot.canvasaxistickrenderer, tickoptions: { marksize: 4 } }, axes: { // use category axis on x axis , use our custom ticks. xaxis: { pad: -1.05, renderer: $.jqplot.categoryaxisrenderer, ticks: ticks }, yaxis: { pad: 1.05, tickoptions: { formatstring: '%d', showgridline: false } } } }); });
may can help?
to remove gridlines, apply below property on both x-axis , y-axis:
tickoptions: { showgridline: false }
in code have set barwidth
15px. before drawing graph please make sure width of div
no less more number of x-axis tixks * 15 (approx).
or
adjust width of each bar @ runtime based on width of div
.
here example solves problem: jsfiddle link
html code:
<div id="chart1" style="margin-top:20px; margin-left:20px; width:310px; height:300px;"></div>
js code:
$(document).ready(function () { var s1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; // can specify custom tick array. // ticks should match 1 each y value (category) in series. var ticks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var plot1 = $.jqplot('chart1', [s1], { // "seriesdefaults" option options object // applied series in chart. seriesdefaults: { renderer: $.jqplot.barrenderer, rendereroptions: { barmargin: 2, barwidth: 25 }, shadow: false }, grid: { drawborder: false, background: '#ffffff', // css color spec background color of grid }, axesdefaults: { tickrenderer: $.jqplot.canvasaxistickrenderer, tickoptions: { marksize: 4 } }, axes: { // use category axis on x axis , use our custom ticks. xaxis: { pad: -1.05, renderer: $.jqplot.categoryaxisrenderer, ticks: ticks, tickoptions: { showgridline: false } }, yaxis: { pad: 1.05, tickoptions: { formatstring: '%d', showgridline: false } } } }); });
Comments
Post a Comment