Blame view

samples/lineStepNoRisers.html 4.44 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  <!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 graph;
  
             var chartData = [
                  {
                      "year": "1950",
                      "value": 0.22
                  },
                  {
                      "year": "1951",
                      "value": 0.168
                  },
                  {
                      "year": "1952",
                      "value": 0.103
                  },
                  {
                      "year": "1953",
                      "value": 0.067
                  },
                  {
                      "year": "1954",
                      "value": 0.151
                  },
                  {
                      "year": "1955",
                      "value": 0.281
                  },
                  {
                      "year": "1956",
                      "value": 0.348
                  },
                  {
                      "year": "1957",
                      "value": 0.274
                  },
                  {
                      "year": "1958",
                      "value": 0.211
                  },
                  {
                      "year": "1959",
                      "value": 0.174
                  },
                  {
                      "year": "1960",
                      "value": 0.124
                  },
                  {
                      "year": "1961",
                      "value": 0.064
                  },
                  {
                      "year": "1962",
                      "value": 0.032
                  },
                  {
                      "year": "1963",
                      "value": 0.05
                  },
                  {
                      "year": "1964",
                      "value": 0.106
                  }
              ];
  
  
             AmCharts.ready(function () {
                 // SERIAL CHART
                 chart = new AmCharts.AmSerialChart();
                 chart.pathToImages = "../amcharts/images/";
                 chart.marginRight = 0;
                 chart.marginTop = 0;
                 chart.dataProvider = chartData;
                 chart.categoryField = "year";
                 chart.dataDateFormat = "YYYY";
                 chart.color = "#FFFFFF";
  
                 chart.backgroundImage = "images/bgSky.jpg";
  
                 // AXES
                 // Category
                 var categoryAxis = chart.categoryAxis;
                 categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
                 categoryAxis.minPeriod = "YYYY"; // our data is yearly, so we set minPeriod to YYYY
                 categoryAxis.gridCount = 20;
                 categoryAxis.autoGridCount = false;
                 categoryAxis.axisAlpha = 0.3;
                 categoryAxis.axisColor = "#FFFFFF";
                 categoryAxis.gridAlpha = 0.05;
  
                 // VALUE
                 var valueAxis = new AmCharts.ValueAxis();
                 valueAxis.gridAlpha = 0;
                 valueAxis.axisAlpha = 0.3;
                 valueAxis.axisColor = "#FFFFFF";
                 valueAxis.showLastLabel = false;
                 chart.addValueAxis(valueAxis);
  
                 // GRAPH
                 graph = new AmCharts.AmGraph();
                 graph.type = "step"; // this line makes step graph
                 graph.noStepRisers = true;
                 graph.valueField = "value";
                 graph.lineColor = "#FFFFFF";
                 graph.lineThickness = 1;
                 graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>";
                 chart.addGraph(graph);
  
                 // CURSOR
                 var chartCursor = new AmCharts.ChartCursor();
                 chartCursor.cursorAlpha = 0;
                 chartCursor.cursorPosition = "mouse";
                 chartCursor.categoryBalloonDateFormat = "YYYY";
                 chart.addChartCursor(chartCursor);
  
                 chart.creditsPosition = "top-right";
  
                 // WRITE
                 chart.write("chartdiv");
             });
  		</script>
  	</head>
  
      <body>
          <div id="chartdiv" style="width: 800px; height: 500px;"></div>
      </body>
  
  </html>