]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @abstract\r | |
3 | * @class Ext.chart.series.Cartesian\r | |
4 | * @extends Ext.chart.series.Series\r | |
5 | *\r | |
6 | * Common base class for series implementations that plot values using cartesian coordinates.\r | |
7 | *\r | |
8 | * @constructor\r | |
9 | */\r | |
10 | Ext.define('Ext.chart.series.Cartesian', {\r | |
11 | extend: 'Ext.chart.series.Series',\r | |
12 | config: {\r | |
13 | /**\r | |
14 | * @cfg {String} xField\r | |
15 | * The field used to access the x axis value from the items from the data source.\r | |
16 | */\r | |
17 | xField: null,\r | |
18 | \r | |
19 | /**\r | |
20 | * @cfg {String|String[]} yField\r | |
21 | * The field(s) used to access the y-axis value(s) of the items from the data source.\r | |
22 | */\r | |
23 | yField: null,\r | |
24 | \r | |
25 | /**\r | |
26 | * @cfg {Ext.chart.axis.Axis|Number|String}\r | |
27 | * xAxis The chart axis the series is bound to in the 'X' direction.\r | |
28 | * Normally, this would be set automatically by the series.\r | |
29 | * For charts with multiple x-axes, this defines which x-axis is used by the series.\r | |
30 | * It refers to either axis' ID or the (zero-based) index of the axis\r | |
31 | * in the chart's {@link Ext.chart.AbstractChart#axes axes} config.\r | |
32 | */\r | |
33 | xAxis: null,\r | |
34 | \r | |
35 | /**\r | |
36 | * @cfg {Ext.chart.axis.Axis|Number|String}\r | |
37 | * yAxis The chart axis the series is bound to in the 'Y' direction.\r | |
38 | * Normally, this would be set automatically by the series.\r | |
39 | * For charts with multiple y-axes, this defines which y-axis is used by the series.\r | |
40 | * It refers to either axis' ID or the (zero-based) index of the axis\r | |
41 | * in the chart's {@link Ext.chart.AbstractChart#axes axes} config.\r | |
42 | */\r | |
43 | yAxis: null\r | |
44 | },\r | |
45 | \r | |
46 | directions: ['X', 'Y'],\r | |
47 | \r | |
48 | /**\r | |
49 | * @private\r | |
50 | *\r | |
51 | * Tells which store record fields should be used for a specific axis direction. E.g. for\r | |
52 | *\r | |
53 | * fieldCategory<direction>: ['<fieldConfig1>', '<fieldConfig2>', ...]\r | |
54 | *\r | |
55 | * the field names from the following configs will be used:\r | |
56 | *\r | |
57 | * series.<fieldConfig1>Field, series.<fieldConfig2>Field, ...\r | |
58 | *\r | |
59 | */\r | |
60 | fieldCategoryX: ['X'],\r | |
61 | fieldCategoryY: ['Y'],\r | |
62 | \r | |
63 | applyXAxis: function (newAxis, oldAxis) {\r | |
64 | return this.getChart().getAxis(newAxis) || oldAxis;\r | |
65 | },\r | |
66 | \r | |
67 | applyYAxis: function (newAxis, oldAxis) {\r | |
68 | return this.getChart().getAxis(newAxis) || oldAxis;\r | |
69 | },\r | |
70 | \r | |
71 | updateXAxis: function (axis) {\r | |
72 | axis.processData(this);\r | |
73 | },\r | |
74 | \r | |
75 | updateYAxis: function (axis) {\r | |
76 | axis.processData(this);\r | |
77 | },\r | |
78 | \r | |
79 | coordinateX: function () {\r | |
80 | return this.coordinate('X', 0, 2);\r | |
81 | },\r | |
82 | \r | |
83 | coordinateY: function () {\r | |
84 | return this.coordinate('Y', 1, 2);\r | |
85 | },\r | |
86 | \r | |
87 | getItemForPoint: function (x, y) {\r | |
88 | if (this.getSprites()) {\r | |
89 | var me = this,\r | |
90 | sprite = me.getSprites()[0],\r | |
91 | store = me.getStore(),\r | |
92 | item, index;\r | |
93 | \r | |
94 | if (me.getHidden()) {\r | |
95 | return null;\r | |
96 | }\r | |
97 | if (sprite) {\r | |
98 | index = sprite.getIndexNearPoint(x, y);\r | |
99 | if (index !== -1) {\r | |
100 | item = {\r | |
101 | series: me,\r | |
102 | category: me.getItemInstancing() ? 'items' : 'markers',\r | |
103 | index: index,\r | |
104 | record: store.getData().items[index],\r | |
105 | field: me.getYField(),\r | |
106 | sprite: sprite\r | |
107 | };\r | |
108 | return item;\r | |
109 | }\r | |
110 | }\r | |
111 | }\r | |
112 | },\r | |
113 | \r | |
114 | createSprite: function () {\r | |
115 | var me = this,\r | |
116 | sprite = me.callParent(),\r | |
117 | chart = me.getChart(),\r | |
118 | xAxis = me.getXAxis();\r | |
119 | \r | |
120 | sprite.setAttributes({\r | |
121 | flipXY: chart.getFlipXY(),\r | |
122 | xAxis: xAxis\r | |
123 | });\r | |
124 | if (sprite.setAggregator && xAxis && xAxis.getAggregator) {\r | |
125 | if (xAxis.getAggregator) {\r | |
126 | sprite.setAggregator({strategy: xAxis.getAggregator()});\r | |
127 | } else {\r | |
128 | sprite.setAggregator({});\r | |
129 | }\r | |
130 | }\r | |
131 | return sprite;\r | |
132 | },\r | |
133 | \r | |
134 | getSprites: function () {\r | |
135 | var me = this,\r | |
136 | chart = this.getChart(),\r | |
137 | animation = me.getAnimation() || chart && chart.getAnimation(),\r | |
138 | itemInstancing = me.getItemInstancing(),\r | |
139 | sprites = me.sprites,\r | |
140 | sprite;\r | |
141 | \r | |
142 | if (!chart) {\r | |
143 | return [];\r | |
144 | }\r | |
145 | \r | |
146 | if (!sprites.length) {\r | |
147 | sprite = me.createSprite();\r | |
148 | } else {\r | |
149 | sprite = sprites[0];\r | |
150 | }\r | |
151 | \r | |
152 | if (animation) {\r | |
153 | if (itemInstancing) {\r | |
154 | sprite.itemsMarker.getTemplate().setAnimation(animation);\r | |
155 | }\r | |
156 | sprite.setAnimation(animation);\r | |
157 | }\r | |
158 | return sprites;\r | |
159 | },\r | |
160 | \r | |
161 | provideLegendInfo: function (target) {\r | |
162 | var me = this,\r | |
163 | style = me.getSubStyleWithTheme(),\r | |
164 | fill = style.fillStyle;\r | |
165 | \r | |
166 | if (Ext.isArray(fill)) {\r | |
167 | fill = fill[0];\r | |
168 | }\r | |
169 | target.push({\r | |
170 | name: me.getTitle() || me.getYField() || me.getId(),\r | |
171 | mark: (Ext.isObject(fill) ? fill.stops && fill.stops[0].color : fill) || style.strokeStyle || 'black',\r | |
172 | disabled: me.getHidden(),\r | |
173 | series: me.getId(),\r | |
174 | index: 0\r | |
175 | });\r | |
176 | },\r | |
177 | \r | |
178 | getXRange: function () {\r | |
179 | return [this.dataRange[0], this.dataRange[2]];\r | |
180 | },\r | |
181 | \r | |
182 | getYRange: function () {\r | |
183 | return [this.dataRange[1], this.dataRange[3]];\r | |
184 | }\r | |
185 | })\r | |
186 | ; |