MCPcopy Create free account
hub / github.com/microsoft/SandDance / selectQuantitative

Function selectQuantitative

docs/tests/v2/es6/js/sanddance.js:153901–153953  ·  view source on GitHub ↗
(colorBinType, column, legend, clickedIndex)

Source from the content-addressed store, hash-verified

153899}
153900
153901function selectQuantitative(colorBinType, column, legend, clickedIndex) {
153902 const keys = Object.keys(legend.rows).map(key => +key).sort((a, b) => +a - +b);
153903 let lowValue;
153904 let lowOperator;
153905 let highValue;
153906 let highOperator;
153907 const rowText = legend.rows[clickedIndex].label;
153908
153909 switch (colorBinType) {
153910 case 'continuous':
153911 {
153912 lowValue = rowText;
153913
153914 if (clickedIndex < keys.length - 1) {
153915 highValue = legend.rows[clickedIndex + 1].value;
153916 }
153917
153918 break;
153919 }
153920
153921 default:
153922 {
153923 if (rowText.indexOf('null') > 0) {
153924 const ex = {
153925 expressions: [(0, _expression.selectNullOrEmpty)(column)]
153926 };
153927 return ex;
153928 }
153929
153930 const dash = rowText.indexOf('–'); //this is not the common dash character!
153931
153932 if (dash > 0) {
153933 //bug in Vega for quantize?
153934 //lowOperator = '>';
153935 //highOperator = '<=';
153936 lowValue = rowText.substr(0, dash);
153937 highValue = rowText.substr(dash + 1);
153938 } else {
153939 if (rowText.indexOf('<') >= 0) {
153940 highValue = rowText.substring(2);
153941 } else {
153942 if (rowText.indexOf('≥') >= 0) {
153943 lowValue = rowText.substring(2);
153944 }
153945 }
153946 }
153947 }
153948 }
153949
153950 if (lowValue) lowValue = (0, _expression.notNice)(lowValue);
153951 if (highValue) highValue = (0, _expression.notNice)(highValue);
153952 return (0, _expression.selectBetween)(column, lowValue, highValue, lowOperator, highOperator);
153953}
153954
153955function finalizeLegend(colorBinType, colorColumn, legend, language) {
153956 const rowTexts = [];

Callers 1

legendRangeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected