]> git.proxmox.com Git - sencha-touch.git/blob - src/src/chart/series/sprite/Area.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / chart / series / sprite / Area.js
1 /**
2 * @class Ext.chart.series.sprite.Area
3 * @extends Ext.chart.series.sprite.StackedCartesian
4 *
5 * Area series sprite.
6 */
7 Ext.define("Ext.chart.series.sprite.Area", {
8 alias: 'sprite.areaSeries',
9 extend: "Ext.chart.series.sprite.StackedCartesian",
10
11 inheritableStatics: {
12 def: {
13 processors: {
14 /**
15 * @cfg {Boolean} [step=false] 'true' if the area is represented with steps instead of lines.
16 */
17 step: 'bool'
18 },
19 defaults: {
20 step: false
21 }
22 }
23 },
24
25 renderClipped: function (surface, ctx, clip, clipRegion) {
26 var me = this,
27 attr = me.attr,
28 dataX = attr.dataX,
29 dataY = attr.dataY,
30 dataStartY = attr.dataStartY,
31 matrix = attr.matrix,
32 x, y, i, lastX, lastY,
33 xx = matrix.elements[0],
34 dx = matrix.elements[4],
35 yy = matrix.elements[3],
36 dy = matrix.elements[5],
37 surfaceMatrix = me.surfaceMatrix,
38 markerCfg = {},
39 start = Math.max(0, this.binarySearch(clip[0])),
40 end = Math.min(dataX.length - 1, this.binarySearch(clip[2]) + 1);
41 ctx.beginPath();
42
43 if (attr.step) {
44 lastY = dataY[start] * yy + dy;
45 for (i = start; i <= end; i++) {
46 x = dataX[i] * xx + dx;
47 y = dataY[i] * yy + dy;
48 ctx.lineTo(x, lastY);
49 ctx.lineTo(x, lastY = y);
50 }
51 } else {
52 for (i = start; i <= end; i++) {
53 x = dataX[i] * xx + dx;
54 y = dataY[i] * yy + dy;
55 ctx.lineTo(x, y);
56 }
57 }
58
59 if (dataStartY) {
60 if (attr.step) {
61 lastX = dataX[end] * xx + dx;
62 for (i = end; i >= start; i--) {
63 x = dataX[i] * xx + dx;
64 y = dataStartY[i] * yy + dy;
65 ctx.lineTo(lastX, y);
66 ctx.lineTo(lastX = x, y);
67 }
68 } else {
69 for (i = end; i >= start; i--) {
70 x = dataX[i] * xx + dx;
71 y = dataStartY[i] * yy + dy;
72 ctx.lineTo(x, y);
73 }
74 }
75 } else {
76 // dataStartY[i] == 0;
77 ctx.lineTo(dataX[end] * xx + dx, y);
78 ctx.lineTo(dataX[end] * xx + dx, dy);
79 ctx.lineTo(dataX[start] * xx + dx, dy);
80 ctx.lineTo(dataX[start] * xx + dx, dataY[i] * yy + dy);
81 }
82 if (attr.transformFillStroke) {
83 attr.matrix.toContext(ctx);
84 }
85 ctx.fill();
86 if (attr.transformFillStroke) {
87 attr.inverseMatrix.toContext(ctx);
88 }
89 ctx.beginPath();
90 if (attr.step) {
91 for (i = start; i <= end; i++) {
92 x = dataX[i] * xx + dx;
93 y = dataY[i] * yy + dy;
94 ctx.lineTo(x, lastY);
95 ctx.lineTo(x, lastY = y);
96 markerCfg.translationX = surfaceMatrix.x(x, y);
97 markerCfg.translationY = surfaceMatrix.y(x, y);
98 me.putMarker("markers", markerCfg, i, !attr.renderer);
99 }
100 } else {
101 for (i = start; i <= end; i++) {
102 x = dataX[i] * xx + dx;
103 y = dataY[i] * yy + dy;
104 ctx.lineTo(x, y);
105 markerCfg.translationX = surfaceMatrix.x(x, y);
106 markerCfg.translationY = surfaceMatrix.y(x, y);
107 me.putMarker("markers", markerCfg, i, !attr.renderer);
108 }
109 }
110
111 if (attr.transformFillStroke) {
112 attr.matrix.toContext(ctx);
113 }
114 ctx.stroke();
115 }
116 });