Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function dividersToPartition(def, scores) {
if (!def.regions || !def.dividers || !scores) return null;
if (def.regions.length !== def.dividers.length + 1) return null;
const uncertScale = getUncertScale(def);
const partitionSelection = SelectionBuilder.partition(
def.name,
def.dividers
);
partitionSelection.partition.dividers.forEach((div, index) => {
div.uncertainty *= uncertScale;
});
// console.log('DBG partitionSelection', JSON.stringify(partitionSelection, 2));
// Construct a partition annotation:
let partitionAnnotation = null;
if (def.annotation && !model.provider.shouldCreateNewAnnotation()) {
// don't send a new selection unless it's changed.
const saveGen = partitionSelection.generation;
partitionSelection.generation = def.annotation.selection.generation;
const changeSet = { score: def.regions };
if (!deepEquals(partitionSelection, def.annotation.selection)) {
{ name: 'Yes', color: '#00C900', value: 100 },
{ name: 'Maybe', color: '#FFFF00', value: 0 },
{ name: 'No', color: '#C90000', value: -Number.MAX_VALUE },
];
const rangeSelection = SelectionBuilder.range({
pressure: [
{ interval: [0, 101.3], endpoints: 'oo', uncertainty: 15 },
{ interval: [200, 400], endpoints: '*o', uncertainty: 30 },
],
temperature: [
{ interval: [233, Number.MAX_VALUE], endpoints: 'oo', uncertainty: 15 },
],
});
const partitionSelection = SelectionBuilder.partition('pressure', [
{ value: 90, uncertainty: 0 },
{ value: 101.3, uncertainty: 10 },
{ value: 200, uncertainty: 40, closeToLeft: true },
]);
const ranges = {
pressure: [0, 600],
temperature: [-270, 1000],
};
const annotations = [
AnnotationBuilder.annotation(rangeSelection, [0]),
AnnotationBuilder.annotation(partitionSelection, [1, 0, 1, 2]),
AnnotationBuilder.annotation(
SelectionBuilder.convertToRuleSelection(rangeSelection),
[1]
import SelectionEditorWidget from 'paraviewweb/src/React/Widgets/SelectionEditorWidget';
import SelectionBuilder from 'paraviewweb/src/Common/Misc/SelectionBuilder';
import LegendProvider from 'paraviewweb/src/InfoViz/Core/LegendProvider';
const rangeSelection = SelectionBuilder.range({
pressure: [
{ interval: [0, 101.3], endpoints: 'oo', uncertainty: 15 },
{ interval: [200, 400], endpoints: '*o', uncertainty: 30 },
],
temperature: [
{ interval: [233, Number.MAX_VALUE], endpoints: 'oo', uncertainty: 15 },
],
});
const partitionSelection = SelectionBuilder.partition('pressure', [
{ value: 90, uncertainty: 0 },
{ value: 101.3, uncertainty: 10 },
{ value: 200, uncertainty: 40, closeToLeft: true },
]);
const ranges = {
pressure: [0, 600],
temperature: [-270, 1000],
};
const selectionTypes = [
rangeSelection,
partitionSelection,
SelectionBuilder.convertToRuleSelection(rangeSelection),
];