OpenSencillo  2016.106
Long live the simplicity of PHP
 All Data Structures Namespaces Files Functions Pages
example.js
1 $(function () {
2 
3  /* data stolen from http://howmanyleft.co.uk/vehicle/jaguar_'e'_type */
4  var day_data = [
5  {"period": "2016-10-01", "licensed": 807, "sorned": 660},
6  {"period": "2016-09-30", "licensed": 1251, "sorned": 729},
7  {"period": "2016-09-29", "licensed": 1769, "sorned": 1018},
8  {"period": "2016-09-20", "licensed": 2246, "sorned": 1461},
9  {"period": "2016-09-19", "licensed": 2657, "sorned": 1967},
10  {"period": "2016-09-18", "licensed": 3148, "sorned": 2627},
11  {"period": "2016-09-17", "licensed": 3471, "sorned": 3740},
12  {"period": "2016-09-16", "licensed": 2871, "sorned": 2216},
13  {"period": "2016-09-15", "licensed": 2401, "sorned": 1656},
14  {"period": "2016-09-10", "licensed": 2115, "sorned": 1022}
15  ];
16  Morris.Bar({
17  element: 'graph_bar_group',
18  data: day_data,
19  xkey: 'period',
20  barColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
21  ykeys: ['licensed', 'sorned'],
22  labels: ['Licensed', 'SORN'],
23  hideHover: 'auto',
24  xLabelAngle: 60
25  });
26 
27  Morris.Bar({
28  element: 'graph_bar',
29  data: [
30  {device: 'iPhone 4', geekbench: 380},
31  {device: 'iPhone 4S', geekbench: 655},
32  {device: 'iPhone 3GS', geekbench: 275},
33  {device: 'iPhone 5', geekbench: 1571},
34  {device: 'iPhone 5S', geekbench: 655},
35  {device: 'iPhone 6', geekbench: 2154},
36  {device: 'iPhone 6 Plus', geekbench: 1144},
37  {device: 'iPhone 6S', geekbench: 2371},
38  {device: 'iPhone 6S Plus', geekbench: 1471},
39  {device: 'Other', geekbench: 1371}
40  ],
41  xkey: 'device',
42  ykeys: ['geekbench'],
43  labels: ['Geekbench'],
44  barRatio: 0.4,
45  barColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
46  xLabelAngle: 35,
47  hideHover: 'auto'
48  });
49 
50  Morris.Bar({
51  element: 'graphx',
52  data: [
53  {x: '2015 Q1', y: 2, z: 3, a: 4},
54  {x: '2015 Q2', y: 3, z: 5, a: 6},
55  {x: '2015 Q3', y: 4, z: 3, a: 2},
56  {x: '2015 Q4', y: 2, z: 4, a: 5}
57  ],
58  xkey: 'x',
59  ykeys: ['y', 'z', 'a'],
60  barColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
61  hideHover: 'auto',
62  labels: ['Y', 'Z', 'A']
63  }).on('click', function (i, row) {
64  console.log(i, row);
65  });
66 
67  Morris.Area({
68  element: 'graph_area',
69  data: [
70  {period: '2014 Q1', iphone: 2666, ipad: null, itouch: 2647},
71  {period: '2014 Q2', iphone: 2778, ipad: 2294, itouch: 2441},
72  {period: '2014 Q3', iphone: 4912, ipad: 1969, itouch: 2501},
73  {period: '2014 Q4', iphone: 3767, ipad: 3597, itouch: 5689},
74  {period: '2015 Q1', iphone: 6810, ipad: 1914, itouch: 2293},
75  {period: '2015 Q2', iphone: 5670, ipad: 4293, itouch: 1881},
76  {period: '2015 Q3', iphone: 4820, ipad: 3795, itouch: 1588},
77  {period: '2015 Q4', iphone: 15073, ipad: 5967, itouch: 5175},
78  {period: '2016 Q1', iphone: 10687, ipad: 4460, itouch: 2028},
79  {period: '2016 Q2', iphone: 8432, ipad: 5713, itouch: 1791}
80  ],
81  xkey: 'period',
82  ykeys: ['iphone', 'ipad', 'itouch'],
83  lineColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
84  labels: ['iPhone', 'iPad', 'iPod Touch'],
85  pointSize: 2,
86  hideHover: 'auto'
87  });
88 
89 
90  Morris.Donut({
91  element: 'graph_donut',
92  data: [
93  {label: 'Jam', value: 25},
94  {label: 'Frosted', value: 40},
95  {label: 'Custard', value: 25},
96  {label: 'Sugar', value: 10}
97  ],
98  colors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
99  formatter: function (y) {
100  return y + "%"
101  }
102  });
103 
104  new Morris.Line({
105  element: 'graph_line',
106  xkey: 'year',
107  ykeys: ['value'],
108  labels: ['Value'],
109  hideHover: 'auto',
110  lineColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'],
111  data: [
112  {year: '2012', value: 20},
113  {year: '2013', value: 10},
114  {year: '2014', value: 5},
115  {year: '2015', value: 5},
116  {year: '2016', value: 20}
117  ]
118  });
119 
120 });