有没有办法在没有比较amchart中的选项的情况下显示多个数据集?

时间:2018-01-16 11:21:29

标签: amcharts

Here is my fiddle

我不想显示与阻止比较,我试图使其可以伪造,但这不起作用。

"stockGraphs": [ {
  "id": "g1",
  "valueField": "value",
  "comparable": false,
  "compareField": "value",
  "balloonText": "[[title]]:<b>[[value]]</b>",
  "compareGraphBalloonText": "[[title]]:<b>[[value]]</b>"
} ],

1 个答案:

答案 0 :(得分:1)

您可以在其他数据集中将compared设置为true(忽略第一个,因为默认情况下始终显示),以便在不使用选择器的情况下显示数据集:

  "dataSets": [ {
      "title": "first data set",
      "fieldMappings": [ {
        "fromField": "value",
        "toField": "value"
      }, {
        "fromField": "volume",
        "toField": "volume"
      } ],
      "dataProvider": chartData1, 
      //don't set compared in the first dataset or it will be displayed twice
      "categoryField": "date"
    }, {
      "title": "second data set",
      "fieldMappings": [ {
        "fromField": "value",
        "toField": "value"
      }, {
        "fromField": "volume",
        "toField": "volume"
      } ],
      "dataProvider": chartData2,
      "compared": true,
      "categoryField": "date"
    },
    // ... etc

如果要显示其他数据集而不更改百分比,请在所需面板中将recalculateToPercents设置为"never",或在panelsSettings中全局设置。

Updated fiddle

修改

如果您想隐藏“比较到”:部分,请添加以下CSS:

.amcharts-compare-div {
  display: none;
}

/* hide the br tags before and after the dropdown, brining the compare to box up */
.amcharts-data-set-selector-div br:first-child, .amcharts-data-set-selector-div br+select+br, .amcharts-data-set-selector-div br+select+br+br {
  display: none;
}

您还需要将dataSetSelector的compareText属性设置为空字符串。

Updated fiddle