mirror of
https://github.com/apache/superset.git
synced 2026-04-24 18:44:53 +00:00
Allow for multiple color schemes (#3295)
* Allow for multiple color schemes 1. create ColorSchemeControl component 2. using the same new control component for linear colors * add color spectum for linear color scheme * remove dup css * fix controls setting for linear color scheme * minor fix by code review comment
This commit is contained in:
committed by
Maxime Beauchemin
parent
3c8577b853
commit
b9a2fa4015
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { formatSelectOptionsForRange, formatSelectOptions } from '../../modules/utils';
|
||||
import * as v from '../validators';
|
||||
import { ALL_COLOR_SCHEMES, spectrums } from '../../modules/colors';
|
||||
import MetricOption from '../../components/MetricOption';
|
||||
import ColumnOption from '../../components/ColumnOption';
|
||||
|
||||
@@ -155,7 +156,7 @@ export const controls = {
|
||||
},
|
||||
|
||||
linear_color_scheme: {
|
||||
type: 'SelectControl',
|
||||
type: 'ColorSchemeControl',
|
||||
label: 'Linear Color Scheme',
|
||||
choices: [
|
||||
['fire', 'fire'],
|
||||
@@ -165,6 +166,9 @@ export const controls = {
|
||||
],
|
||||
default: 'blue_white_yellow',
|
||||
description: '',
|
||||
renderTrigger: true,
|
||||
schemes: spectrums,
|
||||
isLinear: true,
|
||||
},
|
||||
|
||||
normalize_across: {
|
||||
@@ -1307,5 +1311,15 @@ export const controls = {
|
||||
description: 'Leaf nodes that represent fewer than this number of events will be initially ' +
|
||||
'hidden in the visualization',
|
||||
},
|
||||
|
||||
color_scheme: {
|
||||
type: 'ColorSchemeControl',
|
||||
label: 'Color Scheme',
|
||||
default: 'bnbColors',
|
||||
renderTrigger: true,
|
||||
choices: Object.keys(ALL_COLOR_SCHEMES).map(s => ([s, s])),
|
||||
description: 'The color scheme for rendering chart',
|
||||
schemes: ALL_COLOR_SCHEMES,
|
||||
},
|
||||
};
|
||||
export default controls;
|
||||
|
||||
@@ -18,6 +18,12 @@ export const sections = {
|
||||
['slice_id', 'cache_timeout'],
|
||||
],
|
||||
},
|
||||
colorScheme: {
|
||||
label: 'Color Scheme',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
sqlaTimeSeries: {
|
||||
label: 'Time',
|
||||
description: 'Time related form attributes',
|
||||
@@ -83,6 +89,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
['columns'],
|
||||
@@ -119,6 +126,7 @@ export const visTypes = {
|
||||
['pie_label_type'],
|
||||
['donut', 'show_legend'],
|
||||
['labels_outside'],
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -133,6 +141,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['show_brush', 'show_legend'],
|
||||
['rich_tooltip', null],
|
||||
['show_markers', 'x_axis_showminmax'],
|
||||
@@ -164,6 +173,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['x_axis_format'],
|
||||
],
|
||||
},
|
||||
@@ -204,6 +214,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['show_brush', 'show_legend', 'show_bar_value'],
|
||||
['rich_tooltip', 'contribution'],
|
||||
['line_interpolation', 'bar_stacked'],
|
||||
@@ -237,6 +248,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['x_axis_format', 'y_axis_format'],
|
||||
],
|
||||
},
|
||||
@@ -260,6 +272,7 @@ export const visTypes = {
|
||||
controlSetRows: [
|
||||
['show_brush', 'show_legend'],
|
||||
['line_interpolation', 'stacked_style'],
|
||||
['color_scheme'],
|
||||
['rich_tooltip', 'contribution'],
|
||||
['show_controls', null],
|
||||
],
|
||||
@@ -383,6 +396,7 @@ export const visTypes = {
|
||||
['series', 'metric', 'limit'],
|
||||
['size_from', 'size_to'],
|
||||
['rotation'],
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -401,6 +415,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['treemap_ratio'],
|
||||
['number_format'],
|
||||
],
|
||||
@@ -436,6 +451,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['whisker_options'],
|
||||
],
|
||||
},
|
||||
@@ -455,6 +471,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Chart Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['show_legend', null],
|
||||
],
|
||||
},
|
||||
@@ -553,6 +570,7 @@ export const visTypes = {
|
||||
{
|
||||
label: 'Histogram Options',
|
||||
controlSetRows: [
|
||||
['color_scheme'],
|
||||
['link_length'],
|
||||
],
|
||||
},
|
||||
@@ -579,6 +597,7 @@ export const visTypes = {
|
||||
['groupby'],
|
||||
['metric', 'secondary_metric'],
|
||||
['row_limit'],
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -609,6 +628,7 @@ export const visTypes = {
|
||||
['groupby'],
|
||||
['metric'],
|
||||
['row_limit'],
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -655,6 +675,7 @@ export const visTypes = {
|
||||
['groupby', 'columns'],
|
||||
['metric'],
|
||||
['row_limit', 'y_axis_format'],
|
||||
['color_scheme'],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user