]> git.proxmox.com Git - extjs.git/blob - extjs/examples/kitchensink/classic/samples/view/charts/column/StackedController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / kitchensink / classic / samples / view / charts / column / StackedController.js
1 Ext.define('KitchenSink.view.charts.column.StackedController', {
2 extend: 'Ext.app.ViewController',
3 alias: 'controller.column-stacked',
4
5 onPreview: function() {
6 var chart = this.lookupReference('chart');
7
8 chart.preview();
9 },
10
11 onThemeSwitch: function () {
12 var chart = this.lookupReference('chart'),
13 currentThemeClass = Ext.getClassName(chart.getTheme()),
14 themes = Ext.chart.theme,
15 themeNames = [],
16 currentIndex = 0,
17 name;
18
19 for (name in themes) {
20 if (Ext.getClassName(themes[name]) === currentThemeClass) {
21 currentIndex = themeNames.length;
22 }
23 if (name !== 'Base' && name.indexOf('Gradients') < 0) {
24 themeNames.push(name);
25 }
26 }
27 chart.setTheme(themes[themeNames[++currentIndex % themeNames.length]]);
28 },
29
30 onStackGroupToggle: function (segmentedButton, button, pressed) {
31 var chart = this.lookupReference('chart'),
32 series = chart.getSeries()[0],
33 value = segmentedButton.getValue();
34
35 series.setStacked(value === 0);
36 chart.redraw();
37 },
38
39 // The 'target' here is an object that contains information
40 // about the target value when the drag operation on the column ends.
41 onEditTipRender: function (tooltip, item, target, e) {
42 var fieldIndex = Ext.Array.indexOf(item.series.getYField(), target.yField),
43 browser = item.series.getTitle()[fieldIndex];
44
45 tooltip.setHtml(
46 browser + ' on ' + item.record.get('month') + ': ' +
47 target.yValue.toFixed(1) + '%');
48 },
49
50 onBarTipRender: function (tooltip, record, item) {
51 var fieldIndex = Ext.Array.indexOf(item.series.getYField(), item.field),
52 browser = item.series.getTitle()[fieldIndex];
53
54 tooltip.setHtml(browser + ' on ' +
55 record.get('month') + ': ' +
56 record.get(item.field).toFixed(1) + '%');
57 },
58
59 onGridMonthRender: function (value) {
60 return value;
61 },
62
63 onGridValueRender: function (value) {
64 return value + '%';
65 },
66
67 onAxisLabelRender: function (axis, label, layoutContext) {
68 return label.toFixed(label < 10 ? 1: 0) + '%';
69 }
70
71 });