javascript jqPlot:隐藏轴刻度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5948866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jqPlot: hide axis ticks?
提问by Ollie Glass
Here's a default jqPlot axis with ticks:
这是一个带有刻度的默认 jqPlot 轴:
Setting "showTicks: false" on the x-axis removes everything:
在 x 轴上设置 "showTicks: false" 会删除所有内容:
I want to display the numbers and hide the ticks - the little dashes between the numbers and the thick axis line. Is this possible?
我想显示数字并隐藏刻度 - 数字和粗轴线之间的小破折号。这可能吗?
回答by reckbo
axesDefaults: {
showTickMarks:false
}
showTicks toggles the tick marks and the tick labels, and showTickMarks toggles only the tick marks.
showTicks 切换刻度线和刻度标签,而 showTickMarks 仅切换刻度线。
Check out the options at: http://www.jqplot.com/docs/files/jqPlotOptions-txt.html
查看以下选项:http: //www.jqplot.com/docs/files/jqPlotOptions-txt.html
EDIT: I mistakenly had showTicks in the code snippet, which I fixed.
编辑:我错误地在我修复的代码片段中使用了 showTicks。
回答by Olmstov
Not sure if the framework changed since this answer but it didn't work for me.
不确定自这个答案以来框架是否发生了变化,但它对我不起作用。
Here's what did (I left all the fluff so you can see where the axesDefaults live).
这是做了什么(我留下了所有的绒毛,所以你可以看到轴默认值所在的位置)。
var plot1 = $.jqplot ('chart1', [line1, badLine], {
title:'Data Point Highlighting',
axesDefaults:{
tickOptions:{
showMark: false
}
},
axes:{
xaxis:{
tickInterval:1,
min:0.5,
ticks: [[0.5,""],[1,"1"],[2,"2"],[2.5,""]]
},
yaxis:{
ticks: [['25', ""], ['24', "12am"], ['22', "2am"], '20', '18', ['16',"4pm"], '14', '12', '10', '8', '6', '4', '2', '0'],
min:0,
max:24,
}
},
series:[
{
showLine: false
},
{
showLine: false,
markerOptions: { style:"x" }
}
],
highlighter:{
show: true,
sizeAdjust: 7.5
},
cursor:{
show: false
}
});
http://www.jqplot.com/docs/files/jqplot-core-js.html#jqPlot.axesDefaults
http://www.jqplot.com/docs/files/jqplot-core-js.html#jqPlot.axesDefaults