forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugin-chart-period-over-period-kpi): Blank chart when switching …
…from BigNumberTotal (apache#27203) (cherry picked from commit 5403797)
- Loading branch information
1 parent
8cdd357
commit df6cfaa
Showing
17 changed files
with
121 additions
and
290 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes
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
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
...ontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/utils.test.ts
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,39 @@ | ||
/** | ||
* 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 { getComparisonFontSize, getHeaderFontSize } from './utils'; | ||
|
||
test('getHeaderFontSize', () => { | ||
expect(getHeaderFontSize(0.2)).toEqual(16); | ||
expect(getHeaderFontSize(0.3)).toEqual(20); | ||
expect(getHeaderFontSize(0.4)).toEqual(30); | ||
expect(getHeaderFontSize(0.5)).toEqual(48); | ||
expect(getHeaderFontSize(0.6)).toEqual(60); | ||
expect(getHeaderFontSize(0.15)).toEqual(60); | ||
expect(getHeaderFontSize(2)).toEqual(60); | ||
}); | ||
|
||
test('getComparisonFontSize', () => { | ||
expect(getComparisonFontSize(0.125)).toEqual(16); | ||
expect(getComparisonFontSize(0.15)).toEqual(20); | ||
expect(getComparisonFontSize(0.2)).toEqual(26); | ||
expect(getComparisonFontSize(0.3)).toEqual(32); | ||
expect(getComparisonFontSize(0.4)).toEqual(40); | ||
expect(getComparisonFontSize(0.05)).toEqual(40); | ||
expect(getComparisonFontSize(0.9)).toEqual(40); | ||
}); |
59 changes: 59 additions & 0 deletions
59
...et-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/utils.ts
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,59 @@ | ||
/** | ||
* 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 { headerFontSize, subheaderFontSize } from '../sharedControls'; | ||
|
||
const headerFontSizes = [16, 20, 30, 48, 60]; | ||
const comparisonFontSizes = [16, 20, 26, 32, 40]; | ||
|
||
const headerProportionValues = | ||
headerFontSize.config.options.map( | ||
(option: { label: string; value: number }) => option.value, | ||
) ?? []; | ||
|
||
const subheaderProportionValues = | ||
subheaderFontSize.config.options.map( | ||
(option: { label: string; value: number }) => option.value, | ||
) ?? []; | ||
|
||
const getFontSizeMapping = ( | ||
proportionValues: number[], | ||
actualSizes: number[], | ||
) => | ||
proportionValues.reduce((acc, value, index) => { | ||
acc[value] = actualSizes[index] ?? actualSizes[actualSizes.length - 1]; | ||
return acc; | ||
}, {}); | ||
|
||
const headerFontSizesMapping = getFontSizeMapping( | ||
headerProportionValues, | ||
headerFontSizes, | ||
); | ||
|
||
const comparisonFontSizesMapping = getFontSizeMapping( | ||
subheaderProportionValues, | ||
comparisonFontSizes, | ||
); | ||
|
||
export const getHeaderFontSize = (proportionValue: number) => | ||
headerFontSizesMapping[proportionValue] ?? | ||
headerFontSizes[headerFontSizes.length - 1]; | ||
|
||
export const getComparisonFontSize = (proportionValue: number) => | ||
comparisonFontSizesMapping[proportionValue] ?? | ||
comparisonFontSizes[comparisonFontSizes.length - 1]; |
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
87 changes: 0 additions & 87 deletions
87
superset-frontend/plugins/plugin-chart-period-over-period-kpi/README.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.