Blame view

samples/errorChart.html 3.75 KB
aaa287d94   Jeff Chen   NN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  <html>
      
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <title>amCharts examples</title>
          <link rel="stylesheet" href="style.css" type="text/css">
          <script src="../amcharts/amcharts.js" type="text/javascript"></script>
          <script src="../amcharts/serial.js" type="text/javascript"></script>
          
          <script type="text/javascript">
              var chart;
              var chartData = [
                  {
                      "year": 2005,
                      "value": 11.5,
                      "error": 5
                  },
                  {
                      "year": 2006,
                      "value": 26.2,
                      "error": 5
                  },
                  {
                      "year": 2007,
                      "value": 30.1,
                      "error": 5
                  },
                  {
                      "year": 2008,
                      "value": 29.5,
                      "error": 7
                  },
                  {
                      "year": 2009,
                      "value": 24.6,
                      "error": 10
                  }
              ];
  
  
              AmCharts.ready(function () {
                  // SERIAL CHART  
                  chart = new AmCharts.AmSerialChart();
                  chart.pathToImages = "../amcharts/images/";
                  chart.dataProvider = chartData;
                  chart.categoryField = "year";
                  chart.startDuration = 1;
                  chart.balloon.textAlign = "left";
  
                  // AXES
                  // category
                  var categoryAxis = chart.categoryAxis;
                  categoryAxis.gridPosition = "start";
                  categoryAxis.dashLength = 3;
                  categoryAxis.axisAlpha = 0;
  
                  // value
                  var valueAxis = new AmCharts.ValueAxis();
                  valueAxis.axisAlpha = 0;
                  valueAxis.dashLength = 3;
                  chart.addValueAxis(valueAxis);
  
                  // GRAPHS
                  var graph1 = new AmCharts.AmGraph();
                  graph1.valueField = "value";
                  graph1.lineColor = "#ff339d";
                  graph1.lineThickness = 2;
                  graph1.bullet = "yError";
                  graph1.errorField = "error";
                  graph1.bulletSize = 10; // when bulletAxis is set, this property affects only width of error bar
                  graph1.bulletAxis = valueAxis;
                  graph1.balloonText = "value:<b>[[value]]</b><br>error:<b>[[error]]</b>";
                  chart.addGraph(graph1);
  
                  // one more graph added for circle bullets, as onew graph can show one bullet type only
                  var graph2 = new AmCharts.AmGraph();
                  graph2.valueField = "value";
                  graph2.lineColor = "#ff339d";
                  graph2.lineThickness = 2;
                  graph2.lineAlpha = 0;
                  graph2.bullet = "round";
                  graph2.bulletBorderThickness = 2;
                  graph2.bulletBorderColor = "#FFFFFF";
                  graph2.bulletBorderAlpha = 1;
                  graph2.showBalloon = false;
                  chart.addGraph(graph2);
  
                  // CURSOR
                  var chartCursor = new AmCharts.ChartCursor();
                  chartCursor.cursorAlpha = 0;
                  chartCursor.zoomable = false;
                  chartCursor.cursorPosition = "mouse";
                  chartCursor.graphBulletSize = 1;
                  chart.addChartCursor(chartCursor);
  
                  // WRITE
                  chart.write("chartdiv");
              });
          </script>
      </head>
      
      <body>
          <div id="chartdiv" style="width:700px; height:400px;"></div>
      </body>
  
  </html>