未显示的AmChart列可能是由于数据集问题

时间:2018-10-19 07:43:02

标签: amcharts

嗨,大家好,您确实有一个图表出现问题,只是没有出现。

我认为问题与我必须显示的列数有关,因为只有少量数据正在工作。

比当我将所有数据都放在图表中时,它停止工作了。我不认为这是对弹itself本身的限制。

我在这里发布我的代码

<script>

var chart = AmCharts.makeChart( "confrontogas", {
  "type": "serial",
  "theme": "light",
  "dataProvider": [ {
            "offerta": "Energia Italia 150€",
            "costo": 150,
            "color": "#0C3B54",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 229,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 418,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 419,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 420,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 425,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         },{
            "offerta": "",
            "costo": 1,460,
            "color": "#CACACA",
            "labelcolor": "#FFFFFF"
         } ],
  "valueAxes": [ {
    "gridColor": "#FFFFFF",
    "gridAlpha": 0,
    "dashLength": 0,
    "axisAlpha": 0,
    "minimum": 0,
    "labelsEnabled": false
  } ],
  "gridAboveGraphs": true,
  "startDuration": 1,
  "graphs": [ {
    "balloonText": "<b>[[value]]</b> €",
    "fillAlphas": 0.8,
    "lineAlpha": 0.2,
    "type": "column",
    "colorField": "color",
    "valueField": "costo"
  } ],
  "chartCursor": {
    "categoryBalloonEnabled": false,
    "cursorAlpha": 0,
    "zoomable": false
  },
  "categoryField": "offerta",
  "categoryAxis": {
    "gridPosition": "start",
    "gridAlpha": 0,
    "tickPosition": "start",
    "tickLength": 0,
    "labelRotation": 90,
    "autoGridCount": false,
    "gridCount": 548,
    "equalSpacing": true,
    "inside": true,
    "labelFrequency": 1,
    "labelColorField": "labelcolor",
    "forceShowField": "true"
  },


  "export": {
    "enabled": true
  }

} );

如您所见 “ gridCount”:548, 我发布了更少的数据只是为了保持简单

1 个答案:

答案 0 :(得分:2)

根据小提琴中的最后一个数据点,您的valueField costo具有带逗号的数字值,这不是有效的JavaScript:

{
    "offerta": "",
    "costo": 1,460, //should be 1460 or 1.460 depending on what ',' means in your region
    "color": "#CACACA",
    "labelcolor": "#FFFFFF"
}

确保您的数字数据只包含数字或小数点(.)。 AmCharts将自动使用逗号作为分隔符,将点使用小数点表示小数点来格式化您的值,但是数字值必须首先在JavaScript中有效。如果您的值有效,则需要在输出中更改分隔符,请使用thousandsSeparatordecimalSeparator