(skipDataProcessing, filters, variables)
| 51 | } |
| 52 | |
| 53 | plot(skipDataProcessing, filters, variables) { |
| 54 | // skip the data processing if not required (this algorithm is CPU-intensive) |
| 55 | const conditionsOptions = []; |
| 56 | let gXType; |
| 57 | const runtimeContext = buildChartRuntimeContext(this.chart, filters, variables, this.timezone); |
| 58 | const startDate = runtimeContext?.effectiveDateRange?.startDate || null; |
| 59 | const endDate = runtimeContext?.effectiveDateRange?.endDate || null; |
| 60 | |
| 61 | if ( |
| 62 | !skipDataProcessing |
| 63 | || !this.chart.chartData |
| 64 | || !this.chart.chartData.data |
| 65 | || !this.chart.chartData.data.labels |
| 66 | || !this.chart.chartData.data.datasets |
| 67 | ) { |
| 68 | // check if the global date filter should be on or off |
| 69 | // the filter should work only if all the datasets have a dateField |
| 70 | let canDateFilter = true; |
| 71 | this.datasets.map((dataset) => { |
| 72 | if (!dataset.options || !dataset.options.dateField) { |
| 73 | canDateFilter = false; |
| 74 | } |
| 75 | |
| 76 | return dataset; |
| 77 | }); |
| 78 | |
| 79 | for (let i = 0; i < this.datasets.length; i++) { |
| 80 | const dataset = this.datasets[i]; |
| 81 | const { yAxisOperation, dateField } = dataset.options; |
| 82 | let { xAxis, yAxis } = dataset.options; |
| 83 | if (!xAxis && ["kpi", "avg", "gauge"].includes(this.chart.type) && yAxis) { |
| 84 | xAxis = yAxis; |
| 85 | } |
| 86 | if (!xAxis) { |
| 87 | throw new Error("Chart xAxis binding is required"); |
| 88 | } |
| 89 | if (!yAxis) { |
| 90 | throw new Error("Chart yAxis binding is required"); |
| 91 | } |
| 92 | let xData; |
| 93 | let yData; |
| 94 | let yType; |
| 95 | let xType; |
| 96 | let xAxisData = []; |
| 97 | let yAxisData = []; |
| 98 | |
| 99 | let filterData = { data: dataset.data }; |
| 100 | |
| 101 | if (dataset?.options?.conditions) { |
| 102 | // Filter out conditions that contain mustache notation ({{variable}}) |
| 103 | // - save them for variable processing |
| 104 | const nonVariableConditions = dataset.options.conditions |
| 105 | .filter((condition) => !condition.value || !condition.value.toString().includes("{{")); |
| 106 | |
| 107 | if (nonVariableConditions.length > 0) { |
| 108 | filterData = dataFilter( |
| 109 | dataset.data, xAxis, nonVariableConditions, this.timezone, this.chart.timeInterval |
| 110 | ); |
no test coverage detected