2016-11-03 8 views
0

シリアルタイプの棒グラフにトレンドラインを追加する方法については、ドキュメントに従っています。AmCharts - トレンドバーを作成するのに役立つ

AmCharts.makeChart('chartdiv', { 
     type: 'serial', 
     addClassNames: true, 
     theme: 'light', 
     dataProvider: data, 
     startDuration: 1, 
     categoryField: 'month', 
     graphs: [ 
     { 
      valueField: 'complaints', 
      type: 'column', 
      fillAlphas: 0.8, 
      balloonText: "# of complaints on [[category]]: <b>[[value]]</b>" 
     }, 
     { 
      valueField: 'expectation', 
      type: 'line', 
      // bullet: 'round', 
      lineColor: 'green', 
      balloonText: "Expected less than <b>[[value]]</b> for [[category]]", 
      dashLengthField: "dashLengthLine" 
     } 
     ], 
     categoryAxis: { 
     autoGridCount: false, 
     gridCount: data.length, 
     gridPosition: "start", 
     // labelRotation: 90 
     }, 
     export: { 
     enabled: true 
     }, 

     trendLines: [{ 
      initialValue: 6, 
      finalValue: 8 
     }] 
    }); 

trendingLinesはあまりありません。私はそれを宣言するために多くの方法で試しましたが、運はありません。ここでは私が作業しているデータの一部です:

[{ 
    "expectation": 2, 
    "tendValue": 1, 
    "month": "January", 
    "complaints": 1 
    }, { 
    "expectation": 2, 
    "month": "February", 
    "complaints": 2 
    }, { 
    "expectation": 2, 
    "month": "March", 
    "complaints": 0 
    }, { 
    "expectation": 2, 
    "month": "April", 
    "complaints": 1 
    }, { 
    "expectation": 2, 
    "month": "May", 
    "complaints": 0 
    }, { 
    "expectation": 2, 
    "month": "June", 
    "complaints": 1 
    }, { 
    "expectation": 2, 
    "month": "July", 
    "complaints": 2 
    }, { 
    "expectation": 2, 
    "month": "August ", 
    "complaints": 1 
    }, { 
    "expectation": 2, 
    "month": "September", 
    "complaints": 3 
    }, { 
    "expectation": 2, 
    "month": "October", 
    "complaints": 1 
    }, { 
    "expectation": 2, 
    "month": "November", 
    "complaints": 2 
    }, { 
    "expectation": 2, 
    "tendValue": 3, 
    "month": "December", 
    "complaints": 3 
    } ] 
+0

実際のご質問はありましたか? – Tibrogargan

答えて

1

あなたが欠落しているのは、開始点と終了点の宣言です。トレンドラインにはその値だけを伝えます。

トレンドラインの最小コードはsthである必要があります。

{ 
    "finalDate": "2012-01-22 12", 
    "finalValue": 10, 
    "initialDate": "2012-01-17 12", 
    "initialValue": 16 
} 

またはあなたのケースでinitialCategoryfinalCategoryを使用してこのような。トレンドラインのパラメータの詳細については、class referenceをご覧ください。demoをご覧ください。

関連する問題