0

我正在使用股票类型的 AmCharts 来显示图表。问题是在移动设备上它消耗触摸并且不滚动。我已经设置了"panEventsEnabled": false。但它仍然会消耗触摸,在桌面浏览器上我仍然可以平移图表。我不明白为什么它没有禁用 panEvent。

下面是我的图表对象。panEventsEnabled=false设置在最后。

var chartObject = {
"type": "stock",
    "theme": "light",
    "categoryAxesSettings": {
      "minPeriod": "mm",
      "maxSeries": 250,
      "groupToPeriods": [ "mm", "10mm", "30mm", "hh", "3hh", "DD", "3DD", "WW", "MM", "YYYY"]
    },
    "dataSets": [ {
      "color": "#00e673",
      "fieldMappings": [ {
        "fromField": "close",
        "toField": "value"
      }, {
        "fromField": "volumeto",
        "toField": "volume"
      } ],
      "categoryField": "time"
    }],
    "balloon": {},
    "panels": [ {
      "showCategoryAxis": true,
      "categoryBalloonEnabled": false,
      "recalculateToPercents": "never",
      "title": "Value",
      "percentHeight": 60,

      "stockGraphs": [ {
        "id": "g1",
        "title": Value,
        "precision": 2,
        "valueField": "value",
        "type": "line",
        "compareable": true,
        "lineThickness": 2,
        "balloonText": "close: [[value]]",
        "fillAlphas": 0.6
      } ],


      "stockLegend": {
        "valueTextRegular": ": [[value]]"
      }
    }, {
      "title": "Volume",
      "percentHeight": 30,
      "stockGraphs": [ {
        "precision": 2,
        "valueField": "volume",
        "type": "column",
        "cornerRadiusTop": 2,
        "fillAlphas": 1
      } ],

      "stockLegend": {
        "valueTextRegular": "Volume: [[value]]"
      }
    } ],

    "chartScrollbarSettings": {
      "graph": "g1",
      "usePeriod": "10mm",
      "position": "bottom"
    },

    "chartCursorSettings": {
      "valueBalloonsEnabled": true,
      "fullWidth": true,
      "cursorColor": "#ff0000",
      "cursorAlpha": 0.1,
      "valueLineBalloonEnabled": true,
      "valueLineEnabled": true,
      "valueLineAlpha": 0.5
    },

    "periodSelector": {
      "position": "top",
      "dateFormat": "YYYY-MM-DD JJ:NN",
      //"periodContainer":{},
      "hideOutOfScopePeriods":false,
      "inputFieldsEnabled": false,
      "inputFieldWidth": 100,
      "periods": [ {
        "period": "mm", //histomin limit 60
        "count": 60,
        "minPeriod": "mm",
        "label": "1H"
      }, {
        "period": "mm",//histomin limit 1440 //autogroup
        "minPeriod": "mm",
        "count": 1440,
        "label": "1D"
      },{
        "period": "DD",//histohour limit 168
        "count": 7,
        "label": "1W"
      }, {
        "period": "MM",//histohour limit 744 
        "count": 1,
        "label": "1M"
      }, {
        "period": "MM",//histoday limit 93
        "count": 3,
        "label": "3M"
      },{
        "period": "YYYY",//histoday limit 365
        "count": 1,
        "label": "1Y"
      }, {
        "period": "MAX",//histoday all
        "label": "MAX"
      } ]
    },

    "panelsSettings": {
      "usePrefixes": false,
      "creditsPosition":"bottom-left",
      "panEventsEnabled": false
    },
   };
4

1 回答 1

1

改用响应式插件并覆盖selectWithoutZooming

"responsive": {
    "enabled": true,
    "rules": [{
        "maxWidth": 800,
        "overrides": {
            "chartCursorSettings": {
                "selectWithoutZooming": true
            }
        }
    }]
}

在此处查看示例:https ://codepen.io/team/amcharts/pen/80a7ccf3fb8d2c04d00ef9121ca0806c?editors=1010

于 2018-01-23T04:12:14.360 回答