Padding values on inverted axis in jqplot

久未见 提交于 2019-12-29 09:04:49

问题


i would like to know how to set the correct padding values to a jqplot axis so that points aren't rendered on the borders.

this is the code i have

yaxis:{     
    max: 1,
    min: 200,
    numberTicks: 5,
    tickOptions:{
        formatString:'%i'
    }
 }

this displays an inverted axis going from 200 on the bottom to 1 on the top. values vary also from 1 to 200. i have tried with maxPad, minPad and even setting the ticks manually with ( ticks: ['200','150','100','50','1'] ) but no luck so far.

thanks in advance :)


回答1:


That was interesting and relaxing at the same time. The answer to your problem is obvious, since the padding settings are apparently ignored when setting min/max for an axis. Therefore, what you should use to move points away from the border is just increase min/max values just like in the code.

First graph has min/max increased to move the points away from the borders of the plot, the below one (created for the same data) does not.

To avoid this sort of issues and manual setting of these parameters why don't you have a method which could from the given data calculate and return min/max. Then in your graph for each of the values you apply the gap (pad) you like. Just as it is done with use of the minMax(data) method in the code.

BTW: Thanks for teaching me how to invert values of a plot I didn't know this trick. :)

EDIT

Please see another version which offers a solution that doesn't involve manipulating with the jqPlot script.

In this approach I am basically hiding the unwanted value labels, tick marks still are there. I am afraid that without interacting with canvas of the plot you cannot remove those unwanted ticks.



来源:https://stackoverflow.com/questions/10430972/padding-values-on-inverted-axis-in-jqplot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!