javascript 如何禁用 x 轴 amcharts 的标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30734717/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 12:38:56  来源:igfitidea点击:

How to disable the labels of x-axis amcharts

javascriptamcharts

提问by Umesh

I am trying not to show the labels of x-axis, which in this case are: "7.5, 8.0, 8.5, 9.0" and so on.

我试图不显示 x 轴的标签,在这种情况下是:“7.5、8.0、8.5、9.0”等等。

This is what I have tried so far:

这是我迄今为止尝试过的:

<div id="chartdiv"></div>

var chart = AmCharts.makeChart("chartdiv", {
"theme": "light",
"type": "serial",
"dataProvider": [{
    "name": "3s",
    "startTime": 8,
    "endTime": 11,
    "color": "#FF0F00"
}],
"valueAxes": [{
    "axisAlpha": 0,
    "gridAlpha": 0.1
}],
"startDuration": 1,
"graphs": [{
    "balloonText": "<b>[[category]]</b><br>starts at [[startTime]]<br>ends at [[endTime]]",
    "colorField": "color",
    "fillAlphas": 0.8,
    "lineAlpha": 0,
    "openField": "startTime",
    "type": "column",
    "valueField": "endTime"
}],
"rotate": true,
"columnWidth": 1,
"categoryField": "name",  
});

JSFiddle Demo

JSFiddle 演示

回答by martynasma

Use labelsEnabledon your value axis:

使用labelsEnabled您的值轴:

"valueAxes": [{
    "axisAlpha": 0,
    "gridAlpha": 0.1,
    "labelsEnabled": false
}],

Here's the updated fiddle.

这是更新的 fiddle

回答by Oleg Neumyvakin

labelsEnabledcan be used in categoryAxisas well:

labelsEnabled也可以用于categoryAxis

"categoryAxis": {
    "axisColor": "#555555",
    "gridAlpha": 0.1,
    "gridColor": "#FFFFFF",
    "gridCount": 50,        
    "labelsEnabled": false
},

回答by user2992355

Use integersOnlyon your valueAxisproperty:

integersOnly在您的valueAxis财产上使用:

"valueAxes":[{
    "integersOnly": true
}],

Now your value will be displayed like 7, 8, 9...

现在您的值将显示为 7, 8, 9 ...