简体   繁体   English

如何在amCharts股票图表中使用多个数据集?

[英]How to use multiple datasets in amCharts Stock chart?

I have two datasets and want to use them to display the line charts in amCharts Stock Chart. 我有两个数据集,并希望使用它们在amCharts股票图表中显示折线图。 This is the fiddle. 这是小提琴。 It only shows the data from the first dataset. 它仅显示来自第一个数据集的数据。

 "stockGraphs": [ 
    {
      "id": "g1",
      "title": "Graph #1",
      "lineThickness": 2,
      "valueField": "value1",
      "useDataSetColors": false,
      "valueAxis" : "axis1",


    }, 

    {
      "id": "g2",
      "title": "Graph #2",
      "lineThickness": 5,
      "valueField": "value2",
      "useDataSetColors": false,
      "connect" : false,
       "valueAxis" : "axis2"

    }

https://jsfiddle.net/a0p3vm8r/1/ https://jsfiddle.net/a0p3vm8r/1/

I am sure there is a simple JSON config missing somewhere. 我确定某个地方缺少简单的JSON配置。 Can someone please help me with this? 有人可以帮我吗?

There are a few things that need to be done in order to display graphs from the compared data sets. 为了显示来自比较数据集的图形,需要做一些事情。

1) Make the second data set compared by setting compared: true . 1)通过设置compared: truecompared: true第二个数据集。

2) Set comparable: true and compareField for the second graph. 2)为第二张图设置comparable: truecompareField

3) Your fiddle code creates data for the second data set with "value1" as a value field, while graph valueField refers to "value2". 3)您的小提琴代码使用“ value1”作为值字段为第二个数据集创建数据,而图形valueField引用“ value2”。

Here's your chart with all of the above applied: 这是应用了以上所有功能的图表:

https://jsfiddle.net/a0p3vm8r/2/ https://jsfiddle.net/a0p3vm8r/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM