Bladeren bron

getDimensionValues

Deltakosh 7 jaren geleden
bovenliggende
commit
d9b12bfd69
2 gewijzigde bestanden met toevoegingen van 27 en 1 verwijderingen
  1. 6 1
      gui/src/3D/charting/barGraph.ts
  2. 21 0
      gui/src/3D/charting/dataSeries.ts

+ 6 - 1
gui/src/3D/charting/barGraph.ts

@@ -10,6 +10,7 @@ export class BarGraph extends Chart {
     protected _ownDefaultMaterial = false;
     private _barMeshes: Nullable<Array<Mesh>>;
 
+    /** Observable raised when a new element is created (one per bar) */
     public onElementCreated = new Observable<Mesh>();
 
     /** Gets or sets the margin between bars */
@@ -102,7 +103,10 @@ export class BarGraph extends Chart {
         return box;
     }
 
-    /** Force the graph to redraw itself */
+    /** 
+     * Force the graph to redraw itself 
+     * @returns the current BarGraph
+    */
     public refresh(): BarGraph {
         if (!this._dataSource) {
             this._clean();
@@ -175,6 +179,7 @@ export class BarGraph extends Chart {
         return this;
     }
 
+    /** Clean associated resources */
     public dispose() {
         if (this._ownDefaultMaterial && this._defaultMaterial) {
             this._defaultMaterial.dispose();

+ 21 - 0
gui/src/3D/charting/dataSeries.ts

@@ -45,6 +45,27 @@ export class DataSeries {
         return filteredData;
     }
 
+    /**
+     * Get the different values of a dimension
+     * @param key defines the dimension name
+     * @returns An array of values
+     */
+    public getDimensionValues(key: string): Array<any> {
+        var result = new Array<any>();
+
+        this.data.forEach((entry) => {
+            var value = entry[key];
+            if (result.indexOf(value) === -1) {
+                result.push(value);
+            }
+        });
+
+        return result;
+    }
+
+    /**
+     * Create a new DataSeries containing testing values
+     */
     public static CreateFakeData(): DataSeries {
         var series = new DataSeries();
         series.label = "Product #1";