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
 
13
            var chartData = [];
14
 
15
            AmCharts.ready(function () {
16
                // first we generate some random data
17
                generateChartData();
18
 
19
                // SERIAL CHART
20
                chart = new AmCharts.AmSerialChart();
21
 
22
                chart.dataProvider = chartData;
23
                chart.categoryField = "date";
24
 
25
                // data updated event will be fired when chart is first displayed,
26
                // also when data will be updated. We'll use it to set some
27
                // initial zoom
28
                chart.addListener("dataUpdated", zoomChart);
29
 
30
                // AXES
31
                // Category
32
                var categoryAxis = chart.categoryAxis;
33
                categoryAxis.parseDates = true; // in order char to understand dates, we should set parseDates to true
34
                categoryAxis.minPeriod = "mm"; // as we have data with minute interval, we have to set "mm" here.
35
                categoryAxis.gridAlpha = 0.07;
36
                categoryAxis.axisColor = "#DADADA";
37
 
38
                // Value
39
                var valueAxis = new AmCharts.ValueAxis();
40
                valueAxis.gridAlpha = 0.07;
41
                valueAxis.title = "Unique visitors";
42
                chart.addValueAxis(valueAxis);
43
 
44
                // GRAPH
45
                var graph = new AmCharts.AmGraph();
46
                graph.type = "line"; // try to change it to "column"
47
                graph.title = "red line";
48
                graph.valueField = "visits";
49
                graph.lineAlpha = 1;
50
                graph.lineColor = "#d1cf2a";
51
                graph.fillAlphas = 0.3; // setting fillAlphas to > 0 value makes it area graph
52
                chart.addGraph(graph);
53
 
54
                // CURSOR
55
                var chartCursor = new AmCharts.ChartCursor();
56
                chartCursor.cursorPosition = "mouse";
57
                chartCursor.categoryBalloonDateFormat = "JJ:NN, DD MMMM";
58
                chart.addChartCursor(chartCursor);
59
 
60
                // SCROLLBAR
61
                var chartScrollbar = new AmCharts.ChartScrollbar();
62
 
63
                chart.addChartScrollbar(chartScrollbar);
64
 
65
                // WRITE
66
                chart.write("chartdiv");
67
            });
68
 
69
            // generate some random data, quite different range
70
            function generateChartData() {
71
                // current date
72
                var firstDate = new Date();
73
                // now set 1000 minutes back
74
                firstDate.setMinutes(firstDate.getDate() - 1000);
75
 
76
                // and generate 1000 data items
77
                for (var i = 0; i < 1000; i++) {
78
                    var newDate = new Date(firstDate);
79
                    // each time we add one minute
80
                    newDate.setMinutes(newDate.getMinutes() + i);
81
                    // some random number
82
                    var visits = Math.round(Math.random() * 40) + 10;
83
                    // add data item to the array
84
                    chartData.push({
85
                        date: newDate,
86
                        visits: visits
87
                    });
88
                }
89
            }
90
 
91
            // this method is called when chart is first inited as we listen for "dataUpdated" event
92
            function zoomChart() {
93
                // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
94
                chart.zoomToIndexes(chartData.length - 40, chartData.length - 1);
95
            }
96
        </script>
97
    </head>
98
 
99
    <body>
100
        <div id="chartdiv" style="width:100%; height:400px;"></div>
101
    </body>
102
 
103
</html>