-
Notifications
You must be signed in to change notification settings - Fork 1
/
d3-array.html
123 lines (121 loc) · 6.26 KB
/
d3-array.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<script type="text/x-red" data-template-name="d3-array">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="d3-array.label.property"></span></label>
<input type="text" id="node-input-property" style="width: 70%"/>
</div>
<div class="form-row">
<label for="node-input-function"><i class="fa fa-random"></i> <span data-i18n="d3-array.label.function"></span></label>
<select id="node-input-function" style="width:70%;">
<optgroup data-i18n="[label]d3-array.function.statistics.title">
<option value="min" data-i18n="d3-array.function.statistics.min"></option>
<option value="max" data-i18n="d3-array.function.statistics.max"></option>
<option value="minIndex" data-i18n="d3-array.function.statistics.minIndex"></option>
<option value="maxIndex" data-i18n="d3-array.function.statistics.maxIndex"></option>
<option value="extent" data-i18n="d3-array.function.statistics.extent"></option>
<option value="sum" data-i18n="d3-array.function.statistics.sum"></option>
<option value="mean" data-i18n="d3-array.function.statistics.mean"></option>
<option value="median" data-i18n="d3-array.function.statistics.median"></option>
<option value="quantile" data-i18n="d3-array.function.statistics.quantile"></option>
<option value="quantileSorted" data-i18n="d3-array.function.statistics.quantileSorted"></option>
<option value="variance" data-i18n="d3-array.function.statistics.variance"></option>
<option value="deviation" data-i18n="d3-array.function.statistics.deviation"></option>
</optgroup>
<optgroup data-i18n="[label]d3-array.function.search.title">
<option value="least" data-i18n="d3-array.function.search.least"></option>
<option value="greatest" data-i18n="d3-array.function.search.greatest"></option>
<option value="leastIndex" data-i18n="d3-array.function.search.leastIndex"></option>
<option value="greatestIndex" data-i18n="d3-array.function.search.greatestIndex"></option>
<option value="bisect" data-i18n="d3-array.function.search.bisect"></option>
<option value="quickSelect" data-i18n="d3-array.function.search.quickSelect"></option>
<option value="ascending" data-i18n="d3-array.function.search.ascending"></option>
<option value="descending" data-i18n="d3-array.function.search.descending"></option>
</optgroup>
<optgroup data-i18n="[label]d3-array.function.transformations.title">
<option value="group" data-i18n="d3-array.function.transformations.group"></option>
<option value="rollup" data-i18n="d3-array.function.transformations.rollup"></option>
<option value="count" data-i18n="d3-array.function.transformations.count"></option>
<option value="merge" data-i18n="d3-array.function.transformations.merge"></option>
<option value="pairs" data-i18n="d3-array.function.transformations.pairs"></option>
<option value="permute" data-i18n="d3-array.function.transformations.permute"></option>
<option value="shuffle" data-i18n="d3-array.function.transformations.shuffle"></option>
<option value="ticks" data-i18n="d3-array.function.transformations.ticks"></option>
<option value="tickIncrement" data-i18n="d3-array.function.transformations.tickIncrement"></option>
<option value="tickStep" data-i18n="d3-array.function.transformations.tickStep"></option>
<option value="range" data-i18n="d3-array.function.transformations.range"></option>
<option value="zip" data-i18n="d3-array.function.transformations.zip"></option>
</optgroup>
</select>
</div>
<div class="form-row node-input-accessors-container-row">
<label style="width:100%;" for="node-input-accessors-container"><i class="fa fa-cogs"></i> <span data-i18n="d3-array.label.parameters"></span></label>
<ol id="node-input-accessors-container"></ol>
<input type="hidden" id="node-input-accessors"/>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('d3-array', {
category: 'sequence',
color: '#E2D96E',
defaults: {
name: { value: '' },
property: { value: 'payload', required: true, validate: RED.validators.typedInput('propertyType') },
propertyType: { value: 'msg' },
function: { value: '', required: true },
accessors: { value: '[{ "fn": "", "t": "jsonata" }]' }
},
inputs: 1,
outputs: 1,
icon: 'function.svg',
label: function() {
return this.name || this._('d3-array.label.title');
},
labelStyle: function() {
return this.name ? 'node_label_italic' : '';
},
oneditprepare: function() {
$('#node-input-property').typedInput({
default: this.propertyType,
types: ['msg', 'flow', 'global', 'num', 'str', 'json']
});
$('#node-input-accessors-container')
.css('min-height', '250px')
.css('min-width', '450px')
.editableList({
addItem: function(container, i, opt) {
$('<input/>', { class: 'node-input-accessor-value', type: 'text', style: 'width: 100%;margin-left: 5px;' })
.appendTo(container)
.typedInput({ default: 'jsonata', types: ['msg', 'num', 'str', 'json', 'jsonata'] });
if (opt != null && opt.fn != null) {
$('.node-input-accessor-value', container).typedInput('value', opt.fn);
$('.node-input-accessor-value', container).typedInput('type', opt.t);
}
},
removeItem: function(opt) {},
sortItems: function(accessors) {},
sortable: true,
removable: true
});
const accessors = JSON.parse(this.accessors);
for (var i = 0; i < accessors.length; i++) {
var accessor = accessors[i];
$('#node-input-accessors-container').editableList('addItem', accessor);
}
},
oneditsave: function() {
var accessors = $('#node-input-accessors-container').editableList('items');
this.propertyType = $('#node-input-property').typedInput('type');
var result = [];
accessors.each(function() {
var accessor = $(this);
const fn = accessor.find('.node-input-accessor-value').typedInput('value');
const t = accessor.find('.node-input-accessor-value').typedInput('type');
result.push({ fn, t });
});
$('#node-input-accessors').val(JSON.stringify(result));
}
});
</script>