-
Notifications
You must be signed in to change notification settings - Fork 18.3k
feat(time-pivot): rebuild Time-series Period Pivot on ECharts #42245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ab4224f
feat(time-pivot): rebuild Time-series Period Pivot on ECharts
claude 44d8d23
fix: apply oxlint auto-fix for destructuring assignment
rusackas 70b6c5c
fix: open external docs link with noopener,noreferrer to prevent reve…
rusackas 351ec03
fix(time-pivot): show sparse-period symbols, legend off by default, x…
claude 6d518ac
fix(time-pivot): compare x-axis format against the smart_date id literal
claude 663dd27
fix(time-pivot): anchor log-axis min to smallest positive value
rusackas f373e98
docs(time-pivot): explain the grain-vs-frequency relationship in the …
claude ed9d9d4
feat(time-pivot): limit the overlay to the N most recent periods
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/EchartsTimePivot.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| import Echart from '../components/Echart'; | ||
| import { allEventHandlers } from '../utils/eventHandlers'; | ||
| import { TimePivotChartTransformedProps } from './types'; | ||
|
|
||
| export default function EchartsTimePivot( | ||
| props: TimePivotChartTransformedProps, | ||
| ) { | ||
| const { height, width, echartOptions, refs, formData } = props; | ||
|
|
||
| const eventHandlers = allEventHandlers(props); | ||
|
|
||
| return ( | ||
| <Echart | ||
| refs={refs} | ||
| height={height} | ||
| width={width} | ||
| echartOptions={echartOptions} | ||
| eventHandlers={eventHandlers} | ||
| vizType={formData.vizType} | ||
| /> | ||
| ); | ||
| } |
34 changes: 34 additions & 0 deletions
34
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/buildQuery.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| import { buildQueryContext, QueryFormData } from '@superset-ui/core'; | ||
|
|
||
| /** | ||
| * Mirrors the legacy NVD3TimePivotViz.query_obj: a timeseries query with | ||
| * the single metric. | ||
| */ | ||
| export default function buildQuery(formData: QueryFormData) { | ||
| const { metric } = formData; | ||
| return buildQueryContext(formData, baseQueryObject => [ | ||
| { | ||
| ...baseQueryObject, | ||
| is_timeseries: true, | ||
| metrics: metric ? [metric] : [], | ||
| }, | ||
| ]); | ||
| } |
210 changes: 210 additions & 0 deletions
210
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/controlPanel.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,210 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| import { t } from '@apache-superset/core/translation'; | ||
| import { | ||
| ControlPanelConfig, | ||
| D3_TIME_FORMAT_OPTIONS, | ||
| sections, | ||
| } from '@superset-ui/chart-controls'; | ||
|
|
||
| // Control names match the legacy nvd3 chart so saved charts keep working | ||
| // without a form-data migration. nvd3-specific pixel-margin and min/max | ||
| // toggles are intentionally dropped; ECharts lays those out automatically. | ||
| const config: ControlPanelConfig = { | ||
| controlPanelSections: [ | ||
| sections.legacyTimeseriesTime, | ||
| { | ||
| label: t('Query'), | ||
| expanded: true, | ||
| controlSetRows: [ | ||
| ['metric'], | ||
| ['adhoc_filters'], | ||
| [ | ||
| { | ||
| name: 'freq', | ||
| config: { | ||
| type: 'SelectControl', | ||
| label: t('Frequency'), | ||
| default: 'W-MON', | ||
| freeForm: true, | ||
| clearable: false, | ||
| choices: [ | ||
| ['AS', t('Year (freq=AS)')], | ||
| ['52W-MON', t('52 weeks starting Monday (freq=52W-MON)')], | ||
| ['W-SUN', t('1 week starting Sunday (freq=W-SUN)')], | ||
| ['W-MON', t('1 week starting Monday (freq=W-MON)')], | ||
| ['D', t('Day (freq=D)')], | ||
| ['4W-MON', t('4 weeks (freq=4W-MON)')], | ||
| ], | ||
| description: t( | ||
| `The periodicity over which to pivot time. Each period becomes | ||
| its own overlaid series, so pick a Time Grain finer than this | ||
| frequency to see lines (e.g. Day grain with a weekly | ||
| frequency); with one data point per period each series renders | ||
| as a single dot. Users can provide "Pandas" offset aliases. | ||
| Click on the info bubble for more details on accepted "freq" | ||
| expressions.`, | ||
| ), | ||
| tooltipOnClick: () => { | ||
| window.open( | ||
| 'https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases', | ||
| '_blank', | ||
| 'noopener noreferrer', | ||
| ); | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| [ | ||
| { | ||
| name: 'period_limit', | ||
| config: { | ||
| type: 'TextControl', | ||
| isInt: true, | ||
| label: t('Number of periods'), | ||
| renderTrigger: true, | ||
| default: '', | ||
| description: t( | ||
| 'Show only the N most recent periods, from 1 up to the number ' + | ||
| 'of periods in the data. Leave empty to overlay them all.', | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| { | ||
| label: t('Chart Options'), | ||
| expanded: true, | ||
| controlSetRows: [ | ||
| [ | ||
| { | ||
| name: 'show_legend', | ||
| config: { | ||
| type: 'CheckboxControl', | ||
| label: t('Legend'), | ||
| renderTrigger: true, | ||
| default: false, | ||
| description: t('Whether to display the legend (toggles)'), | ||
| }, | ||
| }, | ||
| ], | ||
| ['color_picker'], | ||
| [ | ||
| { | ||
| name: 'line_interpolation', | ||
| config: { | ||
| type: 'SelectControl', | ||
| label: t('Line Style'), | ||
| renderTrigger: true, | ||
| choices: [ | ||
| ['linear', t('Linear')], | ||
| ['cardinal', t('Smooth')], | ||
| ['step-before', t('Step - start')], | ||
| ['step-after', t('Step - end')], | ||
| ], | ||
| default: 'linear', | ||
| description: t('Line interpolation as defined by d3.js'), | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| { | ||
| label: t('X Axis'), | ||
| expanded: true, | ||
| controlSetRows: [ | ||
| [ | ||
| { | ||
| name: 'x_axis_label', | ||
| config: { | ||
| type: 'TextControl', | ||
| label: t('X Axis Label'), | ||
| renderTrigger: true, | ||
| default: '', | ||
| }, | ||
| }, | ||
| ], | ||
| [ | ||
| { | ||
| name: 'x_axis_format', | ||
| config: { | ||
| type: 'SelectControl', | ||
| freeForm: true, | ||
| label: t('X Axis Format'), | ||
| renderTrigger: true, | ||
| default: 'smart_date', | ||
| choices: D3_TIME_FORMAT_OPTIONS, | ||
| description: t('D3 time format for the x-axis labels'), | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| { | ||
| label: t('Y Axis'), | ||
| expanded: true, | ||
| controlSetRows: [ | ||
| [ | ||
| { | ||
| name: 'y_axis_label', | ||
| config: { | ||
| type: 'TextControl', | ||
| label: t('Y Axis Label'), | ||
| renderTrigger: true, | ||
| default: '', | ||
| }, | ||
| }, | ||
| ], | ||
| ['y_axis_format'], | ||
| [ | ||
| { | ||
| name: 'y_log_scale', | ||
| config: { | ||
| type: 'CheckboxControl', | ||
| label: t('Y Log Scale'), | ||
| default: false, | ||
| renderTrigger: true, | ||
| description: t('Use a log scale for the Y-axis'), | ||
| }, | ||
| }, | ||
| ], | ||
| [ | ||
| { | ||
| name: 'y_axis_bounds', | ||
| config: { | ||
| type: 'BoundsControl', | ||
| label: t('Y Axis Bounds'), | ||
| renderTrigger: true, | ||
| default: [null, null], | ||
| description: t( | ||
| 'Bounds for the Y-axis. When left empty, the bounds are ' + | ||
| 'dynamically defined based on the min/max of the data. Note that ' + | ||
| "this feature will only expand the axis range. It won't " + | ||
| "narrow the data's extent.", | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export default config; | ||
Binary file added
BIN
+135 KB
...set-frontend/plugins/plugin-chart-echarts/src/TimePivot/images/example-dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+129 KB
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/images/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.7 KB
...t-frontend/plugins/plugin-chart-echarts/src/TimePivot/images/thumbnail-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.9 KB
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/images/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.1 KB
...t-frontend/plugins/plugin-chart-echarts/src/TimePivot/images/thumbnailLarge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions
55
superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| import { t } from '@apache-superset/core/translation'; | ||
| import { Behavior } from '@superset-ui/core'; | ||
| import buildQuery from './buildQuery'; | ||
| import controlPanel from './controlPanel'; | ||
| import transformProps from './transformProps'; | ||
| import thumbnail from './images/thumbnail.png'; | ||
| import thumbnailDark from './images/thumbnail-dark.png'; | ||
| import example from './images/example.jpg'; | ||
| import exampleDark from './images/example-dark.jpg'; | ||
| import { EchartsTimePivotFormData, EchartsTimePivotChartProps } from './types'; | ||
| import { EchartsChartPlugin } from '../types'; | ||
|
|
||
| export default class EchartsTimePivotChartPlugin extends EchartsChartPlugin< | ||
| EchartsTimePivotFormData, | ||
| EchartsTimePivotChartProps | ||
| > { | ||
| constructor() { | ||
| super({ | ||
| buildQuery, | ||
| controlPanel, | ||
| loadChart: () => import('./EchartsTimePivot'), | ||
| metadata: { | ||
| behaviors: [Behavior.InteractiveChart], | ||
| category: t('Evolution'), | ||
| description: t( | ||
| 'Compares the current time period against equivalent past periods by overlaying them on a shared time axis. The current period is drawn boldly while prior periods fade with age.', | ||
| ), | ||
| exampleGallery: [{ url: example, urlDark: exampleDark }], | ||
| name: t('Time-series Period Pivot'), | ||
| tags: [t('Comparison'), t('Time'), t('Trend'), t('ECharts')], | ||
| thumbnail, | ||
| thumbnailDark, | ||
| }, | ||
| transformProps, | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.