aboutsummaryrefslogtreecommitdiff
path: root/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-03-20 18:00:39 -0400
committerbob <bcz@cs.brown.edu>2019-03-20 18:00:39 -0400
commita16e6592caafb601b59c3d9f7609e8c1af231eba (patch)
treee732e34c5a9fc371bf328fdd35a08ddd196bf6af /src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
parent208a57b15e6b415659311873431dbe9d5b8d8021 (diff)
initial
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