1 | define(["dojo/_base/declare", "dojo/dom-style", "dojo/dom-attr", "./_bidiutils"], |
---|
2 | function(declare, domStyle, domAttr, utils){ |
---|
3 | // module: |
---|
4 | // dojox/charting/bidi/Chart3D |
---|
5 | return declare(null, { |
---|
6 | // direction: String |
---|
7 | // Mirroring support, the main variable which is responsible for the direction of the chart. |
---|
8 | // |
---|
9 | // Allowed values: |
---|
10 | // 1. "ltr" |
---|
11 | // 2. "rtl" |
---|
12 | // |
---|
13 | // By default is ltr. |
---|
14 | direction: "", |
---|
15 | isMirrored: false, |
---|
16 | |
---|
17 | postscript: function(node, lights, camera, theme, direction){ |
---|
18 | // summary: |
---|
19 | // The keyword arguments that can be passed in a Chart constructor. |
---|
20 | // |
---|
21 | // node: Node |
---|
22 | // The DOM node to construct the chart on. |
---|
23 | // lights: |
---|
24 | // Lighting properties for the 3d scene |
---|
25 | // camera: Object |
---|
26 | // Camera properties describing the viewing camera position. |
---|
27 | // theme: Object |
---|
28 | // Charting theme to use for coloring chart elements. |
---|
29 | // direction:String |
---|
30 | // the direction used to render the chart values[rtl/ltr] |
---|
31 | var chartDir = "ltr"; |
---|
32 | if(domAttr.has(node, "direction")){ |
---|
33 | chartDir = domAttr.get(node, "direction"); |
---|
34 | } |
---|
35 | this.chartBaseDirection = direction ? direction : chartDir; |
---|
36 | }, |
---|
37 | generate: function(){ |
---|
38 | this.inherited(arguments); |
---|
39 | this.isMirrored = false; |
---|
40 | return this; |
---|
41 | }, |
---|
42 | applyMirroring: function(plot, dim, offsets){ |
---|
43 | // summary: |
---|
44 | // apply the mirroring operation to the current chart plots. |
---|
45 | // |
---|
46 | if(this.isMirrored){ |
---|
47 | utils.reverseMatrix(plot, dim, offsets, this.dir == "rtl"); |
---|
48 | } |
---|
49 | //force the direction of the node to be ltr to properly render the axes and the plots labels. |
---|
50 | domStyle.set(this.node, "direction", "ltr"); |
---|
51 | return this; |
---|
52 | }, |
---|
53 | setDir: function(dir){ |
---|
54 | // summary: |
---|
55 | // Setter for the chartBaseDirection attribute. |
---|
56 | // description: |
---|
57 | // Allows dynamically set the chartBaseDirection attribute, which will used to |
---|
58 | // updates the chart rendering direction. |
---|
59 | // dir : the desired chart direction [rtl: for right to left ,ltr: for left to right] |
---|
60 | if(dir == "rtl" || dir == "ltr"){ |
---|
61 | if(this.dir != dir){ |
---|
62 | this.isMirrored = true; |
---|
63 | } |
---|
64 | this.dir = dir; |
---|
65 | } |
---|
66 | return this; |
---|
67 | }, |
---|
68 | isRightToLeft: function(){ |
---|
69 | // summary: |
---|
70 | // check the Direction of the chart. |
---|
71 | // description: |
---|
72 | // check the chartBaseDirection attribute to determine the rendering direction |
---|
73 | // of the chart. |
---|
74 | return this.dir == "rtl"; |
---|
75 | } |
---|
76 | }); |
---|
77 | }); |
---|
78 | |
---|