diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index ff00e16803325..92474fdbf456e 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -27419,12 +27419,12 @@ } }, "node_modules/echarts": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.2.tgz", - "integrity": "sha512-LWCt7ohOKdJqyiBJ0OGBmE9szLdfA9sGcsMEi+GGoc6+Xo75C+BkcT/6NNGRHAWtnQl2fNow05AQjznpap28TQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.4.0.tgz", + "integrity": "sha512-uPsO9VRUIKAdFOoH3B0aNg7NRVdN7aM39/OjovjO9MwmWsAkfGyeXJhK+dbRi51iDrQWliXV60/XwLA7kg3z0w==", "dependencies": { "tslib": "2.3.0", - "zrender": "5.3.1" + "zrender": "5.4.0" } }, "node_modules/echarts/node_modules/tslib": { @@ -54712,9 +54712,9 @@ } }, "node_modules/zrender": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.3.1.tgz", - "integrity": "sha512-7olqIjy0gWfznKr6vgfnGBk7y4UtdMvdwFmK92vVQsQeDPyzkHW1OlrLEKg6GHz1W5ePf0FeN1q2vkl/HFqhXw==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.0.tgz", + "integrity": "sha512-rOS09Z2HSVGFs2dn/TuYk5BlCaZcVe8UDLLjj1ySYF828LATKKdxuakSZMvrDz54yiKPDYVfjdKqcX8Jky3BIA==", "dependencies": { "tslib": "2.3.0" } @@ -56213,7 +56213,7 @@ "license": "Apache-2.0", "dependencies": { "d3-array": "^1.2.0", - "echarts": "^5.3.2", + "echarts": "^5.4.0", "lodash": "^4.17.15", "moment": "^2.26.0" }, @@ -70201,7 +70201,7 @@ "version": "file:plugins/plugin-chart-echarts", "requires": { "d3-array": "^1.2.0", - "echarts": "^5.3.2", + "echarts": "^5.4.0", "lodash": "^4.17.15", "moment": "^2.26.0" } @@ -78377,12 +78377,12 @@ } }, "echarts": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.2.tgz", - "integrity": "sha512-LWCt7ohOKdJqyiBJ0OGBmE9szLdfA9sGcsMEi+GGoc6+Xo75C+BkcT/6NNGRHAWtnQl2fNow05AQjznpap28TQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.4.0.tgz", + "integrity": "sha512-uPsO9VRUIKAdFOoH3B0aNg7NRVdN7aM39/OjovjO9MwmWsAkfGyeXJhK+dbRi51iDrQWliXV60/XwLA7kg3z0w==", "requires": { "tslib": "2.3.0", - "zrender": "5.3.1" + "zrender": "5.4.0" }, "dependencies": { "tslib": { @@ -99450,9 +99450,9 @@ } }, "zrender": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.3.1.tgz", - "integrity": "sha512-7olqIjy0gWfznKr6vgfnGBk7y4UtdMvdwFmK92vVQsQeDPyzkHW1OlrLEKg6GHz1W5ePf0FeN1q2vkl/HFqhXw==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.0.tgz", + "integrity": "sha512-rOS09Z2HSVGFs2dn/TuYk5BlCaZcVe8UDLLjj1ySYF828LATKKdxuakSZMvrDz54yiKPDYVfjdKqcX8Jky3BIA==", "requires": { "tslib": "2.3.0" }, diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/Stories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/Stories.tsx index b44ba252ea5d4..342db6f5bad41 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/Stories.tsx +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/Stories.tsx @@ -26,6 +26,8 @@ import { } from '@superset-ui/plugin-chart-echarts'; import data from './data'; import negativeNumData from './negativeNumData'; +import confbandData from './confbandData'; +import stackWithNullsData from './stackWithNulls'; import { withResizableChartDemo } from '../../../../shared/components/ResizableChartDemo'; new EchartsTimeseriesChartPlugin() @@ -66,26 +68,26 @@ export const Timeseries = ({ width, height }) => { { data: queryData, colnames: ['__timestamp'], coltypes: [2] }, ]} formData={{ - contributionMode: undefined, forecastEnabled, - colorScheme: 'supersetColors', + color_scheme: 'supersetColors', seriesType: select( 'Line type', ['line', 'scatter', 'smooth', 'bar', 'start', 'middle', 'end'], 'line', ), logAxis: boolean('Log axis', false), - yAxisFormat: 'SMART_NUMBER', + y_axis_format: 'SMART_NUMBER', stack: boolean('Stack', false), - showValue: boolean('Show Values', false), - onlyTotal: boolean('Only Total', false), - percentageThreshold: number('Percentage Threshold', 0), + show_value: boolean('Show Values', false), + only_total: boolean('Only Total', false), + percentage_threshold: number('Percentage Threshold', 0), area: boolean('Area chart', false), markerEnabled: boolean('Enable markers', false), markerSize: number('Marker Size', 6), minorSplitLine: boolean('Minor splitline', false), opacity: number('Opacity', 0.2), zoomable: boolean('Zoomable', false), + x_axis: '__timestamp', }} /> ); @@ -100,23 +102,71 @@ export const WithNegativeNumbers = ({ width, height }) => ( { data: negativeNumData, colnames: ['__timestamp'], coltypes: [2] }, ]} formData={{ - contributionMode: undefined, - colorScheme: 'supersetColors', + color_scheme: 'supersetColors', seriesType: select( 'Line type', ['line', 'scatter', 'smooth', 'bar', 'start', 'middle', 'end'], 'line', ), - yAxisFormat: '$,.2f', + y_axis_format: '$,.2f', stack: boolean('Stack', true), - showValue: true, - showLegend: true, - onlyTotal: boolean('Only Total', true), + show_value: true, + show_legend: true, + only_total: boolean('Only Total', true), orientation: select( 'Orientation', ['vertical', 'horizontal'], 'vertical', ), + x_axis: '__timestamp', + }} + /> +); + +export const ConfidenceBand = ({ width, height }) => ( + +); + +export const StackWithNulls = ({ width, height }) => ( + ); diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/confbandData.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/confbandData.ts new file mode 100644 index 0000000000000..46529e59b1eee --- /dev/null +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/confbandData.ts @@ -0,0 +1,329 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export default [ + { + ds: -157766400000, + 'SUM(num)': 173161, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: -126230400000, + 'SUM(num)': 173777, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: -94694400000, + 'SUM(num)': 178221, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: -63158400000, + 'SUM(num)': 176779, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: -31536000000, + 'SUM(num)': 184113, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 0, + 'SUM(num)': 188343, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 31536000000, + 'SUM(num)': 178441, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 63072000000, + 'SUM(num)': 169507, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 94694400000, + 'SUM(num)': 156783, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 126230400000, + 'SUM(num)': 157434, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 157766400000, + 'SUM(num)': 153606, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 189302400000, + 'SUM(num)': 150937, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 220924800000, + 'SUM(num)': 154361, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 252460800000, + 'SUM(num)': 154515, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 283996800000, + 'SUM(num)': 159885, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 315532800000, + 'SUM(num)': 159087, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 347155200000, + 'SUM(num)': 159061, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 378691200000, + 'SUM(num)': 167242, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 410227200000, + 'SUM(num)': 165944, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 441763200000, + 'SUM(num)': 165662, + 'SUM(num)__yhat': null, + 'SUM(num)__yhat_lower': null, + 'SUM(num)__yhat_upper': null, + }, + { + ds: 473385600000, + 'SUM(num)': 162578, + 'SUM(num)__yhat': 162578, + 'SUM(num)__yhat_lower': 162578, + 'SUM(num)__yhat_upper': 162578, + }, + { + ds: 504921600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 157613, + 'SUM(num)__yhat_lower': 147613, + 'SUM(num)__yhat_upper': 167613, + }, + { + ds: 536457600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 154580, + 'SUM(num)__yhat_lower': 134580, + 'SUM(num)__yhat_upper': 174580, + }, + { + ds: 567993600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 152134, + 'SUM(num)__yhat_lower': 122134, + 'SUM(num)__yhat_upper': 182134, + }, + { + ds: 599616000000, + 'SUM(num)': null, + 'SUM(num)__yhat': 153577, + 'SUM(num)__yhat_lower': 113577, + 'SUM(num)__yhat_upper': 193577, + }, + { + ds: 631152000000, + 'SUM(num)': null, + 'SUM(num)__yhat': 151121, + 'SUM(num)__yhat_lower': 101121, + 'SUM(num)__yhat_upper': 201121, + }, + { + ds: 662688000000, + 'SUM(num)': null, + 'SUM(num)__yhat': 138102, + 'SUM(num)__yhat_lower': 78102, + 'SUM(num)__yhat_upper': 208102, + }, + { + ds: 694224000000, + 'SUM(num)': null, + 'SUM(num)__yhat': 125030, + 'SUM(num)__yhat_lower': 45030, + 'SUM(num)__yhat_upper': 205030, + }, + { + ds: 725846400000, + 'SUM(num)': null, + 'SUM(num)__yhat': 114647, + 'SUM(num)__yhat_lower': 24647, + 'SUM(num)__yhat_upper': 204647, + }, + { + ds: 757382400000, + 'SUM(num)': null, + 'SUM(num)__yhat': 103968, + 'SUM(num)__yhat_lower': 13968, + 'SUM(num)__yhat_upper': 193968, + }, + { + ds: 788918400000, + 'SUM(num)': null, + 'SUM(num)__yhat': 97006, + 'SUM(num)__yhat_lower': 7006, + 'SUM(num)__yhat_upper': 187006, + }, + { + ds: 820454400000, + 'SUM(num)': null, + 'SUM(num)__yhat': 92213, + 'SUM(num)__yhat_lower': 2213, + 'SUM(num)__yhat_upper': 182213, + }, + { + ds: 852076800000, + 'SUM(num)': null, + 'SUM(num)__yhat': 88462, + 'SUM(num)__yhat_lower': -1538, + 'SUM(num)__yhat_upper': 178462, + }, + { + ds: 883612800000, + 'SUM(num)': null, + 'SUM(num)__yhat': 84424, + 'SUM(num)__yhat_lower': -5576, + 'SUM(num)__yhat_upper': 174424, + }, + { + ds: 915148800000, + 'SUM(num)': null, + 'SUM(num)__yhat': 79787, + 'SUM(num)__yhat_lower': -10213, + 'SUM(num)__yhat_upper': 169787, + }, + { + ds: 946684800000, + 'SUM(num)': null, + 'SUM(num)__yhat': 76610, + 'SUM(num)__yhat_lower': -13390, + 'SUM(num)__yhat_upper': 166610, + }, + { + ds: 978307200000, + 'SUM(num)': null, + 'SUM(num)__yhat': 72073, + 'SUM(num)__yhat_lower': -17927, + 'SUM(num)__yhat_upper': 162073, + }, + { + ds: 1009843200000, + 'SUM(num)': null, + 'SUM(num)__yhat': 68487, + 'SUM(num)__yhat_lower': -21513, + 'SUM(num)__yhat_upper': 158487, + }, + { + ds: 1041379200000, + 'SUM(num)': null, + 'SUM(num)__yhat': 66381, + 'SUM(num)__yhat_lower': -23619, + 'SUM(num)__yhat_upper': 156381, + }, + { + ds: 1072915200000, + 'SUM(num)': null, + 'SUM(num)__yhat': 63472, + 'SUM(num)__yhat_lower': -26528, + 'SUM(num)__yhat_upper': 153472, + }, + { + ds: 1104537600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 60885, + 'SUM(num)__yhat_lower': -29115, + 'SUM(num)__yhat_upper': 150885, + }, + { + ds: 1136073600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 59682, + 'SUM(num)__yhat_lower': -30318, + 'SUM(num)__yhat_upper': 149682, + }, + { + ds: 1167609600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 59191, + 'SUM(num)__yhat_lower': -30809, + 'SUM(num)__yhat_upper': 149191, + }, + { + ds: 1199145600000, + 'SUM(num)': null, + 'SUM(num)__yhat': 54091, + 'SUM(num)__yhat_lower': -35909, + 'SUM(num)__yhat_upper': 144091, + }, +]; diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/stackWithNulls.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/stackWithNulls.ts new file mode 100644 index 0000000000000..8416fa09def21 --- /dev/null +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Timeseries/stackWithNulls.ts @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export default [ + { + ds: 1293840000000, + '1': 2, + '2': 1, + }, + { + ds: 1325376000000, + '1': null, + '2': null, + }, + { + ds: 1356998400000, + '1': null, + '2': 1, + }, +]; diff --git a/superset-frontend/plugins/plugin-chart-echarts/package.json b/superset-frontend/plugins/plugin-chart-echarts/package.json index 0c5cbcf595ae0..02da13b0d12bc 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/package.json +++ b/superset-frontend/plugins/plugin-chart-echarts/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "d3-array": "^1.2.0", - "echarts": "^5.3.2", + "echarts": "^5.4.0", "lodash": "^4.17.15", "moment": "^2.26.0" }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts index bc84b8d655635..b49f9f546bd28 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts @@ -208,6 +208,7 @@ export function transformSeries( ? seriesType : undefined, stack: stackId, + stackStrategy: isConfidenceBand ? 'all' : 'samesign', lineStyle, areaStyle: area || forecastSeries.type === ForecastSeriesEnum.ForecastUpper