@hpcc-js/other 3.5.2 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +43 -43
- package/README.md +41 -41
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +6 -6
- package/src/Audio.ts +86 -86
- package/src/AutoCompleteText.css +47 -47
- package/src/AutoCompleteText.ts +132 -132
- package/src/CalendarHeatMap.css +25 -25
- package/src/CalendarHeatMap.ts +250 -250
- package/src/Comms.ts +1083 -1083
- package/src/ESP.ts +451 -451
- package/src/HPCCBadge.ts +220 -220
- package/src/HeatMap.ts +150 -150
- package/src/Html.css +5 -5
- package/src/Html.ts +48 -48
- package/src/IconList.css +3 -3
- package/src/IconList.ts +86 -86
- package/src/Legend.css +104 -104
- package/src/Legend.ts +227 -227
- package/src/MorphText.css +10 -10
- package/src/MorphText.ts +109 -109
- package/src/NestedTable.ts +51 -51
- package/src/Opportunity.css +81 -81
- package/src/Opportunity.ts +500 -500
- package/src/Paginator.css +131 -131
- package/src/Paginator.ts +172 -172
- package/src/Persist.ts +151 -151
- package/src/PropertyEditor.css +179 -179
- package/src/PropertyEditor.ts +762 -762
- package/src/RadioCheckbox.css +5 -5
- package/src/RadioCheckbox.ts +130 -130
- package/src/Select.css +5 -5
- package/src/Select.ts +130 -130
- package/src/Table.css +106 -106
- package/src/Table.ts +1099 -1099
- package/src/ThemeEditor.css +230 -230
- package/src/ThemeEditor.ts +758 -758
- package/src/__package__.ts +3 -3
- package/src/index.ts +23 -23
package/src/Legend.css
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
.other_Legend .colorBlock {
|
|
2
|
-
width: 10px;
|
|
3
|
-
height: 10px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.other_Legend>table,
|
|
7
|
-
.other_Legend>table td,
|
|
8
|
-
.other_Legend>table th {
|
|
9
|
-
border-collapse: collapse;
|
|
10
|
-
border-spacing: 0px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.other_Table.other_Legend table {
|
|
14
|
-
border-spacing: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.other_Table.other_Legend th,
|
|
18
|
-
.labels-wrapper th {
|
|
19
|
-
padding: 2px 5px;
|
|
20
|
-
background-color: transparent;
|
|
21
|
-
border-width: 1px;
|
|
22
|
-
border-style: solid;
|
|
23
|
-
border-color: transparent;
|
|
24
|
-
color: #333;
|
|
25
|
-
white-space: nowrap;
|
|
26
|
-
cursor: default;
|
|
27
|
-
font-weight: normal;
|
|
28
|
-
text-align: left;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.other_Table.other_Legend tr {
|
|
32
|
-
background-color: transparent;
|
|
33
|
-
color: #333;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.other_Table.other_Legend .tableDiv tbody>tr:nth-child(odd) {
|
|
37
|
-
background-color: unset;
|
|
38
|
-
color: black;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.other_Table.other_Legend .tableDiv tbody>tr:hover,
|
|
42
|
-
.other_Table.other_Legend .tableDiv tbody>tr.hover,
|
|
43
|
-
.rows-wrapper table tbody tr.hover {
|
|
44
|
-
background-color: #bfd7e7;
|
|
45
|
-
color: white;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.other_Table.other_Legend thead>tr:hover {
|
|
50
|
-
background-color: transparent;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.other_Table.other_Legend tbody>tr:hover,
|
|
54
|
-
.other_Table.other_Legend tbody>tr.hover,
|
|
55
|
-
.rows-wrapper tbody tr.hover {
|
|
56
|
-
background-color: #EEE;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.other_Table.other_Legend td,
|
|
60
|
-
.rows-wrapper td {
|
|
61
|
-
border-width: 0px;
|
|
62
|
-
padding: 2px 5px;
|
|
63
|
-
white-space: nowrap;
|
|
64
|
-
box-sizing: border-box;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.other_Legend>.tableDiv>table>tbody>tr:hover {
|
|
68
|
-
cursor: pointer;
|
|
69
|
-
color: #000;
|
|
70
|
-
background-color: #DDD;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.other_Legend.horiz-legend .tableDiv {
|
|
74
|
-
width: 100% !important;
|
|
75
|
-
text-align: left;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.other_Legend.horiz-legend .tableDiv>table {
|
|
79
|
-
display: inline-block;
|
|
80
|
-
width: 100% !important;
|
|
81
|
-
top: 0px !important;
|
|
82
|
-
left: 0px !important;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.other_Legend.horiz-legend thead,
|
|
86
|
-
.other_Legend.horiz-legend tbody,
|
|
87
|
-
.other_Legend.horiz-legend tr {
|
|
88
|
-
display: inline-block;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.other_Legend.horiz-legend td,
|
|
92
|
-
.other_Legend.horiz-legend td>div {
|
|
93
|
-
display: inline-block;
|
|
94
|
-
white-space: nowrap;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.other_Legend.horiz-legend tr {
|
|
98
|
-
white-space: nowrap;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.other_Legend.horiz-legend tbody {
|
|
102
|
-
display: inline-block;
|
|
103
|
-
width: 100% !important;
|
|
104
|
-
text-align: center;
|
|
1
|
+
.other_Legend .colorBlock {
|
|
2
|
+
width: 10px;
|
|
3
|
+
height: 10px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.other_Legend>table,
|
|
7
|
+
.other_Legend>table td,
|
|
8
|
+
.other_Legend>table th {
|
|
9
|
+
border-collapse: collapse;
|
|
10
|
+
border-spacing: 0px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.other_Table.other_Legend table {
|
|
14
|
+
border-spacing: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.other_Table.other_Legend th,
|
|
18
|
+
.labels-wrapper th {
|
|
19
|
+
padding: 2px 5px;
|
|
20
|
+
background-color: transparent;
|
|
21
|
+
border-width: 1px;
|
|
22
|
+
border-style: solid;
|
|
23
|
+
border-color: transparent;
|
|
24
|
+
color: #333;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
cursor: default;
|
|
27
|
+
font-weight: normal;
|
|
28
|
+
text-align: left;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.other_Table.other_Legend tr {
|
|
32
|
+
background-color: transparent;
|
|
33
|
+
color: #333;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.other_Table.other_Legend .tableDiv tbody>tr:nth-child(odd) {
|
|
37
|
+
background-color: unset;
|
|
38
|
+
color: black;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.other_Table.other_Legend .tableDiv tbody>tr:hover,
|
|
42
|
+
.other_Table.other_Legend .tableDiv tbody>tr.hover,
|
|
43
|
+
.rows-wrapper table tbody tr.hover {
|
|
44
|
+
background-color: #bfd7e7;
|
|
45
|
+
color: white;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
.other_Table.other_Legend thead>tr:hover {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.other_Table.other_Legend tbody>tr:hover,
|
|
54
|
+
.other_Table.other_Legend tbody>tr.hover,
|
|
55
|
+
.rows-wrapper tbody tr.hover {
|
|
56
|
+
background-color: #EEE;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.other_Table.other_Legend td,
|
|
60
|
+
.rows-wrapper td {
|
|
61
|
+
border-width: 0px;
|
|
62
|
+
padding: 2px 5px;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.other_Legend>.tableDiv>table>tbody>tr:hover {
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
color: #000;
|
|
70
|
+
background-color: #DDD;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.other_Legend.horiz-legend .tableDiv {
|
|
74
|
+
width: 100% !important;
|
|
75
|
+
text-align: left;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.other_Legend.horiz-legend .tableDiv>table {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
width: 100% !important;
|
|
81
|
+
top: 0px !important;
|
|
82
|
+
left: 0px !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.other_Legend.horiz-legend thead,
|
|
86
|
+
.other_Legend.horiz-legend tbody,
|
|
87
|
+
.other_Legend.horiz-legend tr {
|
|
88
|
+
display: inline-block;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.other_Legend.horiz-legend td,
|
|
92
|
+
.other_Legend.horiz-legend td>div {
|
|
93
|
+
display: inline-block;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.other_Legend.horiz-legend tr {
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.other_Legend.horiz-legend tbody {
|
|
102
|
+
display: inline-block;
|
|
103
|
+
width: 100% !important;
|
|
104
|
+
text-align: center;
|
|
105
105
|
}
|
package/src/Legend.ts
CHANGED
|
@@ -1,227 +1,227 @@
|
|
|
1
|
-
import { Palette, Platform } from "@hpcc-js/common";
|
|
2
|
-
import { format as d3Format } from "d3-format";
|
|
3
|
-
import { select as d3Select } from "d3-selection";
|
|
4
|
-
import { Table } from "./Table.ts";
|
|
5
|
-
|
|
6
|
-
import "../src/Legend.css";
|
|
7
|
-
|
|
8
|
-
function _htmlColorBlock(hexColor) {
|
|
9
|
-
return "<div class=\"colorBlock\" style=\"background-color:" + hexColor + ";\"></div>";
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class Legend extends Table {
|
|
13
|
-
_targetWidget;
|
|
14
|
-
_targetWidgetMonitor;
|
|
15
|
-
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
|
|
19
|
-
this.showHeader(false);
|
|
20
|
-
this.pagination(false);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
isRainbow() {
|
|
24
|
-
const widget = this.getWidget();
|
|
25
|
-
return widget && widget._palette && widget._palette.type() === "rainbow";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
targetWidget(): any;
|
|
29
|
-
targetWidget(_: any): this;
|
|
30
|
-
targetWidget(_?: any): any | this {
|
|
31
|
-
if (!arguments.length) return this._targetWidget;
|
|
32
|
-
this._targetWidget = _;
|
|
33
|
-
if (this._targetWidgetMonitor) {
|
|
34
|
-
this._targetWidgetMonitor.remove();
|
|
35
|
-
delete this._targetWidgetMonitor;
|
|
36
|
-
}
|
|
37
|
-
const context = this;
|
|
38
|
-
this._targetWidgetMonitor = this._targetWidget.monitor(function (key, newProp, oldProp, source) {
|
|
39
|
-
switch (key) {
|
|
40
|
-
case "chart":
|
|
41
|
-
case "columns":
|
|
42
|
-
case "data":
|
|
43
|
-
case "paletteID":
|
|
44
|
-
context.lazyRender();
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getWidget() {
|
|
52
|
-
if (this._targetWidget) {
|
|
53
|
-
switch (this._targetWidget.classID()) {
|
|
54
|
-
case "chart_MultiChart":
|
|
55
|
-
return this._targetWidget.chart();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return this._targetWidget;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getPalette() {
|
|
62
|
-
const widget = this.getWidget();
|
|
63
|
-
if (widget && widget._palette) {
|
|
64
|
-
switch (widget._palette.type()) {
|
|
65
|
-
case "ordinal":
|
|
66
|
-
return Palette.ordinal(widget._palette.id());
|
|
67
|
-
case "rainbow":
|
|
68
|
-
return Palette.rainbow(widget._palette.id());
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return Palette.ordinal("default");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
enter(domNode, element) {
|
|
75
|
-
super.enter(domNode, element);
|
|
76
|
-
d3Select(domNode.parentNode).style("overflow-y", "auto");
|
|
77
|
-
|
|
78
|
-
this.renderHtmlDataCells(true);
|
|
79
|
-
this.fixedHeader(false);
|
|
80
|
-
this.fixedSize(true);
|
|
81
|
-
element.classed("other_Legend", true);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
update(domNode, element) {
|
|
85
|
-
const colArr = ["Key", "Label"];
|
|
86
|
-
let dataArr = [];
|
|
87
|
-
if (this._targetWidget) {
|
|
88
|
-
const _palette = this.getPalette();
|
|
89
|
-
switch (_palette.type()) {
|
|
90
|
-
case "ordinal":
|
|
91
|
-
const oPalette = _palette as Palette.OrdinalPaletteFunc;
|
|
92
|
-
switch (this.dataFamily()) {
|
|
93
|
-
case "2D":
|
|
94
|
-
dataArr = this._targetWidget.data().map(function (n) {
|
|
95
|
-
return [_htmlColorBlock(oPalette(n[0])), n[0]];
|
|
96
|
-
}, this);
|
|
97
|
-
break;
|
|
98
|
-
case "ND":
|
|
99
|
-
const widgetColumns = this._targetWidget.columns();
|
|
100
|
-
dataArr = widgetColumns.filter(function (n, i) { return i > 0; }).map(function (n) {
|
|
101
|
-
return [_htmlColorBlock(oPalette(n)), n];
|
|
102
|
-
}, this);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
case "rainbow":
|
|
107
|
-
const rPalette = _palette as Palette.RainbowPaletteFunc;
|
|
108
|
-
const format = d3Format(this.rainbowFormat());
|
|
109
|
-
const widget = this.getWidget();
|
|
110
|
-
const steps = this.rainbowBins();
|
|
111
|
-
const weightMin = widget._dataMinWeight;
|
|
112
|
-
const weightMax = widget._dataMaxWeight;
|
|
113
|
-
const stepWeightDiff = (weightMax - weightMin) / (steps - 1);
|
|
114
|
-
dataArr.push([_htmlColorBlock(rPalette(weightMin, weightMin, weightMax)), format(weightMin)]);
|
|
115
|
-
for (let x = 1; x < steps - 1; ++x) {
|
|
116
|
-
const mid = stepWeightDiff * x;
|
|
117
|
-
dataArr.push([_htmlColorBlock(rPalette(mid, weightMin, weightMax)), format(Math.floor(mid))]);
|
|
118
|
-
}
|
|
119
|
-
dataArr.push([_htmlColorBlock(rPalette(weightMax, weightMin, weightMax)), format(weightMax)]);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
this.columns(colArr);
|
|
124
|
-
this.data(dataArr);
|
|
125
|
-
super.update(domNode, element);
|
|
126
|
-
|
|
127
|
-
element.classed("horiz-legend", this.orientation() === "horizontal");
|
|
128
|
-
|
|
129
|
-
const table = element.select(".tableDiv > table");
|
|
130
|
-
const tableRect = table.node().getBoundingClientRect();
|
|
131
|
-
const elementRect = this._placeholderElement.node().getBoundingClientRect();
|
|
132
|
-
|
|
133
|
-
element.select(".tableDiv").style("overflow", "visible");
|
|
134
|
-
|
|
135
|
-
const top = elementRect.height / 2 - tableRect.height / 2;
|
|
136
|
-
const left = elementRect.width / 2 - tableRect.width / 2;
|
|
137
|
-
table
|
|
138
|
-
.style("position", "absolute")
|
|
139
|
-
.style("top", top + "px")
|
|
140
|
-
.style("left", left + "px")
|
|
141
|
-
;
|
|
142
|
-
|
|
143
|
-
const startIndex = this.pageNumber() - 1;
|
|
144
|
-
const itemsOnPage = this.itemsPerPage();
|
|
145
|
-
|
|
146
|
-
const start = startIndex * itemsOnPage;
|
|
147
|
-
const end = startIndex * parseInt(itemsOnPage) + parseInt(itemsOnPage);
|
|
148
|
-
|
|
149
|
-
let tData = null;
|
|
150
|
-
if (this.pagination()) {
|
|
151
|
-
tData = this.data().slice(start, end);
|
|
152
|
-
} else {
|
|
153
|
-
tData = this.data();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const rows = this.tbody.selectAll("tr").data(tData);
|
|
157
|
-
const context = this;
|
|
158
|
-
rows
|
|
159
|
-
.on("click", function (d, i) {
|
|
160
|
-
context.onClick(d, i);
|
|
161
|
-
})
|
|
162
|
-
.on("dblclick", function (d, i) {
|
|
163
|
-
context.onDblClick(d, i);
|
|
164
|
-
})
|
|
165
|
-
.on("mouseover", function (d, i) {
|
|
166
|
-
context.onMouseOver(d, i);
|
|
167
|
-
})
|
|
168
|
-
;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
exit(domNode, element) {
|
|
172
|
-
if (this._targetWidgetMonitor) {
|
|
173
|
-
this._targetWidgetMonitor.remove();
|
|
174
|
-
delete this._targetWidgetMonitor;
|
|
175
|
-
}
|
|
176
|
-
super.exit(domNode, element);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
onClick(rowData, rowIdx) {
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
onDblClick(rowData, rowIdx) {
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
onMouseOver(rowData, rowIdx) {
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
Legend.prototype._class += " other_Legend";
|
|
190
|
-
|
|
191
|
-
export interface Legend {
|
|
192
|
-
dataFamily(): string;
|
|
193
|
-
dataFamily(_: string): this;
|
|
194
|
-
dataFamily_exists(): boolean;
|
|
195
|
-
orientation(): string;
|
|
196
|
-
orientation(_: string): this;
|
|
197
|
-
orientation_exists(): boolean;
|
|
198
|
-
rainbowFormat(): string;
|
|
199
|
-
rainbowFormat(_: string): this;
|
|
200
|
-
rainbowFormat_exists(): boolean;
|
|
201
|
-
rainbowBins(): number;
|
|
202
|
-
rainbowBins(_: number): this;
|
|
203
|
-
rainbowBins_exists(): boolean;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
Legend.prototype.publish("dataFamily", "ND", "set", "Type of data", ["1D", "2D", "ND", "map", "any", "other"], { tags: ["Private"] });
|
|
207
|
-
Legend.prototype.publish("orientation", "vertical", "set", "Orientation of Legend rows", ["vertical", "horizontal"], { tags: ["Private"] });
|
|
208
|
-
Legend.prototype.publish("rainbowFormat", ",", "string", "Rainbow number formatting", null, { tags: ["Private"], optional: true, disable: w => !w.isRainbow() });
|
|
209
|
-
Legend.prototype.publish("rainbowBins", 8, "number", "Number of rainbow bins", null, { tags: ["Private"], disable: w => !w.isRainbow() });
|
|
210
|
-
|
|
211
|
-
const origGetBBox = Table.prototype.getBBox;
|
|
212
|
-
Legend.prototype.getBBox = function (refresh, round) {
|
|
213
|
-
const retVal = origGetBBox.apply(this, arguments);
|
|
214
|
-
const table = this.element().select(".tableDiv > table");
|
|
215
|
-
if (!table.empty()) {
|
|
216
|
-
const tableRect = table.node().getBoundingClientRect();
|
|
217
|
-
const width = tableRect.width + 8 + (this.hasVScroll(this._placeholderElement) ? Platform.getScrollbarWidth() : 0);
|
|
218
|
-
const height = tableRect.height + 8 + (this.hasHScroll(this._placeholderElement) ? Platform.getScrollbarWidth() : 0);
|
|
219
|
-
return {
|
|
220
|
-
x: retVal.x,
|
|
221
|
-
y: retVal.y,
|
|
222
|
-
width: (round ? Math.round(width) : width) * this._scale,
|
|
223
|
-
height: (round ? Math.round(height) : height) * this._scale
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
return retVal;
|
|
227
|
-
};
|
|
1
|
+
import { Palette, Platform } from "@hpcc-js/common";
|
|
2
|
+
import { format as d3Format } from "d3-format";
|
|
3
|
+
import { select as d3Select } from "d3-selection";
|
|
4
|
+
import { Table } from "./Table.ts";
|
|
5
|
+
|
|
6
|
+
import "../src/Legend.css";
|
|
7
|
+
|
|
8
|
+
function _htmlColorBlock(hexColor) {
|
|
9
|
+
return "<div class=\"colorBlock\" style=\"background-color:" + hexColor + ";\"></div>";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class Legend extends Table {
|
|
13
|
+
_targetWidget;
|
|
14
|
+
_targetWidgetMonitor;
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this.showHeader(false);
|
|
20
|
+
this.pagination(false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
isRainbow() {
|
|
24
|
+
const widget = this.getWidget();
|
|
25
|
+
return widget && widget._palette && widget._palette.type() === "rainbow";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
targetWidget(): any;
|
|
29
|
+
targetWidget(_: any): this;
|
|
30
|
+
targetWidget(_?: any): any | this {
|
|
31
|
+
if (!arguments.length) return this._targetWidget;
|
|
32
|
+
this._targetWidget = _;
|
|
33
|
+
if (this._targetWidgetMonitor) {
|
|
34
|
+
this._targetWidgetMonitor.remove();
|
|
35
|
+
delete this._targetWidgetMonitor;
|
|
36
|
+
}
|
|
37
|
+
const context = this;
|
|
38
|
+
this._targetWidgetMonitor = this._targetWidget.monitor(function (key, newProp, oldProp, source) {
|
|
39
|
+
switch (key) {
|
|
40
|
+
case "chart":
|
|
41
|
+
case "columns":
|
|
42
|
+
case "data":
|
|
43
|
+
case "paletteID":
|
|
44
|
+
context.lazyRender();
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getWidget() {
|
|
52
|
+
if (this._targetWidget) {
|
|
53
|
+
switch (this._targetWidget.classID()) {
|
|
54
|
+
case "chart_MultiChart":
|
|
55
|
+
return this._targetWidget.chart();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return this._targetWidget;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getPalette() {
|
|
62
|
+
const widget = this.getWidget();
|
|
63
|
+
if (widget && widget._palette) {
|
|
64
|
+
switch (widget._palette.type()) {
|
|
65
|
+
case "ordinal":
|
|
66
|
+
return Palette.ordinal(widget._palette.id());
|
|
67
|
+
case "rainbow":
|
|
68
|
+
return Palette.rainbow(widget._palette.id());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Palette.ordinal("default");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
enter(domNode, element) {
|
|
75
|
+
super.enter(domNode, element);
|
|
76
|
+
d3Select(domNode.parentNode).style("overflow-y", "auto");
|
|
77
|
+
|
|
78
|
+
this.renderHtmlDataCells(true);
|
|
79
|
+
this.fixedHeader(false);
|
|
80
|
+
this.fixedSize(true);
|
|
81
|
+
element.classed("other_Legend", true);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
update(domNode, element) {
|
|
85
|
+
const colArr = ["Key", "Label"];
|
|
86
|
+
let dataArr = [];
|
|
87
|
+
if (this._targetWidget) {
|
|
88
|
+
const _palette = this.getPalette();
|
|
89
|
+
switch (_palette.type()) {
|
|
90
|
+
case "ordinal":
|
|
91
|
+
const oPalette = _palette as Palette.OrdinalPaletteFunc;
|
|
92
|
+
switch (this.dataFamily()) {
|
|
93
|
+
case "2D":
|
|
94
|
+
dataArr = this._targetWidget.data().map(function (n) {
|
|
95
|
+
return [_htmlColorBlock(oPalette(n[0])), n[0]];
|
|
96
|
+
}, this);
|
|
97
|
+
break;
|
|
98
|
+
case "ND":
|
|
99
|
+
const widgetColumns = this._targetWidget.columns();
|
|
100
|
+
dataArr = widgetColumns.filter(function (n, i) { return i > 0; }).map(function (n) {
|
|
101
|
+
return [_htmlColorBlock(oPalette(n)), n];
|
|
102
|
+
}, this);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case "rainbow":
|
|
107
|
+
const rPalette = _palette as Palette.RainbowPaletteFunc;
|
|
108
|
+
const format = d3Format(this.rainbowFormat());
|
|
109
|
+
const widget = this.getWidget();
|
|
110
|
+
const steps = this.rainbowBins();
|
|
111
|
+
const weightMin = widget._dataMinWeight;
|
|
112
|
+
const weightMax = widget._dataMaxWeight;
|
|
113
|
+
const stepWeightDiff = (weightMax - weightMin) / (steps - 1);
|
|
114
|
+
dataArr.push([_htmlColorBlock(rPalette(weightMin, weightMin, weightMax)), format(weightMin)]);
|
|
115
|
+
for (let x = 1; x < steps - 1; ++x) {
|
|
116
|
+
const mid = stepWeightDiff * x;
|
|
117
|
+
dataArr.push([_htmlColorBlock(rPalette(mid, weightMin, weightMax)), format(Math.floor(mid))]);
|
|
118
|
+
}
|
|
119
|
+
dataArr.push([_htmlColorBlock(rPalette(weightMax, weightMin, weightMax)), format(weightMax)]);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
this.columns(colArr);
|
|
124
|
+
this.data(dataArr);
|
|
125
|
+
super.update(domNode, element);
|
|
126
|
+
|
|
127
|
+
element.classed("horiz-legend", this.orientation() === "horizontal");
|
|
128
|
+
|
|
129
|
+
const table = element.select(".tableDiv > table");
|
|
130
|
+
const tableRect = table.node().getBoundingClientRect();
|
|
131
|
+
const elementRect = this._placeholderElement.node().getBoundingClientRect();
|
|
132
|
+
|
|
133
|
+
element.select(".tableDiv").style("overflow", "visible");
|
|
134
|
+
|
|
135
|
+
const top = elementRect.height / 2 - tableRect.height / 2;
|
|
136
|
+
const left = elementRect.width / 2 - tableRect.width / 2;
|
|
137
|
+
table
|
|
138
|
+
.style("position", "absolute")
|
|
139
|
+
.style("top", top + "px")
|
|
140
|
+
.style("left", left + "px")
|
|
141
|
+
;
|
|
142
|
+
|
|
143
|
+
const startIndex = this.pageNumber() - 1;
|
|
144
|
+
const itemsOnPage = this.itemsPerPage();
|
|
145
|
+
|
|
146
|
+
const start = startIndex * itemsOnPage;
|
|
147
|
+
const end = startIndex * parseInt(itemsOnPage) + parseInt(itemsOnPage);
|
|
148
|
+
|
|
149
|
+
let tData = null;
|
|
150
|
+
if (this.pagination()) {
|
|
151
|
+
tData = this.data().slice(start, end);
|
|
152
|
+
} else {
|
|
153
|
+
tData = this.data();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const rows = this.tbody.selectAll("tr").data(tData);
|
|
157
|
+
const context = this;
|
|
158
|
+
rows
|
|
159
|
+
.on("click", function (d, i) {
|
|
160
|
+
context.onClick(d, i);
|
|
161
|
+
})
|
|
162
|
+
.on("dblclick", function (d, i) {
|
|
163
|
+
context.onDblClick(d, i);
|
|
164
|
+
})
|
|
165
|
+
.on("mouseover", function (d, i) {
|
|
166
|
+
context.onMouseOver(d, i);
|
|
167
|
+
})
|
|
168
|
+
;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exit(domNode, element) {
|
|
172
|
+
if (this._targetWidgetMonitor) {
|
|
173
|
+
this._targetWidgetMonitor.remove();
|
|
174
|
+
delete this._targetWidgetMonitor;
|
|
175
|
+
}
|
|
176
|
+
super.exit(domNode, element);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
onClick(rowData, rowIdx) {
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onDblClick(rowData, rowIdx) {
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
onMouseOver(rowData, rowIdx) {
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
Legend.prototype._class += " other_Legend";
|
|
190
|
+
|
|
191
|
+
export interface Legend {
|
|
192
|
+
dataFamily(): string;
|
|
193
|
+
dataFamily(_: string): this;
|
|
194
|
+
dataFamily_exists(): boolean;
|
|
195
|
+
orientation(): string;
|
|
196
|
+
orientation(_: string): this;
|
|
197
|
+
orientation_exists(): boolean;
|
|
198
|
+
rainbowFormat(): string;
|
|
199
|
+
rainbowFormat(_: string): this;
|
|
200
|
+
rainbowFormat_exists(): boolean;
|
|
201
|
+
rainbowBins(): number;
|
|
202
|
+
rainbowBins(_: number): this;
|
|
203
|
+
rainbowBins_exists(): boolean;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
Legend.prototype.publish("dataFamily", "ND", "set", "Type of data", ["1D", "2D", "ND", "map", "any", "other"], { tags: ["Private"] });
|
|
207
|
+
Legend.prototype.publish("orientation", "vertical", "set", "Orientation of Legend rows", ["vertical", "horizontal"], { tags: ["Private"] });
|
|
208
|
+
Legend.prototype.publish("rainbowFormat", ",", "string", "Rainbow number formatting", null, { tags: ["Private"], optional: true, disable: w => !w.isRainbow() });
|
|
209
|
+
Legend.prototype.publish("rainbowBins", 8, "number", "Number of rainbow bins", null, { tags: ["Private"], disable: w => !w.isRainbow() });
|
|
210
|
+
|
|
211
|
+
const origGetBBox = Table.prototype.getBBox;
|
|
212
|
+
Legend.prototype.getBBox = function (refresh, round) {
|
|
213
|
+
const retVal = origGetBBox.apply(this, arguments);
|
|
214
|
+
const table = this.element().select(".tableDiv > table");
|
|
215
|
+
if (!table.empty()) {
|
|
216
|
+
const tableRect = table.node().getBoundingClientRect();
|
|
217
|
+
const width = tableRect.width + 8 + (this.hasVScroll(this._placeholderElement) ? Platform.getScrollbarWidth() : 0);
|
|
218
|
+
const height = tableRect.height + 8 + (this.hasHScroll(this._placeholderElement) ? Platform.getScrollbarWidth() : 0);
|
|
219
|
+
return {
|
|
220
|
+
x: retVal.x,
|
|
221
|
+
y: retVal.y,
|
|
222
|
+
width: (round ? Math.round(width) : width) * this._scale,
|
|
223
|
+
height: (round ? Math.round(height) : height) * this._scale
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return retVal;
|
|
227
|
+
};
|