javascript - Centering a flot chart relative to the chart plotted instead of the canvas size. -


hey i'm working on application uses flot charts extensively. manager tasked me "centering" charts not way right now.

by default generate canvas size leaves room on y-axis data, , leads offset canvas centered leaving chart slight offset right.

i know nitpicky issue i'm wondering if there's implementable way make chart center relative chart itself, possibly extending right-side canvas equal left, or making y-axis generate in text form leaving chart canvas.

i've tried read through flot api solution nothing jumps out @ me.

if i'm understanding correctly, looking grid's margin property.

grid:{     margin:{        right: 17,        top: 17     } } 

see fiddle here.

for comment

to set right margin equal left margin dynamically, let flot draw plot once, set right margin equal yaxis's width , redraw plot:

p = $.plot( ... p.getoptions().grid.margin.right = p.getyaxes()[0].box.width;    p.setupgrid(); p.draw(); 

updated fiddle. run multple times see how works dynamically.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -