Pārlūkot izejas kodu

Propagate new HueChart getData fn.

Marcus McLaughlin 15 gadi atpakaļ
vecāks
revīzija
b38b9c6ea6

+ 4 - 4
desktop/core/static/js/Source/CCS/HueChart.Area.js

@@ -31,7 +31,7 @@ HueChart.Area = new Class({
         setScales: function(vis) {
                 this.parent();
                 //Scale with peakSum as max, since this is a stacked chart.
-                var peakSum = this.data.getPeakSum(this.options.series);
+                var peakSum = this.getData(true).getPeakSum(this.options.series);
                 //Start yScale range from 0, rather than from the bottom padding, since the areas will be stacked on top of one another.
                 this.yScale = pv.Scale.linear(0, peakSum * 1.2).range(0, (this.height - (this.options.topPadding + this.options.bottomPadding)));
                 //Create yScaleTicks which has a domain which goes up to a function of peakSum and a range from the bottomPadding, to the bottom of the topPadding. 
@@ -53,9 +53,9 @@ HueChart.Area = new Class({
                 stack = stack.bottom(this.options.bottomPadding)
                         //Using as layers the values in the this.series array.
                         .layers(this.options.series)
-                        //And as values the this.data array
-                        .values(this.data.getObjects())
-                        //The two commands below will be run this.series.length * this.data.length times.
+                        //And as values the this.getData() array
+                        .values(this.getData(true).getObjects())
+                        //The two commands below will be run this.series.length * this.getData().length times.
                         //The x-value, in pixels, is calculated as a conversion of the data object's xField value using the xScale.
                         .x(function(d) {
                                 return this.xScale(d[this.options.xField]);

+ 9 - 8
desktop/core/static/js/Source/CCS/HueChart.Box.js

@@ -60,11 +60,11 @@ HueChart.Box = new Class({
                 if(this.options.xIsDate) {
                         //If the xField is a date property, prepare the dates for sorting
                         //Change the xField to the new property designed for sorting dates
-                        this.data.prepareDates(this.options.xField);
+                        this.getData(true).prepareDates(this.options.xField);
                         this.options.xField = 'seconds_from_first';
                 } else {
                         //Otherwise sort by the x property.
-                        this.data.sortByProperty(this.options.xField);
+                        this.getData(true).sortByProperty(this.options.xField);
                 }
                 //When the setupChart event is fired, the full ProtoVis visualization is being set up, in preparation for render.
                 //The addGraph function is responsible for adding the actual representation of the data, be that a group of lines, or a group of area graphs.
@@ -87,10 +87,10 @@ HueChart.Box = new Class({
         //Set the scales which will be used to convert data values into positions for graph objects
         setScales: function(vis) {
                 //Get the minimum and maximum x values.
-                var xMin = this.data.getMinValue(this.options.xField);
-                var xMax = this.data.getMaxValue(this.options.xField);
+                var xMin = this.getData(true).getMinValue(this.options.xField);
+                var xMax = this.getData(true).getMaxValue(this.options.xField);
                 //Get the maximum of the values that are to be graphed
-                var maxValue = this.data.getMaxValue(this.options.series);
+                var maxValue = this.getData(true).getMaxValue(this.options.series);
                 this.xScale = pv.Scale.linear(xMin, xMax).range(this.options.leftPadding, this.width - this.options.rightPadding);
                 this.yScale = pv.Scale.linear(0, maxValue * 1.2).range(this.options.bottomPadding, (this.height - (this.options.topPadding)));
         },
@@ -99,7 +99,7 @@ HueChart.Box = new Class({
         setTicks:function(vis) {
                 //Add X-Ticks.
                 //Create tick array.
-                var xTicks = (this.options.xIsDate ? this.data.createTickArray(7, 'day') : this.xScale.ticks(7));
+                var xTicks = (this.options.xIsDate ? this.getData(true).createTickArray(7, 'day') : this.xScale.ticks(7));
                 //Create rules (lines intended to denote scale)
                 vis.add(pv.Rule)
                         //Use the tick array as data.
@@ -174,7 +174,7 @@ HueChart.Box = new Class({
                 get_selected_index = this.getSelectedIndex.bind(this);
                 //Add a thin black bar which is approximately the height of the graphing area for each item on the graph.
                 vis.add(pv.Bar)
-                        .data(this.data.getObjects())
+                        .data(this.getData(true).getObjects())
                         .left(function(d) { 
                                 return this.xScale(d[this.options.xField]); 
                         }.bind(this))
@@ -208,7 +208,7 @@ HueChart.Box = new Class({
                         var dataIndex = getDataIndexFromMouse();
                         //Fire pointMouseOver if the item exists
                         if(dataIndex) {
-                                this.fireEvent('pointMouseOver', [this.data.getObjects()[dataIndex], dataIndex]);
+                                this.fireEvent('pointMouseOver', [this.getData(true).getObjects()[dataIndex], dataIndex]);
                         }
                         return vis;
                 }.bind(this);
@@ -217,6 +217,7 @@ HueChart.Box = new Class({
                         //Fire pointClick if the item exists
                         if(dataIndex != null) {
                                 this.fireEvent('pointClick', [ this.data.getObjects()[dataIndex], dataIndex ]);
+                                        this.fireEvent('pointClick', [ this.getData(true).getObjects()[dataIndex], dataIndex ]);
                         }
                         return vis;
                 }.bind(this);