Skip to content

Commit

Permalink
fix: add advanced analytics to all of timeseries viz (#1308)
Browse files Browse the repository at this point in the history
* feat: add advanced analytics to all of timeseries viz

* fix namespace
  • Loading branch information
zhaoyongjie committed Nov 26, 2021
1 parent 15fbe4a commit 4de4fc3
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 490 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { t, RollingType, ComparisionType } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '../types';
import { formatSelectOptions } from '../utils';

export const advancedAnalytics: ControlPanelSectionConfig = {
export const advancedAnalyticsControls: ControlPanelSectionConfig = {
label: t('Advanced analytics'),
tabOverride: 'data',
description: t(
Expand Down
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 { t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '../types';

export const annotationLayers = [];

export const annotationsAndLayersControls: ControlPanelSectionConfig = {
label: t('Annotations and Layers'),
expanded: false,
controlSetRows: [
[
{
name: 'annotation_layers',
config: {
type: 'AnnotationLayerControl',
label: '',
default: annotationLayers,
description: t('Annotation Layers'),
},
},
],
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* 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 { legacyValidateInteger, legacyValidateNumber, t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from '../types';

export const FORECAST_DEFAULT_DATA = {
forecastEnabled: false,
forecastInterval: 0.8,
forecastPeriods: 10,
forecastSeasonalityDaily: null,
forecastSeasonalityWeekly: null,
forecastSeasonalityYearly: null,
};

export const forecastIntervalControls: ControlPanelSectionConfig = {
label: t('Predictive Analytics'),
expanded: false,
controlSetRows: [
[
{
name: 'forecastEnabled',
config: {
type: 'CheckboxControl',
label: t('Enable forecast'),
renderTrigger: false,
default: FORECAST_DEFAULT_DATA.forecastEnabled,
description: t('Enable forecasting'),
},
},
],
[
{
name: 'forecastPeriods',
config: {
type: 'TextControl',
label: t('Forecast periods'),
validators: [legacyValidateInteger],
default: FORECAST_DEFAULT_DATA.forecastPeriods,
description: t('How many periods into the future do we want to predict'),
},
},
],
[
{
name: 'forecastInterval',
config: {
type: 'TextControl',
label: t('Confidence interval'),
validators: [legacyValidateNumber],
default: FORECAST_DEFAULT_DATA.forecastInterval,
description: t('Width of the confidence interval. Should be between 0 and 1'),
},
},
{
name: 'forecastSeasonalityYearly',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Yearly seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityYearly,
description: t(
'Should yearly seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
],
[
{
name: 'forecastSeasonalityWeekly',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Weekly seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityWeekly,
description: t(
'Should weekly seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
{
name: 'forecastSeasonalityDaily',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Daily seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: FORECAST_DEFAULT_DATA.forecastSeasonalityDaily,
description: t(
'Should daily seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
],
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

export * from './sections';
export * from './advancedAnalytics';
export * from './annotationsAndLayers';
export * from './forecastInterval';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { legacyValidateInteger, legacyValidateNumber, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -35,14 +35,7 @@ import {
import { legendSection, showValueControl } from '../../controls';

const {
annotationLayers,
contributionMode,
forecastEnabled,
forecastInterval,
forecastPeriods,
forecastSeasonalityDaily,
forecastSeasonalityWeekly,
forecastSeasonalityYearly,
logAxis,
markerEnabled,
markerSize,
Expand Down Expand Up @@ -100,118 +93,9 @@ const config: ControlPanelConfig = {
['row_limit'],
],
},
{
label: t('Annotations and Layers'),
expanded: false,
controlSetRows: [
[
{
name: 'annotation_layers',
config: {
type: 'AnnotationLayerControl',
label: '',
default: annotationLayers,
description: t('Annotation Layers'),
},
},
],
],
},
{
label: t('Predictive Analytics'),
expanded: false,
controlSetRows: [
[
{
name: 'forecastEnabled',
config: {
type: 'CheckboxControl',
label: t('Enable forecast'),
renderTrigger: false,
default: forecastEnabled,
description: t('Enable forecasting'),
},
},
],
[
{
name: 'forecastPeriods',
config: {
type: 'TextControl',
label: t('Forecast periods'),
validators: [legacyValidateInteger],
default: forecastPeriods,
description: t('How many periods into the future do we want to predict'),
},
},
],
[
{
name: 'forecastInterval',
config: {
type: 'TextControl',
label: t('Confidence interval'),
validators: [legacyValidateNumber],
default: forecastInterval,
description: t('Width of the confidence interval. Should be between 0 and 1'),
},
},
{
name: 'forecastSeasonalityYearly',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Yearly seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: forecastSeasonalityYearly,
description: t(
'Should yearly seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
],
[
{
name: 'forecastSeasonalityWeekly',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Weekly seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: forecastSeasonalityWeekly,
description: t(
'Should weekly seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
{
name: 'forecastSeasonalityDaily',
config: {
type: 'SelectControl',
freeForm: true,
label: 'Daily seasonality',
choices: [
[null, 'default'],
[true, 'Yes'],
[false, 'No'],
],
default: forecastSeasonalityDaily,
description: t(
'Should daily seasonality be applied. An integer value will specify Fourier order of seasonality.',
),
},
},
],
],
},
sections.advancedAnalyticsControls,
sections.annotationsAndLayersControls,
sections.forecastIntervalControls,
{
label: t('Chart Options'),
expanded: true,
Expand Down

0 comments on commit 4de4fc3

Please sign in to comment.