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