aboutsummaryrefslogtreecommitdiff
path: root/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-03-21 21:36:52 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-03-21 21:36:52 -0400
commitce4e7a03e82c71bd5c979b19308f4dba03be08a2 (patch)
tree3f1eb320790bd66cc128c8899c5ee9ed170d3382 /src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
parent27299e9666ec0aae6a4d1335fd30b2714ad67970 (diff)
parent1cf618563838f4ce7d8a98c8a0c8d94670bc4e18 (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into promises_and_user_document
Diffstat (limited to 'src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts')
-rw-r--r--src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts b/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
new file mode 100644
index 000000000..995bf4e0b
--- /dev/null
+++ b/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
@@ -0,0 +1,52 @@
+import { AlphabeticBinRange, BinLabel } from '../../model/idea/idea'
+import { VisualBinRange } from './VisualBinRange'
+
+export class AlphabeticVisualBinRange extends VisualBinRange {
+ public DataBinRange: AlphabeticBinRange;
+
+ constructor(dataBinRange: AlphabeticBinRange) {
+ super();
+ this.DataBinRange = dataBinRange;
+ }
+
+ public AddStep(value: number): number {
+ return value + 1;
+ }
+
+ public GetValueFromIndex(index: number): number {
+ return index;
+ }
+
+ public GetBins(): number[] {
+ var bins = new Array<number>();
+ var idx = 0;
+ for (var key in this.DataBinRange.labelsValue) {
+ if (this.DataBinRange.labelsValue.hasOwnProperty(key)) {
+ bins.push(idx);
+ idx++;
+ }
+ }
+ return bins;
+ }
+
+ public GetLabel(value: number): string {
+ return this.DataBinRange.prefix + this.DataBinRange.valuesLabel![value];
+ }
+
+ public GetLabels(): Array<BinLabel> {
+ var labels = new Array<BinLabel>();
+ var count = 0;
+ for (var key in this.DataBinRange.valuesLabel) {
+ if (this.DataBinRange.valuesLabel.hasOwnProperty(key)) {
+ var value = this.DataBinRange.valuesLabel[key];
+ labels.push(new BinLabel({
+ value: parseFloat(key),
+ minValue: count++,
+ maxValue: count,
+ label: this.DataBinRange.prefix + value
+ }));
+ }
+ }
+ return labels;
+ }
+} \ No newline at end of file