]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('KitchenSink.view.chart.ChartController', {\r |
2 | extend: 'Ext.app.ViewController',\r | |
3 | alias: 'controller.chart',\r | |
4 | \r | |
5 | config: {\r | |
6 | defaultVisibleRange: null,\r | |
7 | rangeAxis: ['top', 'bottom']\r | |
8 | },\r | |
9 | \r | |
10 | requires: [\r | |
11 | 'Ext.chart.theme.Blue',\r | |
12 | 'Ext.chart.theme.Green',\r | |
13 | 'Ext.chart.theme.Muted',\r | |
14 | 'Ext.chart.theme.Red',\r | |
15 | 'Ext.chart.theme.Sky',\r | |
16 | 'Ext.chart.theme.Yellow'\r | |
17 | ],\r | |
18 | \r | |
19 | themes: [\r | |
20 | 'default',\r | |
21 | 'blue',\r | |
22 | 'green',\r | |
23 | 'muted',\r | |
24 | 'red',\r | |
25 | 'sky',\r | |
26 | 'yellow'\r | |
27 | ],\r | |
28 | \r | |
29 | currentTheme: 0,\r | |
30 | \r | |
31 | getChart: function() {\r | |
32 | return this.getView().down('[isChart]');\r | |
33 | },\r | |
34 | \r | |
35 | onThemeChange: function() {\r | |
36 | var themes = this.themes,\r | |
37 | idx = ++this.currentTheme;\r | |
38 | \r | |
39 | if (idx === themes.length) {\r | |
40 | this.currentTheme = idx = 0;\r | |
41 | }\r | |
42 | this.getChart().setTheme(themes[idx]);\r | |
43 | },\r | |
44 | \r | |
45 | onReset: function() {\r | |
46 | var range = this.getDefaultVisibleRange(),\r | |
47 | chart = this.getChart(),\r | |
48 | legend = chart.getLegend(),\r | |
49 | axes;\r | |
50 | \r | |
51 | if (range) {\r | |
52 | axes = chart.getAxes();\r | |
53 | axes.forEach(function(axis) {\r | |
54 | var pos = axis.getPosition();\r | |
55 | if (range[pos]) {\r | |
56 | axis.setVisibleRange(range[pos]);\r | |
57 | }\r | |
58 | });\r | |
59 | }\r | |
60 | \r | |
61 | if (legend) {\r | |
62 | chart.resetLegendStore();\r | |
63 | } else {\r | |
64 | chart.redraw();\r | |
65 | }\r | |
66 | }\r | |
67 | })\r |