Skip to content
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

fix(plugin-chart-pivot-table): color weight of Conditional formatting metrics not work #20396

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import memoizeOne from 'memoize-one';
import { DataRecord } from '@superset-ui/core';
import { addAlpha, DataRecord } from '@superset-ui/core';
import {
ColorFormatters,
COMPARATOR,
Expand All @@ -28,9 +28,6 @@ import {
export const round = (num: number, precision = 0) =>
Number(`${Math.round(Number(`${num}e+${precision}`))}e-${precision}`);

export const rgbToRgba = (rgb: string, alpha: number) =>
rgb.replace(/rgb/i, 'rgba').replace(/\)/i, `,${alpha})`);

const MIN_OPACITY_BOUNDED = 0.05;
const MIN_OPACITY_UNBOUNDED = 0;
const MAX_OPACITY = 1;
Expand Down Expand Up @@ -174,7 +171,7 @@ export const getColorFunction = (
const compareResult = comparatorFunction(value, columnValues);
if (compareResult === false) return undefined;
const { cutoffValue, extremeValue } = compareResult;
return rgbToRgba(
return addAlpha(
colorScheme,
getOpacity(value, cutoffValue, extremeValue, minOpacity, maxOpacity),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { configure } from '@superset-ui/core';
import {
COMPARATOR,
getOpacity,
rgbToRgba,
round,
getColorFormatters,
getColorFunction,
Expand Down Expand Up @@ -54,12 +53,6 @@ describe('getOpacity', () => {
});
});

describe('rgba', () => {
it('returns correct rgba value', () => {
expect(rgbToRgba('rgb(255,0,0)', 0.5)).toEqual('rgba(255,0,0,0.5)');
});
});

describe('getColorFunction()', () => {
it('getColorFunction GREATER_THAN', () => {
const colorFunction = getColorFunction(
Expand Down