diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af0bcf0665..5c161b2431b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Fixed a `EuiDataGrid` sizing bug which didn't account for a horizontal scrollbar ([#5478](https://github.com/elastic/eui/pull/5478)) +**Deprecations** + +- Deprecated `PartitionConfig` in favor of inclusion in Charts `theme.partition` ([#5492](https://github.com/elastic/eui/pull/5492)) + ## [`43.1.1`](https://github.com/elastic/eui/tree/v43.1.1) **Bug fixes** diff --git a/package.json b/package.json index f74ad70ba83..e1be475e164 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "@cypress/code-coverage": "^3.9.12", "@cypress/react": "^5.10.3", "@cypress/webpack-dev-server": "^1.7.0", - "@elastic/charts": "^38.1.1", + "@elastic/charts": "^41.0.1", "@elastic/datemath": "^5.0.3", "@elastic/eslint-config-kibana": "^0.15.0", "@emotion/babel-preset-css-prop": "^11.0.0", diff --git a/src-docs/src/views/elastic_charts/accessibility_sunburst.js b/src-docs/src/views/elastic_charts/accessibility_sunburst.js index 1dd87e08847..97c1fbb2796 100644 --- a/src-docs/src/views/elastic_charts/accessibility_sunburst.js +++ b/src-docs/src/views/elastic_charts/accessibility_sunburst.js @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; import { ThemeContext } from '../../components'; -import { Chart, Partition, Settings } from '@elastic/charts'; +import { Chart, Partition, Settings, PartitionLayout } from '@elastic/charts'; import { EUI_CHARTS_THEME_DARK, @@ -20,7 +20,6 @@ export const AccessibilitySunburst = () => { const euiChartTheme = isDarkTheme ? EUI_CHARTS_THEME_DARK : EUI_CHARTS_THEME_LIGHT; - const euiPartitionConfig = euiChartTheme.partition; const { vizColors } = euiChartTheme.theme.colors; const data = [ @@ -50,12 +49,14 @@ export const AccessibilitySunburst = () => { count} layers={[ { @@ -66,11 +67,7 @@ export const AccessibilitySunburst = () => { }, }, ]} - config={{ - ...euiPartitionConfig, - clockwiseSectors: false, - partitionLayout: 'sunburst', - }} + clockwiseSectors={false} /> @@ -82,6 +79,7 @@ export const AccessibilitySunburst = () => { { count} + layout={PartitionLayout.sunburst} layers={[ { groupByRollup: ({ fruit }) => fruit, @@ -98,14 +97,7 @@ export const AccessibilitySunburst = () => { }, }, ]} - config={{ - ...euiPartitionConfig, - ...(isDarkTheme - ? EUI_CHARTS_THEME_DARK.partition - : EUI_CHARTS_THEME_LIGHT.partition), - clockwiseSectors: false, - partitionLayout: 'sunburst', - }} + clockwiseSectors={false} /> diff --git a/src-docs/src/views/elastic_charts/pie.js b/src-docs/src/views/elastic_charts/pie.js index 597c64d12b2..54ebaa133bf 100644 --- a/src-docs/src/views/elastic_charts/pie.js +++ b/src-docs/src/views/elastic_charts/pie.js @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; import { ThemeContext } from '../../components'; -import { Chart, Partition, Settings } from '@elastic/charts'; +import { Chart, Partition, Settings, PartitionLayout } from '@elastic/charts'; import { EUI_CHARTS_THEME_DARK, @@ -27,7 +27,6 @@ export default () => { const euiChartTheme = isDarkTheme ? EUI_CHARTS_THEME_DARK : EUI_CHARTS_THEME_LIGHT; - const euiPartitionConfig = euiChartTheme.partition; return (
@@ -38,7 +37,7 @@ export default () => { - + { count: 319, }, ]} + layout={PartitionLayout.sunburst} valueAccessor={(d) => d.count} layers={[ { @@ -61,10 +61,7 @@ export default () => { }, }, ]} - config={{ - ...euiPartitionConfig, - clockwiseSectors: false, - }} + clockwiseSectors={false} /> @@ -74,7 +71,7 @@ export default () => { - + { percent: 8.7, }, ]} + layout={PartitionLayout.sunburst} valueAccessor={(d) => Number(d.percent)} valueFormatter={() => ''} layers={[ @@ -102,11 +100,8 @@ export default () => { }, }, ]} - config={{ - ...euiPartitionConfig, - emptySizeRatio: 0.4, - clockwiseSectors: false, - }} + emptySizeRatio={0.4} + clockwiseSectors={false} /> diff --git a/src-docs/src/views/elastic_charts/pie_example.js b/src-docs/src/views/elastic_charts/pie_example.js index 2e785cf0424..7b85493a3d0 100644 --- a/src-docs/src/views/elastic_charts/pie_example.js +++ b/src-docs/src/views/elastic_charts/pie_example.js @@ -13,8 +13,6 @@ import { EuiLink, EuiIconTip, EuiToolTip, - EuiCallOut, - EuiCode, EuiImage, } from '../../../../src/components'; @@ -197,40 +195,15 @@ export const ElasticChartsPieExample = { /> .

- - Elastic Charts'{' '} - - partition charts do not currently support theming - {' '} - through the {''} component. - - } - > -

- {' '} - EUI provides a separate key for use with - - {'Partition.config={{...EUI_CHARTS_THEME_LIGHT.partition}}'} - - . The chart colors also need to be passed a different way via{' '} - - {'Partition.layers.shape.fillColor'} - - . See the snippet for full details. -

-
), demo: , snippet: `import { EUI_CHARTS_THEME_DARK, EUI_CHARTS_THEME_LIGHT } from '@elastic/eui/dist/eui_charts_theme'; const euiChartTheme = isDarkTheme ? EUI_CHARTS_THEME_DARK : EUI_CHARTS_THEME_LIGHT; -const euiPartitionConfig = euiChartTheme.partition; - + + `, }, diff --git a/src-docs/src/views/elastic_charts/pie_slices.js b/src-docs/src/views/elastic_charts/pie_slices.js index 805976b118b..77f12bf57af 100644 --- a/src-docs/src/views/elastic_charts/pie_slices.js +++ b/src-docs/src/views/elastic_charts/pie_slices.js @@ -1,6 +1,6 @@ /* eslint-disable no-nested-ternary */ import React, { Fragment, useState, useContext } from 'react'; -import { Chart, Partition, Settings } from '@elastic/charts'; +import { Chart, Partition, Settings, PartitionLayout } from '@elastic/charts'; import { ThemeContext } from '../../components'; import { @@ -34,7 +34,6 @@ export default () => { const euiChartTheme = isDarkTheme ? EUI_CHARTS_THEME_DARK : EUI_CHARTS_THEME_LIGHT; - const euiPartitionConfig = euiChartTheme.partition; const sliceOrderRadiosIdPrefix = 'colorType'; const sliceOrderRadios = [ @@ -71,7 +70,7 @@ export default () => { clockwiseSectors: false, }); const [sliceOrderConfigText, setSliceOrderConfigText] = useState( - 'clockwiseSectors: false,' + 'clockwiseSectors={false}' ); const [pieTypeIdSelected, setPieTypeIdSelected] = useState( @@ -93,10 +92,10 @@ export default () => { .label; if (sliceOrderLabel.includes('Counter')) { setSliceOrderConfig({ clockwiseSectors: false }); - setSliceOrderConfigText('clockwiseSectors: false,'); + setSliceOrderConfigText('clockwiseSectors={false}'); } else if (sliceOrderLabel.includes('Clockwise')) { setSliceOrderConfig({ specialFirstInnermostSector: false }); - setSliceOrderConfigText('specialFirstInnermostSector: false,'); + setSliceOrderConfigText('specialFirstInnermostSector={false}'); } else if (sliceOrderLabel.includes('natural')) { setSliceOrderConfig({}); setSliceOrderConfigText(''); @@ -140,15 +139,26 @@ export default () => { } }; + const themeOverrides = { + partition: { + emptySizeRatio: pieTypeIdSelected.includes('Donut') && 0.4, + }, + }; + return ( {customTitle}
- + Number(d.percent)} valueFormatter={showValues ? undefined : () => ''} valueGetter={showValues ? 'percent' : undefined} @@ -161,11 +171,7 @@ export default () => { }, }, ]} - config={{ - ...euiPartitionConfig, - emptySizeRatio: pieTypeIdSelected.includes('Donut') && 0.4, - ...sliceOrderConfig, - }} + {...sliceOrderConfig} />
@@ -273,8 +279,10 @@ export default () => { textToCopy={`

Distribution of the top ${numSlices} browsers from 2019

- - ${showLegend ? '' : ''} + + { }, }, ]} - config={{ - ...euiPartitionConfig, - ${pieTypeIdSelected.includes('Donut') ? 'emptySizeRatio: 0.4,' : ''} - ${sliceOrderConfigText} - }} + ${pieTypeIdSelected.includes('Donut') ? 'emptySizeRatio={0.4}' : ''} + ${sliceOrderConfigText} /> `} > diff --git a/src-docs/src/views/elastic_charts/treemap.js b/src-docs/src/views/elastic_charts/treemap.js index c7e86d94f79..7319015e218 100644 --- a/src-docs/src/views/elastic_charts/treemap.js +++ b/src-docs/src/views/elastic_charts/treemap.js @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useMemo } from 'react'; import { ThemeContext } from '../../components'; import { Chart, Partition, Settings, PartitionLayout } from '@elastic/charts'; import { GITHUB_DATASET_MOD } from './data'; @@ -32,6 +32,11 @@ export default () => { sortBy: 'natural', }); + const euiChartTheme = useMemo( + () => (isDarkTheme ? EUI_CHARTS_THEME_DARK : EUI_CHARTS_THEME_LIGHT), + [isDarkTheme] + ); + return (
@@ -41,18 +46,21 @@ export default () => { - + d.count} layers={[ { groupByRollup: (d) => d.total, shape: { - fillColor: isDarkTheme - ? EUI_CHARTS_THEME_DARK.partition.sectorLineStroke - : EUI_CHARTS_THEME_LIGHT.partition.sectorLineStroke, + fillColor: euiChartTheme.theme.partition.sectorLineStroke, }, hideInLegend: true, }, @@ -70,27 +78,21 @@ export default () => { }, }, ]} - config={{ - ...(isDarkTheme - ? EUI_CHARTS_THEME_DARK.partition - : EUI_CHARTS_THEME_LIGHT.partition), - clockwiseSectors: false, - fillLabel: { - ...(isDarkTheme - ? EUI_CHARTS_THEME_DARK.partition.fillLabel - : EUI_CHARTS_THEME_LIGHT.partition.fillLabel), - textInvertible: true, - }, - }} + clockwiseSectors={false} /> - + d.count} valueGetter="percent" topGroove={0} @@ -113,12 +115,6 @@ export default () => { }, }, ]} - config={{ - partitionLayout: PartitionLayout.treemap, - ...(isDarkTheme - ? EUI_CHARTS_THEME_DARK.partition - : EUI_CHARTS_THEME_LIGHT.partition), - }} /> diff --git a/src/themes/charts/themes.ts b/src/themes/charts/themes.ts index 220d5372079..ac19da9365d 100644 --- a/src/themes/charts/themes.ts +++ b/src/themes/charts/themes.ts @@ -6,14 +6,15 @@ * Side Public License, v 1. */ -import { euiPaletteColorBlind } from '../../services/color/eui_palettes'; -import { DEFAULT_VISUALIZATION_COLOR } from '../../services/color/visualization_colors'; import { PartialTheme, LineAnnotationStyle, + RecursivePartial, PartitionConfig, } from '@elastic/charts'; -import { RecursivePartial } from '../../components/common'; + +import { euiPaletteColorBlind } from '../../services/color/eui_palettes'; +import { DEFAULT_VISUALIZATION_COLOR } from '../../services/color/visualization_colors'; // @ts-ignore typescript doesn't understand the webpack loader import lightColors from '!!sass-vars-to-js-loader!../../themes/amsterdam/_colors_light.scss'; @@ -26,6 +27,7 @@ const fontFamily = `'Inter', 'Inter UI', -apple-system, BlinkMacSystemFont, export interface EuiChartThemeType { lineAnnotation: LineAnnotationStyle; theme: PartialTheme; + /** DEPRECATED: Use `theme.partition` config instead */ partition: RecursivePartial; } @@ -208,6 +210,25 @@ function createTheme(colors: any): EuiChartThemeType { stroke: colors.euiColorDarkestShade.rgba, }, }, + partition: { + fontFamily: fontFamily, + minFontSize: 8, + maxFontSize: 16, + fillLabel: { + valueFont: { + fontWeight: 700, + }, + }, + linkLabel: { + maxCount: 5, + fontSize: 11, + textColor: colors.euiTextColor.rgba, + }, + outerSizeRatio: 1, + circlePadding: 4, + sectorLineStroke: colors.euiColorEmptyShade.rgba, + sectorLineWidth: 1.5, + }, }, }; } diff --git a/yarn.lock b/yarn.lock index 8a1cd7efafe..251155b0dc8 100755 --- a/yarn.lock +++ b/yarn.lock @@ -1189,10 +1189,10 @@ debug "^3.1.0" lodash.once "^4.1.1" -"@elastic/charts@^38.1.1": - version "38.1.1" - resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-38.1.1.tgz#ca12e9a9e3dbcd28f151e8858326ea722ec7065a" - integrity sha512-c6/pFVTrrY3210rHbEjcKwJGqUCowhW0sm+wZhBzGEMIfcLdzeE8BqhDYmdE2glslN/EWMKCNCZjC7g+yOmZ0g== +"@elastic/charts@^41.0.1": + version "41.0.1" + resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-41.0.1.tgz#28bd722d86366f799668e1e79c36b3977c1a9710" + integrity sha512-oqNcWG6qkJCsSk+DcXWIOgvz7SpfY4AsOG6moTD/i5LnON9mteVsMdRm1Tw4PZV6JWDgGQnSH3gmQhQrb0wONQ== dependencies: "@popperjs/core" "^2.4.0" chroma-js "^2.1.0" @@ -1202,7 +1202,7 @@ d3-collection "^1.0.7" d3-interpolate "^1.4.0" d3-scale "^1.0.7" - d3-shape "^1.3.4" + d3-shape "^2.0.0" luxon "^1.25.0" prop-types "^15.7.2" re-reselect "^3.4.0" @@ -5619,10 +5619,10 @@ d3-interpolate@1, d3-interpolate@^1.4.0: dependencies: d3-color "1" -d3-path@1: - version "1.0.9" - resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-1.0.9.tgz#48c050bb1fe8c262493a8caf5524e3e9591701cf" - integrity sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg== +"d3-path@1 - 2": + version "2.0.0" + resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-2.0.0.tgz#55d86ac131a0548adae241eebfb56b4582dd09d8" + integrity sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA== d3-scale@^1.0.7: version "1.0.7" @@ -5637,12 +5637,12 @@ d3-scale@^1.0.7: d3-time "1" d3-time-format "2" -d3-shape@^1.3.4: - version "1.3.7" - resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-1.3.7.tgz#df63801be07bc986bc54f63789b4fe502992b5d7" - integrity sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw== +d3-shape@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-2.1.0.tgz#3b6a82ccafbc45de55b57fcf956c584ded3b666f" + integrity sha512-PnjUqfM2PpskbSLTJvAzp2Wv4CZsnAgTfcVRTwW03QR3MkXF8Uo7B1y/lWkAsmbKwuecto++4NlsYcvYpXpTHA== dependencies: - d3-path "1" + d3-path "1 - 2" d3-time-format@2: version "2.3.0"