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
        <script>
11
            var chart;
12
            var chartData = [];
13
            var chartCursor;
14
 
15
 
16
 
17
            AmCharts.ready(function () {
18
                // generate some data first
19
                generateChartData();
20
 
21
                // SERIAL CHART
22
                chart = new AmCharts.AmSerialChart();
23
 
24
                chart.dataProvider = chartData;
25
                chart.categoryField = "date";
26
                chart.balloon.bulletSize = 5;
27
 
28
                // listen for "dataUpdated" event (fired when chart is rendered) and call zoomChart method when it happens
29
                chart.addListener("dataUpdated", zoomChart);
30
 
31
                // AXES
32
                // category
33
                var categoryAxis = chart.categoryAxis;
34
                categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
35
                categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
36
                categoryAxis.dashLength = 1;
37
                categoryAxis.minorGridEnabled = true;
38
                categoryAxis.twoLineMode = true;
39
                categoryAxis.dateFormats = [{
40
                    period: 'fff',
41
                    format: 'JJ:NN:SS'
42
                }, {
43
                    period: 'ss',
44
                    format: 'JJ:NN:SS'
45
                }, {
46
                    period: 'mm',
47
                    format: 'JJ:NN'
48
                }, {
49
                    period: 'hh',
50
                    format: 'JJ:NN'
51
                }, {
52
                    period: 'DD',
53
                    format: 'DD'
54
                }, {
55
                    period: 'WW',
56
                    format: 'DD'
57
                }, {
58
                    period: 'MM',
59
                    format: 'MMM'
60
                }, {
61
                    period: 'YYYY',
62
                    format: 'YYYY'
63
                }];
64
 
65
                categoryAxis.axisColor = "#DADADA";
66
 
67
                // value
68
                var valueAxis = new AmCharts.ValueAxis();
69
                valueAxis.axisAlpha = 0;
70
                valueAxis.dashLength = 1;
71
                chart.addValueAxis(valueAxis);
72
 
73
                // GRAPH
74
                var graph = new AmCharts.AmGraph();
75
                graph.title = "red line";
76
                graph.valueField = "visits";
77
                graph.bullet = "round";
78
                graph.bulletBorderColor = "#FFFFFF";
79
                graph.bulletBorderThickness = 2;
80
                graph.bulletBorderAlpha = 1;
81
                graph.lineThickness = 2;
82
                graph.lineColor = "#5fb503";
83
                graph.negativeLineColor = "#efcc26";
84
                graph.hideBulletsCount = 50; // this makes the chart to hide bullets when there are more than 50 series in selection
85
                chart.addGraph(graph);
86
 
87
                // CURSOR
88
                chartCursor = new AmCharts.ChartCursor();
89
                chartCursor.cursorPosition = "mouse";
90
                chartCursor.pan = true; // set it to fals if you want the cursor to work in "select" mode
91
                chart.addChartCursor(chartCursor);
92
 
93
                // SCROLLBAR
94
                var chartScrollbar = new AmCharts.ChartScrollbar();
95
                chart.addChartScrollbar(chartScrollbar);
96
 
97
                chart.creditsPosition = "bottom-right";
98
 
99
                // WRITE
100
                chart.write("chartdiv");
101
            });
102
 
103
            // generate some random data, quite different range
104
            function generateChartData() {
105
                var firstDate = new Date();
106
                firstDate.setDate(firstDate.getDate() - 500);
107
 
108
                for (var i = 0; i < 500; i++) {
109
                    // we create date objects here. In your data, you can have date strings
110
                    // and then set format of your dates using chart.dataDateFormat property,
111
                    // however when possible, use date objects, as this will speed up chart rendering.
112
                    var newDate = new Date(firstDate);
113
                    newDate.setDate(newDate.getDate() + i);
114
 
115
                    var visits = Math.round(Math.random() * 40) - 20;
116
 
117
                    chartData.push({
118
                        date: newDate,
119
                        visits: visits
120
                    });
121
                }
122
            }
123
 
124
            // this method is called when chart is first inited as we listen for "dataUpdated" event
125
            function zoomChart() {
126
                // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
127
                chart.zoomToIndexes(chartData.length - 40, chartData.length - 1);
128
            }
129
 
130
            // changes cursor mode from pan to select
131
            function setPanSelect() {
132
                if (document.getElementById("rb1").checked) {
133
                    chartCursor.pan = false;
134
                    chartCursor.zoomable = true;
135
                } else {
136
                    chartCursor.pan = true;
137
                }
138
                chart.validateNow();
139
            }
140
 
141
        </script>
142
    </head>
143
 
144
    <body>
145
        <div id="chartdiv" style="width: 100%; height: 400px;"></div>
146
        <div style="margin-left:35px;">
147
            <input type="radio" name="group" id="rb1" onclick="setPanSelect()">Select
148
            <input type="radio" checked="true" name="group" id="rb2" onclick="setPanSelect()">Pan
149
		</div>
150
    </body>
151
 
152
</html>