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

feat: add 4.5 contrast for text in partition slices #608

Merged
merged 78 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
02f2f53
feat: move luminance value code from kibana in charts
rshen91 Mar 26, 2020
325b5bd
feat: textColor takes into account contrast with background slice
rshen91 Mar 31, 2020
6acca30
feat: account for initial non black or white textColor
rshen91 Mar 31, 2020
8f4ddf5
feat: add background color knob for xy charts
rshen91 Apr 10, 2020
23eb310
test: fix backgrounds to white for vrt
rshen91 Apr 13, 2020
d4b43ca
fix: add color background functionality to partition chart simple
rshen91 Apr 14, 2020
361200e
docs: add story for partition in styling
rshen91 Apr 14, 2020
963572b
feat: add combine color helper function
rshen91 Apr 15, 2020
01d1e2e
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 15, 2020
c7eec32
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 16, 2020
c36c79a
feat: add background to geometries
rshen91 Apr 20, 2020
fe5be74
fix: improve contrast
rshen91 Apr 20, 2020
cd31813
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 21, 2020
38e1250
fix: add updated story file
rshen91 Apr 21, 2020
69168b6
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 21, 2020
c1bc892
feat: update colorIsDark to adjust text for contrast
rshen91 Apr 21, 2020
7c3c7b0
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 22, 2020
69a2cc0
fix: readd textInvertible functionality in fill_text_layout
rshen91 Apr 22, 2020
7059318
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 22, 2020
f9a824d
WIP
rshen91 Apr 23, 2020
9bc19ba
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 23, 2020
65d8bc8
feat: improve makeHighContrastColor()
rshen91 Apr 23, 2020
71b512e
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 24, 2020
ba1b1cf
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 27, 2020
016cc7d
fix: merge conflicts
rshen91 Apr 27, 2020
9d0d6e7
WIP
rshen91 Apr 27, 2020
c0a56e0
feat: add link label contrast functionality
rshen91 Apr 27, 2020
878635c
chore: merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 28, 2020
94d69ec
test: update contrast logic and vrts
rshen91 Apr 28, 2020
1152d96
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 29, 2020
0688de9
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 29, 2020
e083865
fix: remove broken playground
rshen91 Apr 29, 2020
7ede9a3
fix: add playground from current master
rshen91 Apr 29, 2020
fc86b2a
test: add unit tests for calc file
rshen91 Apr 29, 2020
1fa7fb8
chore: merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Apr 30, 2020
08f1dd7
WIP
rshen91 Apr 30, 2020
a957653
WIP
rshen91 Apr 30, 2020
876062a
merging with master but broken build
rshen91 Apr 30, 2020
9492c23
WIP
rshen91 May 2, 2020
fcc7cfe
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 2, 2020
8035d6c
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 4, 2020
5b3b11f
feat: playground add foreground color functionality
rshen91 May 4, 2020
572cbdd
feat: error handling in conbineColors
rshen91 May 4, 2020
336ae5e
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 4, 2020
c09dfca
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 5, 2020
08768fa
feat: add contrastText prop and opacity in playground
rshen91 May 5, 2020
1800133
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 5, 2020
ee33cfd
fix: fix brightness lightness calc
rshen91 May 5, 2020
4f4801b
chore: merge commit
rshen91 May 8, 2020
7412a60
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 8, 2020
0a24a5e
feat: add textContrast number functionality
rshen91 May 11, 2020
1c04a77
feat: fix contrast with luminance over lightness for colorIsDark
rshen91 May 12, 2020
511b5b4
test: add unit tests and add class to playground
rshen91 May 13, 2020
48ec0fa
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 19, 2020
f8619e2
feat: low hanging fruit
rshen91 May 20, 2020
b411301
feat: add code review changes
rshen91 May 21, 2020
88e42d3
fix: add internal tag to LinkLabelsViewModelSpec
rshen91 May 21, 2020
41314f9
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 26, 2020
8a4c825
fix: cp tmp/charts.api.md to api/chart.api.md
rshen91 May 26, 2020
0946501
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 27, 2020
545e78e
feat: add chart background to own component
rshen91 May 27, 2020
ef78e4b
fix: fix order for <ChartBackground />
rshen91 May 27, 2020
299f90e
fix: add styling fix for legend
rshen91 May 28, 2020
aa48c17
chore: merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 28, 2020
69cd5d8
test: add unit test for combine colors and correct contrast
rshen91 May 28, 2020
462debe
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 May 28, 2020
01b7052
docs: add docs to storybook docs about textContrast
rshen91 May 29, 2020
9bb1e8e
Merge remote-tracking branch 'upstream/master' into luminance-pie
rshen91 Jun 1, 2020
36baf2e
feat: update baseThemes
rshen91 Jun 2, 2020
1864be2
Merge branch 'master' into luminance-pie
nickofthyme Jun 7, 2020
f14f2fa
fix: update pr with remaining checks
nickofthyme Jun 8, 2020
33aeb59
refactor: return types and rgb format
markov00 Jun 8, 2020
979ffe0
fix: get correct theme via selector and minor refactoring
markov00 Jun 8, 2020
af65d11
fix: refactor chart size
markov00 Jun 8, 2020
9012b54
fix: cleanup theme colors and add color check
markov00 Jun 8, 2020
20a11c0
fix: api docs
markov00 Jun 8, 2020
44e5101
Merge branch 'master' into luminance-pie
markov00 Jun 8, 2020
9c91e74
fix: broken tests, update prop naming
nickofthyme Jun 8, 2020
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
2 changes: 1 addition & 1 deletion .playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License. */

import React from 'react';
import { Example } from '../stories/treemap/6_custom_style';
import { Example } from '../stories/stylings/20_partition_background';

export class Playground extends React.Component {
render() {
Expand Down
10 changes: 8 additions & 2 deletions api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export interface AxisStyle {
tickLabelPadding?: number;
}

// @public
export interface BackgroundStyle {
color: string;
}

// Warning: (ae-forgotten-export) The symbol "SpecRequiredProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "SpecOptionalProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "BarSeries" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand Down Expand Up @@ -1403,6 +1408,7 @@ export interface Theme {
areaSeriesStyle: AreaSeriesStyle;
// (undocumented)
axes: AxisConfig;
background: BackgroundStyle;
barSeriesStyle: BarSeriesStyle;
bubbleSeriesStyle: BubbleSeriesStyle;
chartMargins: Margins;
Expand Down Expand Up @@ -1534,8 +1540,8 @@ export interface XYChartSeriesIdentifier extends SeriesIdentifier {

// Warnings were encountered during analysis:
//
// src/chart_types/partition_chart/layout/types/config_types.ts:117:5 - (ae-forgotten-export) The symbol "TimeMs" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:118:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:120:5 - (ae-forgotten-export) The symbol "TimeMs" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:121:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/specs/index.ts:47:13 - (ae-forgotten-export) The symbol "NodeColorAccessor" needs to be exported by the entry point index.d.ts
// src/commons/series_id.ts:37:3 - (ae-forgotten-export) The symbol "SeriesKey" needs to be exported by the entry point index.d.ts

Expand Down
166 changes: 166 additions & 0 deletions docs/0-Intro/1-Overview.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import { Chart, Datum, Partition, PartitionLayout, Settings } from '../../src';
import { mocks } from '../../src/mocks/hierarchical/index';
import { config } from '../../src/chart_types/partition_chart/layout/config/config';
import { ShapeTreeNode } from '../../src/chart_types/partition_chart/layout/types/viewmodel_types';
import {
categoricalFillColor,
colorBrewerCategoricalStark9,
countryLookup,
indexInterpolatedFillColor,
interpolatorCET2s,
interpolatorTurbo,
productLookup,
regionLookup,
} from '../../stories/utils/utils';
import { Meta, Story } from "@storybook/addon-docs/blocks";

<Meta title="Introduction/Elastic Charts Overview" />
Expand Down Expand Up @@ -255,3 +269,155 @@ type PointStyleAccessor = (
```

> Note: When overriding bar or point styles be mindful of performance and these accessor functions will be call on every bar/point is every series. Precomputing any expensive task before rendering.

### Background Colors and Text Contrast
You can provide the `backgroundColor` of the container that the chart will be placed onto. You can set the `textContrast` to a boolean value or a number. The default `textContrast` is set to 4.5 but you can always disable this or set your own numerical amount.

> Note: This functionality is currently available for Partition charts. Please see the partition background and partition label stories.

```js
config: {
fillLabel: {
textInvertible: true,
textContrast: true, // can also be set to a number
}
}
```
`textInvertible` will have to be set to true for `textContrast` to be set as well. To see an example of where this applies, please see the Partitions Background story within Stylings. Charts are included below but are static.
If you have `textInvertible` set to true, but do not have `textContrast` set to true, then the red slices, Europe, North America, and Asia, will have white text:

<Chart className="story-chart">
<Settings theme={{background : {color: `rgba(155, 155, 155, 1)`}}} />
<Partition
id="spec_1"
data={mocks.miniSunburst}
valueAccessor={(d) => d.exportVal}
valueFormatter={(d) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`}
layers={[
{
groupByRollup: (d) => d.sitc1,
nodeLabel: (d) => productLookup[d].name,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex);
},
},
},
{
groupByRollup: (d) => countryLookup[d.dest].continentCountry.substr(0, 2),
nodeLabel: (d) => regionLookup[d].regionName,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex);
},
},
},
{
groupByRollup: (d) => d.dest,
nodeLabel: (d) => countryLookup[d].name,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.3)(d.parent.parent.sortIndex);
},
},
},
]}
config={{
partitionLayout: PartitionLayout.sunburst,
linkLabel: {
maxCount: 0,
fontSize: 14,
},
fontFamily: 'Arial',
fillLabel: {
valueFormatter: (d) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`,
fontStyle: 'italic',
textInvertible: true,
textContrast: false,
fontWeight: 900,
valueFont: {
fontFamily: 'Menlo',
fontStyle: 'normal',
fontWeight: 100,
},
},
margin: { top: 0, bottom: 0, left: 0, right: 0 },
minFontSize: 1,
idealFontSizeJump: 1.1,
outerSizeRatio: 1,
emptySizeRatio: 0,
circlePadding: 4,
backgroundColor: 'rgba(229,229,229,1)',
}}
/>
</Chart>



Now if you set the `textContrast` to true as well, these slices also become black in text color:

<Chart className="story-chart">
<Settings theme={{background : {color: `rgba(155, 155, 155, 1)`}}} />
<Partition
id="spec_1"
data={mocks.miniSunburst}
valueAccessor={(d) => d.exportVal}
valueFormatter={(d) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`}
layers={[
{
groupByRollup: (d) => d.sitc1,
nodeLabel: (d) => productLookup[d].name,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex);
},
},
},
{
groupByRollup: (d) => countryLookup[d.dest].continentCountry.substr(0, 2),
nodeLabel: (d) => regionLookup[d].regionName,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex);
},
},
},
{
groupByRollup: (d) => d.dest,
nodeLabel: (d) => countryLookup[d].name,
shape: {
fillColor: (d) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.3)(d.parent.parent.sortIndex);
},
},
},
]}
config={{
partitionLayout: PartitionLayout.sunburst,
linkLabel: {
maxCount: 0,
fontSize: 14,
},
fontFamily: 'Arial',
fillLabel: {
valueFormatter: (d) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`,
fontStyle: 'italic',
textInvertible: true,
textContrast: true,
fontWeight: 900,
valueFont: {
fontFamily: 'Menlo',
fontStyle: 'normal',
fontWeight: 100,
},
},
margin: { top: 0, bottom: 0, left: 0, right: 0 },
minFontSize: 1,
idealFontSizeJump: 1.1,
outerSizeRatio: 1,
emptySizeRatio: 0,
circlePadding: 4,
backgroundColor: 'rgba(229,229,229,1)',
}}
/>
</Chart>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
"@storybook/react": "5.2.8",
"@storybook/source-loader": "^5.3.9",
"@storybook/theming": "^5.2.8",
"@types/chroma-js": "^2.0.0",
"@types/classnames": "^2.2.7",
"@types/color": "^3.0.1",
"@types/core-js": "^2.5.2",
"@types/d3-array": "^1.2.6",
"@types/d3-collection": "^1.0.8",
Expand Down Expand Up @@ -170,6 +172,7 @@
"webpack-dev-server": "^3.3.1"
},
"dependencies": {
"chroma-js": "^2.1.0",
"@popperjs/core": "^2.4.0",
"classnames": "^2.2.6",
"d3-array": "^1.2.4",
Expand Down
4 changes: 3 additions & 1 deletion src/chart_types/partition_chart/layout/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ export const configMetadata = {
fillLabel: {
type: 'group',
values: {
textColor: { dflt: '#000000', type: 'color' },
textColor: { type: 'color', dflt: '#000000' },
textInvertible: { dflt: false, type: 'boolean' },
textContrast: { dflt: false, type: 'boolean' || 'number' },
...fontSettings,
valueGetter: {
dflt: sumValueGetter,
Expand Down Expand Up @@ -221,6 +222,7 @@ export const configMetadata = {
},
textColor: { dflt: '#000000', type: 'color' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we switch to abbreviated hex code in line 173, should it happen here too? Althogh I'm not sure if it's worth the byte savings; currently it's possible to grep for strings of length 7 starting with # to find hex colors :-) (strings starting with # can also be URLs etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good catch thanks!

textInvertible: { dflt: false, type: 'boolean' },
textContrast: { dflt: false, type: 'boolean' || 'number' },
textOpacity: { dflt: 1, min: 0, max: 1, type: 'number' },
minimumStemLength: {
dflt: 0,
Expand Down
3 changes: 3 additions & 0 deletions src/chart_types/partition_chart/layout/types/config_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export type PerSidePadding = PerSideDistance;

export type Padding = Pixels | Partial<PerSidePadding>;

export type TextContrast = boolean | number;

interface LabelConfig extends Font {
textColor: Color;
textInvertible: boolean;
textContrast: TextContrast;
textOpacity: Ratio;
valueFormatter: ValueFormatter;
valueFont: PartialFont;
Expand Down
2 changes: 2 additions & 0 deletions src/chart_types/partition_chart/layout/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface Font {
fontVariant: FontVariant;
fontWeight: FontWeight;
fontFamily: FontFamily;
textColor: string;
textOpacity: number;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already possible to color the texts, would be glad to catch up on the usefulness of putting it in this type. I'm not against it and it may be the better model, I'm just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed over zoom


export type PartialFont = Partial<Font>;
Expand Down
23 changes: 18 additions & 5 deletions src/chart_types/partition_chart/layout/types/viewmodel_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ import { Font } from './types';
import { config, ValueGetterName } from '../config/config';
import { ArrayNode, HierarchyOfArrays } from '../utils/group_by_rollup';
import { Color } from '../../../../utils/commons';
import { LinkLabelsViewModelSpec } from '../viewmodel/link_text_layout';
import { VerticalAlignments } from '../viewmodel/viewmodel';

/** @internal */
export type LinkLabelVM = {
link: PointTuples;
linkLabels: PointTuples;
translate: PointTuple;
textAlign: CanvasTextAlign;
text: string;
valueText: string;
width: Distance;
valueWidth: Distance;
verticalOffset: Distance;
labelFontSpec: Font;
valueFontSpec: Font;
};

/** @internal */
Expand Down Expand Up @@ -95,19 +94,33 @@ export type ShapeViewModel = {
config: Config;
quadViewModel: QuadViewModel[];
rowSets: RowSet[];
linkLabelViewModels: LinkLabelVM[];
linkLabelViewModels: LinkLabelsViewModelSpec;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call extracting it out!

outsideLinksViewModel: OutsideLinksViewModel[];
diskCenter: PointObject;
pickQuads: PickFunction;
outerRadius: number;
};

const defaultFont: Font = {
fontStyle: 'normal',
fontVariant: 'normal',
fontFamily: '',
fontWeight: 'normal',
textColor: 'black',
textOpacity: 1,
};

/** @internal */
export const nullShapeViewModel = (specifiedConfig?: Config, diskCenter?: PointObject): ShapeViewModel => ({
config: specifiedConfig || config,
quadViewModel: [],
rowSets: [],
linkLabelViewModels: [],
linkLabelViewModels: {
linkLabels: [],
labelFontSpec: defaultFont,
valueFontSpec: defaultFont,
strokeColor: '',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what the goal is behind moving font/color specs from the individual LinkLabelVMs into a newly created upper layer, let's touch on it in a chat unless it's quicker to type in :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed in zoom

outsideLinksViewModel: [],
diskCenter: diskCenter || { x: 0, y: 0 },
pickQuads: () => [],
Expand Down
21 changes: 21 additions & 0 deletions src/chart_types/partition_chart/layout/utils/__mocks__/calcs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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. */
const module = jest.requireActual('../calcs.ts');

export const getBackgroundWithContainerColorFromUser = jest.fn(module.getBackgroundWithContainerColorFromUser);
export const makeHighContrastColor = jest.fn(module.makeHighContrastColor);
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License. */

const module = jest.requireActual('../d3_utils.ts');
const module = jest.requireActual('../color_library_wrappers.ts');

export const defaultColor = module.defaultColor;
export const transparentColor = module.transparentColor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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. */
const module = jest.requireActual('../../viewmodel/fill_text_layout.ts');

export const getTextColorIfTextInvertible = jest.fn(module.getTextColorIfTextInvertible);
Loading