如何在amstock图表上显示多个折线图?

时间:2019-01-16 05:24:13

标签: javascript reactjs amcharts jstockchart

我正在使用amstock图表,但在比较数据时似乎图表根本无法工作。如果单击比较,则其他图表将无法获得价值。

我尝试使用amstock图表选项设置,但仍然无法正常工作。

export let Config = (configDataSets) => {
  let dataSets = []

  configDataSets.forEach((configDataSet, i) => {    
    dataSets.push({
      "title": configDataSet.title,
      "fieldMappings": [{
        "fromField": "value",
        "toField": "value"
      }],
      "dataProvider": configDataSet.dataProvider,
      "categoryField": "date"
    })
  })

  let config = {
    "type": "stock",
    "theme": "light",
    "dataSets": dataSets,
    "panels": [{
      "showCategoryAxis": false,
      "title": "Value",
      "categoryAxis": {},
      "percentHeight": 70,
      "stockGraphs": [{
        "id": "g1",
        "bullet": "round",
        "valueField": "value",
        "comparable": true,
        "compareField": "value",
        "balloonText": "[[title]]:<b>[[value]]</b>",
        "compareGraphBalloonText": "[[title]]:<b>[[value]]</b>"
      }],
      "stockLegend": {
        "periodValueTextComparing": "[[percents.value.close]]%",
        "periodValueTextRegular": "[[value.close]]"
      }
    }, {
      "title": "Value",
      "percentHeight": 30,
      "stockGraphs": [{
        "valueField": "value",
        "type": "column",
        "showBalloon": false,
        "fillAlphas": 1
      }],
      "stockLegend": {
        "periodValueTextRegular": "[[value.close]]"
      }
    }],

    "chartScrollbarSettings": {
      "graph": "g1"
    },

    "chartCursorSettings": {
      "valueBalloonsEnabled": true,
      "fullWidth": true,
      "cursorAlpha": 0.1
    },

    "panelsSettings": {
      "recalculateToPercents": "never"
    },

    "periodSelector": {
      "position": "left",
      "periods": [ {
        "period": "MM",
        "selected": true,
        "count": 1,
        "label": "1 month"
      }, {
        "period": "YYYY",
        "count": 1,
        "label": "1 year"
      }, {
        "period": "YTD",
        "label": "YTD"
      }, {
        "period": "MAX",
        "label": "MAX"
      } ]
    },

    "dataSetSelector": {
      "position": "left",
    },

    "export": {
      "enabled": true
    },

    "responsive": {
      "enabled": true
    }
  }

  return config
}

比较数据时我期望的是,其他数据将显示其折线图或值

0 个答案:

没有答案