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

refactor: simplify color manipulation code #1372

Merged
merged 60 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
50cd467
use optional chaining
markov00 Sep 10, 2021
37022ad
remove unnecessary multiply by 1 operation
markov00 Sep 10, 2021
6da2bd5
simplify fillTextColor
markov00 Sep 10, 2021
b8007c9
move lightness check within fn
markov00 Sep 10, 2021
d8917a3
refactor getTextColorIfTextInvertible and fix bg color isOpaque check
markov00 Sep 10, 2021
ee4220c
use only numeric contrastRatio to improve readibility
markov00 Sep 10, 2021
484166a
dry code removing getOnPaperColorSet
markov00 Sep 10, 2021
f11dad1
replace isColorValid with a safer alternative
markov00 Sep 10, 2021
09e8d66
refactor fillTextColor
markov00 Sep 10, 2021
823534b
reduce complexity of fillTextColor
markov00 Sep 10, 2021
67dab73
reduce color functions: remove stringToRGB part 1
markov00 Sep 13, 2021
f73d912
remove stringToRGB part 2
markov00 Sep 13, 2021
bbbd4fb
removed unused fillColor on brush
markov00 Sep 13, 2021
ac30089
cleanup remaining RGBtoString
markov00 Sep 13, 2021
a25b276
replace addOpacity with a more robust implementation
markov00 Sep 13, 2021
8f61878
remove unused RGBtoString
markov00 Sep 13, 2021
cf640f8
remove unused hexto tohex
markov00 Sep 13, 2021
81b7432
remove argsTo toArgs and validateColor
markov00 Sep 13, 2021
8c3b038
remove d3-color dep
markov00 Sep 13, 2021
1a7d6ed
removed unused RgbObject
markov00 Sep 13, 2021
b4b0960
prepare fillTextColor to use RGBATuple in makeHighContrastColor
markov00 Sep 13, 2021
0cfe70a
dry hueInterpolator
markov00 Sep 13, 2021
758a303
combineColors with RgbaTuple only
markov00 Sep 13, 2021
a286c81
convert makeHighContrastColor to use RgbaTuple
markov00 Sep 13, 2021
9762e00
fillTextColor correctly use rgbatuples
markov00 Sep 13, 2021
d656c39
fix color calc test
markov00 Sep 13, 2021
5a2c81c
move chromajs related code into color_library_wrappers
markov00 Sep 13, 2021
710ca8d
move colorToRgba into wrappers
markov00 Sep 13, 2021
e728b51
fix wrongly applied opacity on points renderer
markov00 Sep 14, 2021
30c7af2
textInvertible on by default
markov00 Sep 14, 2021
b803d19
remove unused `seriesOpacity` argument from `OpacityFn`
markov00 Sep 14, 2021
55b4c2f
add LRU cache for colors
markov00 Sep 14, 2021
44dd420
remove `textOpacity` prop from configurations
markov00 Sep 14, 2021
8df655b
remove `textInvertible` prop. Maximize contrast by default
markov00 Sep 14, 2021
6504922
remove `textContrast` prop. Always use the default hardcoded value
markov00 Sep 14, 2021
da5b058
refactor fillTextColor to always maximise contrast
markov00 Sep 14, 2021
fe9ceeb
fix opacity for textures
markov00 Sep 14, 2021
9220821
replace makeHighContrastColor code with only black/white text output
markov00 Sep 14, 2021
5d52689
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 Sep 14, 2021
97d5c67
remove unused foreground color in `fillTextColor`
markov00 Sep 15, 2021
84b4884
`fillTextColor` accept only a background and containerBackground
markov00 Sep 15, 2021
950d4c0
fix tests
markov00 Sep 15, 2021
6be4bea
update API report with changes
markov00 Sep 15, 2021
3e7d6cc
update VRT baselines with color contrast changes
markov00 Sep 15, 2021
6311bcd
clear canvas with background color instead of clearRect
markov00 Sep 15, 2021
7d8cecd
update VRTs with latest changes on the background color
markov00 Sep 15, 2021
6764cf4
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 Sep 15, 2021
edcd469
fix color test with APCA contrast results
markov00 Sep 16, 2021
8c484a3
fix lint on apca code
markov00 Sep 16, 2021
2261239
cleanup mocks wrong/unused types
markov00 Sep 16, 2021
53c3ebd
fix ci to ignore canvas package
markov00 Sep 16, 2021
7927211
fix ci and types
markov00 Sep 16, 2021
6e25032
fix vrts without jsdom
markov00 Sep 16, 2021
70f1774
fix missing clearRect on clearCanvas
markov00 Sep 20, 2021
d932a01
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 Sep 20, 2021
878f650
revert to wcag2 color contrast
markov00 Sep 20, 2021
7ca2a0f
revert: use wcag2 color contrast
markov00 Sep 20, 2021
06917ee
add comment on clearCanvas
markov00 Sep 20, 2021
02711a0
fix unit color contrast unit test
markov00 Sep 20, 2021
229c8e8
fix color contrast test with wcag2 result
markov00 Sep 21, 2021
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
1 change: 1 addition & 0 deletions .ci/vrts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
###
source .ci/global_setup.sh


VRTS_FILES=$1
###
### visual testing
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module.exports = {
'no-restricted-properties': 0, // need to find and filter desired options
'class-methods-use-this': 0,
'unicorn/prefer-number-properties': 0,
'unicorn/number-literal-case': 0, // use prettier lower case preference
'global-require': 1,
'import/no-dynamic-require': 1,
'no-shadow': 1,
Expand Down
35 changes: 35 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,38 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

---
This product includes code that is adapted from https://github.com/Myndex/SAPC-APCA
which is available under a "W3C SOFTWARE NOTICE AND LICENSE" license.

Copyright (c) 2021 W3C® (MIT, ERCIM, Keio, Beihang)

License

By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply
with the following terms and conditions.

Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee
or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof,
including modifications:

- The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist,
the W3C Software and Document Short Notice should be included, see
https://www.w3.org/Consortium/Legal/2015/copyright-software-short-notice.html
- Notice of any changes or modifications, through a copyright statement on the new code or document such as
"This software or document includes material copied from or derived from [title and URI of the W3C document].
Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."

Disclaimers
THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.

The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining
to the work without specific, written prior permission. Title to copyright in this work will
at all times remain with copyright holders.
153 changes: 2 additions & 151 deletions docs/0-Intro/1-Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,154 +265,5 @@ 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>
<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 discreteColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex);
},
},
},
{
groupByRollup: (d) => countryLookup[d.dest].continentCountry.substr(0, 2),
nodeLabel: (d) => regionLookup[d].regionName,
shape: {
fillColor: (d) => {
return discreteColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex);
},
},
},
{
groupByRollup: (d) => d.dest,
nodeLabel: (d) => countryLookup[d].name,
shape: {
fillColor: (d) => {
return discreteColor(colorBrewerCategoricalStark9, 0.3)(d[MODEL_KEY].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>
<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 discreteColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex);
},
},
},
{
groupByRollup: (d) => countryLookup[d.dest].continentCountry.substr(0, 2),
nodeLabel: (d) => regionLookup[d].regionName,
shape: {
fillColor: (d) => {
return discreteColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex);
},
},
},
{
groupByRollup: (d) => d.dest,
nodeLabel: (d) => countryLookup[d].name,
shape: {
fillColor: (d) => {
return discreteColor(colorBrewerCategoricalStark9, 0.3)(d[MODEL_KEY].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>
### Background Color
You can provide the `backgroundColor` of the container that the chart will be placed onto.
4 changes: 1 addition & 3 deletions docs/1-Typesofchart/4-Sunburts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
{
groupByRollup: (d) => d.sitc1,
nodeLabel: (d) => productLookup[d].name,
fillLabel: { textInvertible: true },
shape: {
fillColor: indexInterpolatedFillColor(interpolatorCET2s),
},
Expand All @@ -52,7 +51,6 @@ The code sample can be found within the details below.
{
groupByRollup: (d) => d.sitc1,
nodeLabel: (d) => productLookup[d].name,
fillLabel: { textInvertible: true },
shape: {
fillColor: indexInterpolatedFillColor(interpolatorCET2s),
},
Expand All @@ -76,6 +74,6 @@ These props are for the `<Partition/>` component as seen in the code snippet abo
| layers | Array | | |
| groupByRollup| function | | |
| nodeLabel | function | | |
| fillLabel | object { textInvertible : boolean} | | |
| fillLabel | object | | |
| shape | object { fillColor: indexInterpolatedFillColor(interpolatorCET2s) }

2 changes: 0 additions & 2 deletions docs/1-Typesofchart/8-Donut.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
{
groupByRollup: (d) => d.sitc1,
nodeLabel: (d) => productLookup[d].name,
fillLabel: { textInvertible: true },
shape: {
fillColor: indexInterpolatedFillColor(interpolatorCET2s),
},
Expand Down Expand Up @@ -69,7 +68,6 @@ import {
{
groupByRollup: (d: Datum) => d.sitc1,
nodeLabel: (d: Datum) => productLookup[d].name,
fillLabel: { textInvertible: true },
shape: {
fillColor: indexInterpolatedFillColor(interpolatorCET2s),
},
Expand Down
1 change: 0 additions & 1 deletion integration/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const { debug } = require('./config');

module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest_env_setup.ts'],
modulePathIgnorePatterns: ['<rootDir>/node_modules/canvas/.+'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.json',
Expand Down
11 changes: 0 additions & 11 deletions integration/page_objects/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Url from 'url';

import { JSDOM } from 'jsdom';
import { AXNode } from 'puppeteer';

import { DRAG_DETECTION_TIMEOUT } from '../../packages/charts/src/state/reducers/interactions';
Expand Down Expand Up @@ -470,16 +469,6 @@ class CommonPage {
});
return accessibilitySnapshot;
}

/**
* Get HTML for element to test aria labels etc
*/
// eslint-disable-next-line class-methods-use-this
async getSelectorHTML(url: string, tagName: string) {
await this.loadElementFromURL(url, '.echCanvasRenderer');
const xml = await page.evaluate(() => new XMLSerializer().serializeToString(document));
return new JSDOM(xml, { contentType: 'text/xml' }).window.document.getElementsByTagName(tagName);
}
}

export const common = new CommonPage();
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions integration/tests/styles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { common } from '../page_objects/common';
describe('Styles', () => {
it('should hide the value label with 0 borderWidth', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--with-value-label-advanced&knob-show value label=true&knob-alternating value label=&knob-contain value label within bar element=&knob-hide clipped value=&knob-debug=&knob-textInverted=&knob-value color=rgba(0,0,0,1)&knob-value border color=rgba(0,0,0,1)&knob-value border width=0&knob-Fixed font size=10&knob-Use fixed font size=&knob-Max font size=25&knob-Min font size=10&knob-offsetX=0&knob-offsetY=0&knob-data volume size=s&knob-split series=&knob-stacked series=&knob-chartRotation=0',
'http://localhost:9001/?path=/story/bar-chart--with-value-label-advanced&knob-show value label=true&knob-alternating value label=&knob-contain value label within bar element=&knob-hide clipped value=&knob-debug=&knob-useBorder=&knob-value color=rgba(0,0,0,1)&knob-value border color=rgba(0,0,0,1)&knob-value border width=0&knob-Fixed font size=10&knob-Use fixed font size=&knob-Max font size=25&knob-Min font size=10&knob-offsetX=0&knob-offsetY=0&knob-data volume size=s&knob-split series=&knob-stacked series=&knob-chartRotation=0',
);
});
it('should hide the value label with 0 textBorder', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--with-value-label-advanced&knob-show value label=true&knob-alternating value label=&knob-contain value label within bar element=&knob-hide clipped value=&knob-debug=&knob-textInverted=true&knob-value color=rgba(0,0,0,1)&knob-value border color=rgba(0,0,0,1)&knob-value border width=0&knob-Fixed font size=10&knob-Use fixed font size=&knob-Max font size=25&knob-Min font size=10&knob-offsetX=0&knob-offsetY=0&knob-data volume size=s&knob-split series=&knob-stacked series=&knob-chartRotation=0',
'http://localhost:9001/?path=/story/bar-chart--with-value-label-advanced&knob-show value label=true&knob-alternating value label=&knob-contain value label within bar element=&knob-hide clipped value=&knob-debug=&knob-useBorder=true&knob-value color=rgba(0,0,0,1)&knob-value border color=rgba(0,0,0,1)&knob-value border width=0&knob-Fixed font size=10&knob-Use fixed font size=&knob-Max font size=25&knob-Min font size=10&knob-offsetX=0&knob-offsetY=0&knob-data volume size=s&knob-split series=&knob-stacked series=&knob-chartRotation=0',
);
});
});
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"@types/core-js": "^2.5.2",
"@types/d3-array": "^1.2.6",
"@types/d3-collection": "^1.0.8",
"@types/d3-color": "^1.2.2",
"@types/d3-interpolate": "^1.3.1",
"@types/d3-scale": "^2.1.1",
"@types/d3-shape": "^1.3.1",
Expand Down
6 changes: 2 additions & 4 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,6 @@ export type DisplayValueStyle = Omit<TextStyle, 'fill' | 'fontSize'> & {
borderColor?: Color;
borderWidth?: number;
} | {
textInvertible: boolean;
textContrast?: number | boolean;
textBorder?: number;
};
alignment?: {
Expand Down Expand Up @@ -2441,8 +2439,8 @@ export type YDomainRange = YDomainBase & DomainRange & LogScaleOptions;
// src/chart_types/heatmap/layout/types/config_types.ts:19:13 - (ae-forgotten-export) The symbol "SizeRatio" needs to be exported by the entry point index.d.ts
// src/chart_types/heatmap/layout/types/config_types.ts:47:5 - (ae-forgotten-export) The symbol "TextAlign" needs to be exported by the entry point index.d.ts
// src/chart_types/heatmap/layout/types/config_types.ts:48:5 - (ae-forgotten-export) The symbol "TextBaseline" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:139: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:140: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:136: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:137:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
1 change: 0 additions & 1 deletion packages/charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"d3-array": "^1.2.4",
"d3-cloud": "^1.2.5",
"d3-collection": "^1.0.7",
"d3-color": "^1.4.0",
"d3-interpolate": "^1.4.0",
"d3-scale": "^1.0.7",
"d3-shape": "^1.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import chroma from 'chroma-js';

import { getGreensColorScale } from '../../../../common/color_library_wrappers';
import { Pixels, PointObject } from '../../../../common/geometry';
import { SpecType } from '../../../../specs/constants';
import { LIGHT_THEME } from '../../../../utils/themes/light_theme';
Expand Down Expand Up @@ -71,8 +70,7 @@ export const defaultGoalSpec = {
...commonDefaults,
bands: [50, 75, 100],
bandFillColor: ({ value, highestValue, lowestValue }: BandFillColorAccessorInput) => {
const func = chroma.scale(chroma.brewer.Greens).gamma(0.5).domain([highestValue, lowestValue]);
return func(value).css();
return getGreensColorScale(0.5, [highestValue, lowestValue])(value);
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm actually created this as a very specific one just to move chromajs function into a single file. I can create have a more complex/functional fn when actually required

},
tickValueFormatter: ({ value }: BandFillColorAccessorInput) => String(value),
labelMajor: ({ base }: BandFillColorAccessorInput) => String(base),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import { clearCanvas, renderLayers, withContext } from '../../../../renderers/canvas';
import { Color } from '../../../../utils/common';
import { Mark } from '../../layout/viewmodel/geoms';

/** @internal */
export function renderCanvas2d(ctx: CanvasRenderingContext2D, dpr: number, geomObjects: Mark[]) {
export function renderCanvas2d(ctx: CanvasRenderingContext2D, dpr: number, geomObjects: Mark[], background: Color) {
withContext(ctx, () => {
// set some defaults for the overall rendering

Expand All @@ -30,7 +31,7 @@ export function renderCanvas2d(ctx: CanvasRenderingContext2D, dpr: number, geomO

renderLayers(ctx, [
// clear the canvas
clearCanvas,
() => clearCanvas(ctx, background),
() => geomObjects.forEach((mark) => withContext(ctx, () => mark.render(ctx))),
]);
});
Expand Down
Loading