Subversion Repositories php-qbpwcf

Rev

Rev 23 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 liveuser 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
<html>
3
 
4
    <head>
5
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
        <title>amCharts examples</title>
7
        <link rel="stylesheet" href="style.css" type="text/css">
8
        <script src="../amcharts/amcharts.js" type="text/javascript"></script>
9
        <script src="../amcharts/serial.js" type="text/javascript"></script>
10
 
11
        <script>
12
            var chartData = [
13
                {
14
                    "date": "2012-01-01",
15
                    "distance": 227,
16
                    "duration": 408
17
                },
18
                {
19
                    "date": "2012-01-02",
20
                    "distance": 371,
21
                    "duration": 482
22
                },
23
                {
24
                    "date": "2012-01-03",
25
                    "distance": 433,
26
                    "duration": 562
27
                },
28
                {
29
                    "date": "2012-01-04",
30
                    "distance": 345,
31
                    "duration": 379
32
                },
33
                {
34
                    "date": "2012-01-05",
35
                    "distance": 480,
36
                    "duration": 501
37
                },
38
                {
39
                    "date": "2012-01-06",
40
                    "distance": 386,
41
                    "duration": 443
42
                },
43
                {
44
                    "date": "2012-01-07",
45
                    "distance": 348,
46
                    "duration": 405
47
                },
48
                {
49
                    "date": "2012-01-08",
50
                    "distance": 238,
51
                    "duration": 309
52
                },
53
                {
54
                    "date": "2012-01-09",
55
                    "distance": 218,
56
                    "duration": 287
57
                },
58
                {
59
                    "date": "2012-01-10",
60
                    "distance": 349,
61
                    "duration": 485
62
                },
63
                {
64
                    "date": "2012-01-11",
65
                    "distance": 603,
66
                    "duration": 890
67
                },
68
                {
69
                    "date": "2012-01-12",
70
                    "distance": 534,
71
                    "duration": 810
72
                }
73
            ];
74
            var chart;
75
 
76
            AmCharts.ready(function () {
77
                // SERIAL CHART
78
                chart = new AmCharts.AmSerialChart();
79
                chart.dataProvider = chartData;
80
                chart.categoryField = "date";
81
                chart.dataDateFormat = "YYYY-MM-DD";
82
                chart.marginTop = 0;
83
 
84
                // AXES
85
                // category axis
86
                var categoryAxis = chart.categoryAxis;
87
                categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
88
                categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
89
                categoryAxis.autoGridCount = false;
90
                categoryAxis.gridCount = 50;
91
                categoryAxis.gridAlpha = 0;
92
                categoryAxis.gridColor = "#000000";
93
                categoryAxis.axisColor = "#555555";
94
                // we want custom date formatting, so we change it in next line
95
                categoryAxis.dateFormats = [{
96
                    period: 'DD',
97
                    format: 'DD'
98
                }, {
99
                    period: 'WW',
100
                    format: 'MMM DD'
101
                }, {
102
                    period: 'MM',
103
                    format: 'MMM'
104
                }, {
105
                    period: 'YYYY',
106
                    format: 'YYYY'
107
                }];
108
 
109
                // as we have data of different units, we create two different value axes
110
                // Duration value axis
111
                var durationAxis = new AmCharts.ValueAxis();
112
                durationAxis.title = "duration";
113
                durationAxis.gridAlpha = 0.05;
114
                durationAxis.axisAlpha = 0;
115
                durationAxis.tickLength = 0;
116
                durationAxis.inside = true;
117
                // the following line makes this value axis to convert values to duration
118
                // it tells the axis what duration unit it should use. mm - minute, hh - hour...
119
                durationAxis.duration = "mm";
120
                durationAxis.durationUnits = {
121
                    DD: "d. ",
122
                    hh: "h ",
123
                    mm: "min",
124
                    ss: ""
125
                };
126
                chart.addValueAxis(durationAxis);
127
 
128
                // Distance value axis
129
                var distanceAxis = new AmCharts.ValueAxis();
130
                distanceAxis.title = "distance";
131
                distanceAxis.gridAlpha = 0;
132
                distanceAxis.position = "right";
133
                distanceAxis.inside = true;
134
                distanceAxis.unit = "mi";
135
                distanceAxis.axisAlpha = 0;
136
                distanceAxis.tickLength = 0;
137
                chart.addValueAxis(distanceAxis);
138
 
139
                // GRAPHS
140
                // duration graph
141
                var durationGraph = new AmCharts.AmGraph();
142
                durationGraph.title = "duration";
143
                durationGraph.valueField = "duration";
144
                durationGraph.type = "line";
145
                durationGraph.valueAxis = durationAxis; // indicate which axis should be used
146
                durationGraph.lineColor = "#CC0000";
147
                durationGraph.balloonText = "[[value]]";
148
                durationGraph.lineThickness = 1;
149
                durationGraph.legendValueText = "[[value]]";
150
                durationGraph.bullet = "square";
151
                durationGraph.bulletBorderColor = "#CC0000";
152
                durationGraph.bulletBorderAlpha = 1;
153
                durationGraph.bulletBorderThickness = 1;
154
                chart.addGraph(durationGraph);
155
 
156
                // distance graph
157
                var distanceGraph = new AmCharts.AmGraph();
158
                distanceGraph.valueField = "distance";
159
                distanceGraph.title = "distance";
160
                distanceGraph.type = "column";
161
                distanceGraph.fillAlphas = 0.1;
162
                distanceGraph.valueAxis = distanceAxis; // indicate which axis should be used
163
                distanceGraph.balloonText = "[[value]] miles";
164
                distanceGraph.legendValueText = "[[value]] mi";
165
                distanceGraph.legendPeriodValueText = "total: [[value.sum]] mi";
166
                distanceGraph.lineColor = "#000000";
167
                distanceGraph.lineAlpha = 0;
168
                chart.addGraph(distanceGraph);
169
 
170
                // CURSOR
171
                var chartCursor = new AmCharts.ChartCursor();
172
                chartCursor.zoomable = false;
173
                chartCursor.categoryBalloonDateFormat = "DD";
174
                chartCursor.cursorAlpha = 0;
175
                chartCursor.valueLineEnabled = true;
176
                chartCursor.valueLineBalloonEnabled = true;
177
                chartCursor.valueLineAxis = distanceAxis;
178
                chart.addChartCursor(chartCursor);
179
 
180
                // LEGEND
181
                var legend = new AmCharts.AmLegend();
182
                legend.bulletType = "round";
183
                legend.equalWidths = false;
184
                legend.valueWidth = 120;
185
                legend.color = "#000000";
186
                legend.useGraphSettings = true;
187
                chart.addLegend(legend);
188
 
189
                // WRITE
190
                chart.write("chartdiv");
191
            });
192
        </script>
193
    </head>
194
 
195
    <body>
196
        <div id="chartdiv" style="width:100%; height:400px;"></div>
197
    </body>
198
 
199
</html>