如何在amchart条形图中删除或隐藏类别名称

时间:2017-07-13 09:18:29

标签: javascript angularjs amcharts

我需要从条形图中删除类别字段。请告诉我该怎么做。

如果我把标签放在假的里面,那就是左边的。我需要把它完全从吧台上移走。

还要检查这个jsFiddle

https://jsfiddle.net/ArunKumarUmma/21wm5hf5/6/

var chart = AmCharts.makeChart( "chartdiv", {
  "type": "serial",
  "theme": "light",
  "dataProvider": [ {
    "Index":"2.45",
"amt":"148,773.88",
"amt1":"60,794.55",
"color":"#ba5bbb",
"color1":"#428DB6",
"name":"Name1",
"value":"148773.88",
"value1":"60794.55"

  }, {
   "Index":"2.45",
"amt":"148,773.88",
"amt1":"60,794.55",
"color":"#ba5bbb",
"color1":"#428DB6",
"name":"Name2",
"value":"148773.88",
"value1":"60794.55"
  }, {
   "Index":"2.45",
"amt":"148,773.88",
"amt1":"60,794.55",
"color":"#ba5bbb",
"color1":"#428DB6",
"name":"Name3",
"value":"148773.88",
"value1":"60794.55"
  }, {
    "Index":"2.45",
"amt":"148,773.88",
"amt1":"60,794.55",
"color":"#ba5bbb",
"color1":"#428DB6",
"name":"Name4",
"value":"148773.88",
"value1":"60794.55"
  }, {
    "Index":"2.45",
"amt":"148,773.88",
"amt1":"60,794.55",
"color":"#ba5bbb",
"color1":"#428DB6",
"name":"Name5",
"value":"148773.88",
"value1":"60794.55"
  }],
   "type": "serial",
              "theme": "light",
              "categoryField": "name",
              "rotate": true,
              "startDuration": 1,
              "startEffect":"easeOutSine",
               "columnSpacing": 0,
              "autoMargins": false,
              "marginBottom": 0,
             "pullOutRadius": 0,
              "categoryAxis": {
                  "inside": true,
                   "gridPosition": "start",
                   "gridAlpha": 0,
                   "axisAlpha": 0,
                   "tickPosition": "start",
                   "tickLength": 0,
                  "position": "left"
              },
              "trendLines": [],
              "graphs": [
                {
                  "balloonText": " [[name]]: $[[amt]]<br> Index: [[Index]]",
                  "fillAlphas": 0.8,
                  "fillColorsField": "color1",
                  "id": "AmGraph-12",
                  "lineAlpha": 0.2,
                  "title": "amt",
                  "type": "column",
                  "valueField": "value",
                  "showHandOnHover":true,
                  "labelText": "[[Index]]",
                  "labelPosition": "right",

                  "fixedColumnWidth": 15
                },
                {
                  "balloonText": " [[name]]: $[[amt1]]",
                  "fillAlphas": 0.8,
                  "fillColorsField": "color",
                  "id": "AmGraph-22",
                  "lineAlpha": 0.2,
                  "title": "amt",
                  "type": "column",
                  "valueField": "value1",
                  "showHandOnHover":true,
                  "fixedColumnWidth": 15
                }
              ],
              "guides": [],
              "valueAxes": [
                {
                  "id": "ValueAxis-1",
                  "axisAlpha": 0,
                  "gridAlpha": 0,
                  "labelsEnabled": false,
                  "minimum":0
                }
              ],
              "allLabels": [],
              "balloon": {
              "fillColor": "#000000",
               "color": "#ffffff",
               "fillAlpha": 1.0,
                "offsetX": 0,
                  "offsetY": 0,
                  "horizontalPadding":0,
                  "maxWidth":100
              },
              "titles": [],
              "export": {
                "enabled": true
              }


} );

Please check the image what i required exactly

2 个答案:

答案 0 :(得分:1)

您可以通过在categoryAxis对象中将labelsEnabled设置为false来隐藏类别轴标签。

要删除条形图右侧的值标签,请删除图表对象中的labelText定义。

Updated fiddle

答案 1 :(得分:0)

只需在您的代码中添加"hideCredits":true

它将隐藏文本“ Amcharts的JSCharts”。

amcharts:any;

this.amcharts = AmCharts.makeChart("chartdiv", {
  "type": "serial", "theme": "none",
  "hideCredits":true,
  "pathToImages": "/lib/3/images/",
  "dataProvider": this.myList,
  "valueAxes": [{ "id": "v1", "axisAlpha": 0, "position": "left" }, { "id": "v2", "axisAlpha": 0, "position": "right", "unit": "%", "gridAlpha": 0, "maximum": 100 }],
  "startDuration": 1,
  "graphs": [{ "fillAlphas": 1, "title": "value", "type": "column", "valueField": "value" }, { "valueAxis": "v2", "bullet": "round", "lineThickness": 3, "bulletSize": 7, "bulletBorderAlpha": 1, "bulletColor": "#FFFFFF", "useLineColorForBulletBorder": true, "fillAlphas": 0, "lineAlpha": 1, "title": "Value", "valueField": "Value" }],
  "categoryField": "name",
  "categoryAxis": { "gridPosition": "start", "axisAlpha": 0, "tickLength": 2, "labelRotation": 90}
});