(colorBinType: ColorBin, column: Column, legend: VegaDeckGl.types.Legend, clickedIndex: number)
| 38 | } |
| 39 | |
| 40 | function selectQuantitative(colorBinType: ColorBin, column: Column, legend: VegaDeckGl.types.Legend, clickedIndex: number): SearchExpressionGroup { |
| 41 | const keys = Object.keys(legend.rows).map(key => +key).sort((a, b) => +a - +b); |
| 42 | let lowValue: string; |
| 43 | let lowOperator: SearchExpressionOperators; |
| 44 | let highValue: string; |
| 45 | let highOperator: SearchExpressionOperators; |
| 46 | const rowText = legend.rows[clickedIndex].label; |
| 47 | switch (colorBinType) { |
| 48 | case 'continuous': { |
| 49 | lowValue = rowText; |
| 50 | if (clickedIndex < keys.length - 1) { |
| 51 | highValue = legend.rows[clickedIndex + 1].value; |
| 52 | } |
| 53 | break; |
| 54 | } |
| 55 | default: { |
| 56 | if (rowText.indexOf('null') > 0) { |
| 57 | const ex: SearchExpressionGroup = { |
| 58 | expressions: [selectNullOrEmpty(column)], |
| 59 | }; |
| 60 | return ex; |
| 61 | } |
| 62 | const dash = rowText.indexOf('–'); //this is not the common dash character! |
| 63 | if (dash > 0) { |
| 64 | //bug in Vega for quantize? |
| 65 | //lowOperator = '>'; |
| 66 | //highOperator = '<='; |
| 67 | lowValue = rowText.substr(0, dash); |
| 68 | highValue = rowText.substr(dash + 1); |
| 69 | } else { |
| 70 | if (rowText.indexOf('<') >= 0) { |
| 71 | highValue = rowText.substring(2); |
| 72 | } else { |
| 73 | if (rowText.indexOf('≥') >= 0) { |
| 74 | lowValue = rowText.substring(2); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | if (lowValue) lowValue = notNice(lowValue); |
| 81 | if (highValue) highValue = notNice(highValue); |
| 82 | if (lowValue === highValue) { |
| 83 | return { expressions: [selectExact(column, lowValue)] }; |
| 84 | } else { |
| 85 | return selectBetween(column, lowValue, highValue, lowOperator, highOperator); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | export function finalizeLegend(colorBinType: ColorBin, colorColumn: Column, legend: VegaDeckGl.types.Legend, language: Language) { |
| 90 | const rowTexts: string[] = []; |
no test coverage detected