This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(legacy-plugin-chart-big-number): add control panel config for th…
…e BigNumber charts (#419) * move nvd3 controls file to the correct directory * feat: BigNumber registers its own controls * fix: nvd3 controls imports * fix: disable rules for some lines * controls -> controlPanel * control utils got moved * fix: control utils required from nvd3 * fix: version Co-authored-by: Krist Wongsuphasawat <[email protected]>
- Loading branch information
Showing
8 changed files
with
336 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,174 @@ | ||
/** | ||
* 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/translation'; | ||
import { formatSelectOptions } from '@superset-ui/control-utils'; | ||
import React from 'react'; | ||
import { headerFontSize, subheaderFontSize } from '../sharedControls'; | ||
|
||
type VisibilityProps = { | ||
// eslint-disable-next-line camelcase | ||
form_data: { time_range: string }; | ||
}; | ||
|
||
export default { | ||
controlPanelSections: [ | ||
{ | ||
label: t('Query'), | ||
expanded: true, | ||
controlSetRows: [['metric'], ['adhoc_filters']], | ||
}, | ||
{ | ||
label: t('Options'), | ||
tabOverride: 'data', | ||
expanded: true, | ||
controlSetRows: [ | ||
[ | ||
{ | ||
name: 'compare_lag', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Comparison Period Lag'), | ||
isInt: true, | ||
description: t('Based on granularity, number of time periods to compare against'), | ||
}, | ||
}, | ||
{ | ||
name: 'compare_suffix', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Comparison suffix'), | ||
description: t('Suffix to apply after the percentage display'), | ||
}, | ||
}, | ||
], | ||
['y_axis_format'], | ||
[ | ||
{ | ||
name: 'show_trend_line', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Show Trend Line'), | ||
renderTrigger: true, | ||
default: true, | ||
description: t('Whether to display the trend line'), | ||
}, | ||
}, | ||
{ | ||
name: 'start_y_axis_at_zero', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Start y-axis at 0'), | ||
renderTrigger: true, | ||
default: true, | ||
description: t( | ||
'Start y-axis at zero. Uncheck to start y-axis at minimum value in the data.', | ||
), | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'time_range_fixed', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Fix to selected Time Range'), | ||
description: t( | ||
'Fix the trend line to the full time range specified in case filtered results do not include the start or end dates', | ||
), | ||
renderTrigger: true, | ||
visibility(props: VisibilityProps) { | ||
const { time_range: timeRange } = props.form_data; | ||
// only display this option when a time range is selected | ||
return timeRange && timeRange !== 'No filter'; | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
{ | ||
label: t('Chart Options'), | ||
expanded: true, | ||
controlSetRows: [['color_picker', null], [headerFontSize], [subheaderFontSize]], | ||
}, | ||
{ | ||
label: t('Advanced Analytics'), | ||
expanded: false, | ||
controlSetRows: [ | ||
// eslint-disable-next-line react/jsx-key | ||
[<h1 className="section-header">{t('Rolling Window')}</h1>], | ||
[ | ||
{ | ||
name: 'rolling_type', | ||
config: { | ||
type: 'SelectControl', | ||
label: t('Rolling Function'), | ||
default: 'None', | ||
choices: formatSelectOptions(['None', 'mean', 'sum', 'std', 'cumsum']), | ||
description: t( | ||
'Defines a rolling window function to apply, works along ' + | ||
'with the [Periods] text box', | ||
), | ||
}, | ||
}, | ||
{ | ||
name: 'rolling_periods', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Periods'), | ||
isInt: true, | ||
description: t( | ||
'Defines the size of the rolling window function, ' + | ||
'relative to the time granularity selected', | ||
), | ||
}, | ||
}, | ||
{ | ||
name: 'min_periods', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Min Periods'), | ||
isInt: true, | ||
description: t( | ||
'The minimum number of rolling periods required to show ' + | ||
'a value. For instance if you do a cumulative sum on 7 days ' + | ||
'you may want your "Min Period" to be 7, so that all data points ' + | ||
'shown are the total of 7 periods. This will hide the "ramp up" ' + | ||
'taking place over the first 7 periods', | ||
), | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
], | ||
controlOverrides: { | ||
y_axis_format: { | ||
label: t('Number format'), | ||
}, | ||
}, | ||
sectionOverrides: { | ||
druidTimeSeries: { | ||
controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], | ||
}, | ||
sqlaTimeSeries: { | ||
controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], | ||
}, | ||
}, | ||
}; |
This file contains 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
This file contains 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,57 @@ | ||
/** | ||
* 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/translation'; | ||
import { headerFontSize, subheaderFontSize } from '../sharedControls'; | ||
|
||
export default { | ||
controlPanelSections: [ | ||
{ | ||
label: t('Query'), | ||
expanded: true, | ||
controlSetRows: [['metric'], ['adhoc_filters']], | ||
}, | ||
{ | ||
label: t('Options'), | ||
expanded: true, | ||
controlSetRows: [ | ||
[ | ||
{ | ||
name: 'subheader', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Subheader'), | ||
description: t('Description text that shows up below your Big Number'), | ||
}, | ||
}, | ||
], | ||
['y_axis_format'], | ||
], | ||
}, | ||
{ | ||
label: t('Chart Options'), | ||
expanded: true, | ||
controlSetRows: [[headerFontSize], [subheaderFontSize]], | ||
}, | ||
], | ||
controlOverrides: { | ||
y_axis_format: { | ||
label: t('Number format'), | ||
}, | ||
}, | ||
}; |
This file contains 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
This file contains 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,89 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
// These are control configurations that are shared ONLY within the BigNumber viz plugin repo. | ||
import { t } from '@superset-ui/translation'; | ||
|
||
export const headerFontSize = { | ||
name: 'header_font_size', | ||
config: { | ||
type: 'SelectControl', | ||
label: t('Big Number Font Size'), | ||
renderTrigger: true, | ||
clearable: false, | ||
default: 0.4, | ||
// Values represent the percentage of space a header should take | ||
options: [ | ||
{ | ||
label: t('Tiny'), | ||
value: 0.2, | ||
}, | ||
{ | ||
label: t('Small'), | ||
value: 0.3, | ||
}, | ||
{ | ||
label: t('Normal'), | ||
value: 0.4, | ||
}, | ||
{ | ||
label: t('Large'), | ||
value: 0.5, | ||
}, | ||
{ | ||
label: t('Huge'), | ||
value: 0.6, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const subheaderFontSize = { | ||
name: 'subheader_font_size', | ||
config: { | ||
type: 'SelectControl', | ||
label: t('Subheader Font Size'), | ||
renderTrigger: true, | ||
clearable: false, | ||
default: 0.15, | ||
// Values represent the percentage of space a subheader should take | ||
options: [ | ||
{ | ||
label: t('Tiny'), | ||
value: 0.125, | ||
}, | ||
{ | ||
label: t('Small'), | ||
value: 0.15, | ||
}, | ||
{ | ||
label: t('Normal'), | ||
value: 0.2, | ||
}, | ||
{ | ||
label: t('Large'), | ||
value: 0.3, | ||
}, | ||
{ | ||
label: t('Huge'), | ||
value: 0.4, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains 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
Oops, something went wrong.