Amchart 未使用数据初始化

Amchart not initialized with data

我的图表显示不正确,这是以下 ajax 代码,图表的缩略图不正确。 我正在使用 ajax 获取响应并初始化 amchart(区域)

Ajaxjson响应数据

{"success":true,"graph_data":[{"date":"2018-06-21","value":121.65},{"date":"2018-06-20","value":121.65},{"date":"2018-06-19","value":121.5},{"date":"2018-06-18","value":121.3},{"date":"2018-06-17","value":120.55},{"date":"2018-06-16","value":119.84},{"date":"2018-06-14","value":119.88}],"min_period":"DD","message":null}

这里是我为 amchart 初始化的代码

var chart = AmCharts.makeChart( "graph_chart_div", {
    "type": "serial",
    "theme": "light",
    "marginRight": 5,
    "marginLeft": 5,
    "minPeriod":response.min_period,
    "autoMarginOffset": 5,
    "dataDateFormat": "YYYY-MM-DD",
    "valueAxes": [ {
        "id": "v1",
        "axisAlpha": 0,
        "position": "left",
        "ignoreAxisWidth": true
    } ],
    "balloon": {
        "borderThickness": 1,
        "shadowAlpha": 0
    },
    "graphs": [ {
        "id": "g1",
        "balloon": {
            "drop": true,
            "adjustBorderColor": false,
            "color": "#ffffff",
            "type": "smoothedLine"
        },
        "fillAlphas": 0.2,
        "bullet": "round",
        "bulletBorderAlpha": 1,
        "bulletColor": "#FFFFFF",
        "bulletSize": 5,
        "hideBulletsCount": 50,
        "lineThickness": 2,
        "title": "red line",
        "useLineColorForBulletBorder": true,
        "valueField": "value",
        "balloonText": "<span style='font-size:18px;'>[[value]]</span>"
    } ],
    "chartCursor": {
        "valueLineEnabled": true,
        "valueLineBalloonEnabled": true,
        "cursorAlpha": 0,
        "zoomable": false,
        "valueZoomable": true,
        "valueLineAlpha": 0.5
    },
    "valueScrollbar": {
        "autoGridCount": true,
        "color": "#000000",
        "scrollbarHeight": 50
    },
    "categoryField": "date",
    "categoryAxis": {

        "gridPosition": "start",
        "labelRotation": 45,
        "minorGridEnabled": true,
        /* ENSURE 2 LINES BELOW ARE ADDED */
        "autoGridCount": false,
        "gridCount": 12,

        "parseDates": true,
        "dashLength": 1,
        // "minorGridEnabled": true
    },
    "export": {
        "enabled": false
    },
    // "dataProvider": graph_data
    "dataProvider": response.graph_data
} );

这是当前初始化的图表

我想为我的数据显示以下图表

您的日期数据有误。使用 parseDates 时,AmCharts 要求基于日期的数据按日期升序排列。

Important: If this is set to true, the data points needs to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart.

修复排序顺序后,您的图表将正确呈现。