Skip to content

Commit

Permalink
feat(explore): Color scheme groups, new color schemes (apache#27995)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored May 9, 2024
1 parent b224b83 commit bbfe5c0
Show file tree
Hide file tree
Showing 21 changed files with 533 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('Dashboard edit', () => {

it('should apply same color to same labels with color scheme set', () => {
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand All @@ -231,7 +231,7 @@ describe('Dashboard edit', () => {
'[data-test-chart-name="Top 10 California Names Timeseries"] .line .nv-legend-symbol',
)
.first()
.should('have.css', 'fill', 'rgb(51, 61, 71)');
.should('have.css', 'fill', 'rgb(0, 234, 162)');

// open 2nd main tab
openTab(0, 1);
Expand All @@ -240,7 +240,7 @@ describe('Dashboard edit', () => {
// label Anthony
cy.get('[data-test-chart-name="Trends"] .line .nv-legend-symbol')
.eq(2)
.should('have.css', 'fill', 'rgb(51, 61, 71)');
.should('have.css', 'fill', 'rgb(0, 234, 162)');
});

it('should apply same color to same labels with no color scheme set', () => {
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('Dashboard edit', () => {

it.skip('should change color scheme multiple times', () => {
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand Down Expand Up @@ -509,7 +509,7 @@ describe('Dashboard edit', () => {

editDashboard();
openProperties();
selectColorScheme('bnbColors');
selectColorScheme('modernSunset');
applyChanges();
saveChanges();

Expand All @@ -532,7 +532,7 @@ describe('Dashboard edit', () => {

it.skip('should apply the color scheme across main tabs', () => {
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand All @@ -548,7 +548,7 @@ describe('Dashboard edit', () => {
it.skip('should apply the color scheme across main tabs for rendered charts', () => {
waitForChartLoad({ name: 'Treemap', viz: 'treemap_v2' });
openProperties();
selectColorScheme('bnbColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand All @@ -563,7 +563,7 @@ describe('Dashboard edit', () => {
// change scheme now that charts are rendered across the main tabs
editDashboard();
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('modernSunset');
applyChanges();
saveChanges();

Expand All @@ -574,7 +574,7 @@ describe('Dashboard edit', () => {

it.skip('should apply the color scheme in nested tabs', () => {
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand Down Expand Up @@ -609,7 +609,7 @@ describe('Dashboard edit', () => {
// go to previous tab
openTab(1, 0);
openProperties();
selectColorScheme('lyftColors');
selectColorScheme('blueToGreen');
applyChanges();
saveChanges();

Expand Down Expand Up @@ -646,16 +646,16 @@ describe('Dashboard edit', () => {
});

it.skip('should overwrite the color scheme when advanced is closed', () => {
selectColorScheme('d3Category20b');
selectColorScheme('blueToGreen');
openAdvancedProperties();
assertMetadata('d3Category20b');
assertMetadata('blueToGreen');
applyChanges();
});

it.skip('should overwrite the color scheme when advanced is open', () => {
openAdvancedProperties();
selectColorScheme('googleCategory10c');
assertMetadata('googleCategory10c');
selectColorScheme('modernSunset');
assertMetadata('modernSunset');
applyChanges();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
* under the License.
*/

import { ColorSchemeGroup } from './types';

export interface ColorSchemeConfig {
colors: string[];
description?: string;
id: string;
label?: string;
isDefault?: boolean;
group?: ColorSchemeGroup;
}

export default class ColorScheme {
Expand All @@ -36,17 +39,21 @@ export default class ColorScheme {

isDefault?: boolean;

group?: ColorSchemeGroup;

constructor({
colors,
description = '',
id,
label,
isDefault,
group,
}: ColorSchemeConfig) {
this.id = id;
this.label = label ?? id;
this.colors = colors;
this.description = description;
this.isDefault = isDefault;
this.group = group;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import CategoricalScheme from '../../CategoricalScheme';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'bnbColors',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 CategoricalScheme from '../../CategoricalScheme';
import { ColorSchemeGroup } from '../../types';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'blueToGreen',
label: 'Blue to green',
group: ColorSchemeGroup.Featured,
colors: [
'#3200A7',
'#004CDA',
'#0074F1',
'#0096EF',
'#53BFFF',
'#41C8E6',
'#30DEDE',
'#04D9C7',
'#00EAA2',
'#A6FF93',
],
},
].map(s => new CategoricalScheme(s));

export default schemes;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 CategoricalScheme from '../../CategoricalScheme';
import { ColorSchemeGroup } from '../../types';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'colorsOfRainbow',
label: 'Colors of rainbow',
group: ColorSchemeGroup.Featured,
colors: [
'#41ED86',
'#2FC096',
'#01DFFF',
'#153AE0',
'#850AD6',
'#BD59FF',
'#FF4A96',
'#C32668',
'#F40000',
'#FF8901',
'#FFBC0A',
'#FFEC43',
],
},
].map(s => new CategoricalScheme(s));

export default schemes;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import CategoricalScheme from '../../CategoricalScheme';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'd3Category10',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import CategoricalScheme from '../../CategoricalScheme';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'echarts4Colors',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import CategoricalScheme from '../../CategoricalScheme';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'googleCategory10c',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ export { default as CategoricalGoogle } from './google';
export { default as CategoricalLyft } from './lyft';
export { default as CategoricalPreset } from './preset';
export { default as CategoricalSuperset } from './superset';
export { default as CategoricalPresetSuperset } from './presetAndSuperset';
export { default as CategoricalModernSunset } from './modernSunset';
export { default as CategoricalColorsOfRainbow } from './colorsOfRainbow';
export { default as CategoricalBlueToGreen } from './blueToGreen';
export { default as CategoricalRedToYellow } from './redToYellow';
export { default as CategoricalWavesOfBlue } from './wavesOfBlue';
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import CategoricalScheme from '../../CategoricalScheme';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'lyftColors',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 CategoricalScheme from '../../CategoricalScheme';
import { ColorSchemeGroup } from '../../types';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'modernSunset',
label: 'Modern sunset',
group: ColorSchemeGroup.Featured,
colors: [
'#0080F6',
'#254081',
'#6C4592',
'#A94693',
'#DC4180',
'#F35193',
'#FF7582',
'#FF4C5D',
'#FF824E',
'#FFAD2A',
'#FFDB04',
'#F3F700',
],
},
].map(s => new CategoricalScheme(s));

export default schemes;
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
*/

import CategoricalScheme from '../../CategoricalScheme';
import { ColorSchemeGroup } from '../../types';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'presetColors',
label: 'Preset Colors',
group: ColorSchemeGroup.Featured,
colors: [
// Full color
'#6BD3B3',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 CategoricalScheme from '../../CategoricalScheme';
import { ColorSchemeGroup } from '../../types';

// TODO: add the colors to the theme while working on SIP https://github.com/apache/superset/issues/20159
const schemes = [
{
id: 'supersetAndPresetColors',
label: 'Preset + Superset',
group: ColorSchemeGroup.Featured,
colors: [
'#004960',
'#2893B3',
'#20A7C9',
'#5CC0DA',
'#7DCDE1',
'#A9D3E1',
'#C6ECE1',
'#AAE2D2',
'#71CFB4',
'#2FC096',
'#178F7A',
'#067162',
],
},
].map(s => new CategoricalScheme(s));

export default schemes;
Loading

0 comments on commit bbfe5c0

Please sign in to comment.