Skip to content

Commit

Permalink
remove gradients from defaults
Browse files Browse the repository at this point in the history
restore

deal with incomplete config
  • Loading branch information
thomasneirynck committed Jan 13, 2020
1 parent 4334e9a commit 17d51ac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getDefaultDynamicProperties,
VECTOR_STYLES,
} from '../../styles/vector/vector_style_defaults';
import { COLOR_GRADIENTS } from '../../styles/color_utils';
import { RENDER_AS } from './render_as';
import { CreateSourceEditor } from './create_source_editor';
import { UpdateSourceEditor } from './update_source_editor';
Expand Down Expand Up @@ -255,7 +256,7 @@ export class ESGeoGridSource extends AbstractESAggSource {
name: COUNT_PROP_NAME,
origin: SOURCE_DATA_ID_ORIGIN,
},
color: 'Blues',
color: COLOR_GRADIENTS[0].value,
},
},
[VECTOR_STYLES.LINE_COLOR]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Schemas } from 'ui/vis/editors/default/schemas';
import { AggConfigs } from 'ui/agg_types';
import { AbstractESAggSource } from '../es_agg_source';
import { DynamicStyleProperty } from '../../styles/vector/properties/dynamic_style_property';
import { COLOR_GRADIENTS } from '../../styles/color_utils';

const MAX_GEOTILE_LEVEL = 29;

Expand Down Expand Up @@ -142,7 +143,7 @@ export class ESPewPewSource extends AbstractESAggSource {
name: COUNT_PROP_NAME,
origin: SOURCE_DATA_ID_ORIGIN,
},
color: 'Blues',
color: COLOR_GRADIENTS[0].value,
},
},
[VECTOR_STYLES.LINE_WIDTH]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export function getHexColorRangeStrings(colorRampName, numberColors = GRADIENT_I
}

export function getColorRampCenterColor(colorRampName) {
if (!colorRampName) {
return null;
}
const colorRamp = getColorRamp(colorRampName);
const centerIndex = Math.floor(colorRamp.value.length / 2);
return getColor(colorRamp.value, centerIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function extractColorFromStyleProperty(colorStyleProperty, defaultColor)
: defaultColor;
}

if (!colorStyleProperty.options.color) {
return null;
}

const palette = getColorPalette(colorStyleProperty.options.color);
return palette[0];
} else {
Expand All @@ -46,6 +50,9 @@ export function extractColorFromStyleProperty(colorStyleProperty, defaultColor)
return colorStyleProperty.options.customColorRamp[middleIndex].color;
}

if (!colorStyleProperty.options.color) {
return null;
}
return getColorRampCenterColor(colorStyleProperty.options.color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { VectorStyle } from './vector_style';
import { SYMBOLIZE_AS_CIRCLE, DEFAULT_ICON_SIZE } from './vector_constants';
import { COLOR_GRADIENTS, DEFAULT_FILL_COLORS, DEFAULT_LINE_COLORS } from '../color_utils';
import { DEFAULT_FILL_COLORS, DEFAULT_LINE_COLORS } from '../color_utils';
import chrome from 'ui/chrome';

const DEFAULT_ICON = 'airfield';
Expand Down Expand Up @@ -114,7 +114,7 @@ export function getDefaultDynamicProperties() {
[VECTOR_STYLES.FILL_COLOR]: {
type: VectorStyle.STYLE_TYPE.DYNAMIC,
options: {
color: COLOR_GRADIENTS[0].value,
color: undefined,
field: undefined,
fieldMetaOptions: {
isEnabled: true,
Expand All @@ -125,7 +125,7 @@ export function getDefaultDynamicProperties() {
[VECTOR_STYLES.LINE_COLOR]: {
type: VectorStyle.STYLE_TYPE.DYNAMIC,
options: {
color: COLOR_GRADIENTS[0].value,
color: undefined,
field: undefined,
fieldMetaOptions: {
isEnabled: true,
Expand Down Expand Up @@ -176,7 +176,7 @@ export function getDefaultDynamicProperties() {
[VECTOR_STYLES.LABEL_COLOR]: {
type: VectorStyle.STYLE_TYPE.STATIC,
options: {
color: COLOR_GRADIENTS[0].value,
color: undefined,
field: undefined,
fieldMetaOptions: {
isEnabled: true,
Expand Down

0 comments on commit 17d51ac

Please sign in to comment.