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

Update elastic-charts to v41.0.1 #5492

Merged
merged 10 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 7 additions & 15 deletions src-docs/src/views/elastic_charts/accessibility_sunburst.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 = [
Expand Down Expand Up @@ -50,12 +49,14 @@ export const AccessibilitySunburst = () => {
<EuiSpacer />
<Chart size={{ height: 200 }}>
<Settings
theme={euiChartTheme.theme}
ariaLabelledBy={id}
ariaDescription="There is a great variety of reported favorite fruit"
ariaTableCaption="For the chart representation, after Clementine (22) individual results are not labelled as the segments become too small"
/>
<Partition
data={data}
layout={PartitionLayout.sunburst}
valueAccessor={({ count }) => count}
layers={[
{
Expand All @@ -66,11 +67,7 @@ export const AccessibilitySunburst = () => {
},
},
]}
config={{
...euiPartitionConfig,
clockwiseSectors: false,
partitionLayout: 'sunburst',
}}
clockwiseSectors={false}
/>
</Chart>
</>
Expand All @@ -82,13 +79,15 @@ export const AccessibilitySunburst = () => {
<EuiSpacer />
<Chart size={{ height: 200 }}>
<Settings
theme={euiChartTheme.theme}
ariaLabelledBy={id}
ariaDescription="There is a great variety of reported favorite fruit"
ariaTableCaption="For the chart representation, after Clementine (22) individual results are not labelled as the segments become too small"
/>
<Partition
data={data}
valueAccessor={({ count }) => count}
layout={PartitionLayout.sunburst}
layers={[
{
groupByRollup: ({ fruit }) => fruit,
Expand All @@ -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}
/>
</Chart>
</>
Expand Down
21 changes: 8 additions & 13 deletions src-docs/src/views/elastic_charts/pie.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,7 +27,6 @@ export default () => {
const euiChartTheme = isDarkTheme
? EUI_CHARTS_THEME_DARK
: EUI_CHARTS_THEME_LIGHT;
const euiPartitionConfig = euiChartTheme.partition;

return (
<div>
Expand All @@ -38,7 +37,7 @@ export default () => {
</EuiTitle>
<EuiSpacer />
<Chart size={{ height: 200 }}>
<Settings ariaLabelledBy={exampleOne} />
<Settings theme={euiChartTheme.theme} ariaLabelledBy={exampleOne} />
<Partition
id="pieByPR"
data={[
Expand All @@ -51,6 +50,7 @@ export default () => {
count: 319,
},
]}
layout={PartitionLayout.sunburst}
valueAccessor={(d) => d.count}
layers={[
{
Expand All @@ -61,10 +61,7 @@ export default () => {
},
},
]}
config={{
...euiPartitionConfig,
clockwiseSectors: false,
}}
clockwiseSectors={false}
/>
</Chart>
</EuiFlexItem>
Expand All @@ -74,7 +71,7 @@ export default () => {
</EuiTitle>
<EuiSpacer />
<Chart size={{ height: 200 }}>
<Settings ariaLabelledBy={exampleTwo} />
<Settings theme={euiChartTheme.theme} ariaLabelledBy={exampleTwo} />
<Partition
id="donutByLanguage"
data={[
Expand All @@ -91,6 +88,7 @@ export default () => {
percent: 8.7,
},
]}
layout={PartitionLayout.sunburst}
valueAccessor={(d) => Number(d.percent)}
valueFormatter={() => ''}
layers={[
Expand All @@ -102,11 +100,8 @@ export default () => {
},
},
]}
config={{
...euiPartitionConfig,
emptySizeRatio: 0.4,
clockwiseSectors: false,
}}
emptySizeRatio={0.4}
clockwiseSectors={false}
/>
</Chart>
</EuiFlexItem>
Expand Down
38 changes: 4 additions & 34 deletions src-docs/src/views/elastic_charts/pie_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
EuiLink,
EuiIconTip,
EuiToolTip,
EuiCallOut,
EuiCode,
EuiImage,
} from '../../../../src/components';

Expand Down Expand Up @@ -197,40 +195,15 @@ export const ElasticChartsPieExample = {
/>
.
</p>
<EuiCallOut
color="warning"
title={
<>
Elastic Charts&apos;{' '}
<EuiLink href="https://github.com/elastic/elastic-charts/issues/518">
partition charts do not currently support theming
</EuiLink>{' '}
through the <EuiCode>{'<Settings />'}</EuiCode> component.
</>
}
>
<p>
{' '}
EUI provides a separate key for use with
<EuiCode language="ts">
{'Partition.config={{...EUI_CHARTS_THEME_LIGHT.partition}}'}
</EuiCode>
. The chart colors also need to be passed a different way via{' '}
<EuiCode language="ts">
{'Partition.layers.shape.fillColor'}
</EuiCode>
. See the snippet for full details.
</p>
</EuiCallOut>
</>
),
demo: <PieChart />,
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;

<Chart size={{height: 200}}>
<Chart size={{ height: 200 }}>
<Settings theme={euiChartTheme.theme} />
<Partition
data={[
{
Expand All @@ -248,11 +221,8 @@ const euiPartitionConfig = euiChartTheme.partition;
},
},
]}
config={{
...euiPartitionConfig,
emptySizeRatio: 0.4, // To create a donut chart
clockwiseSectors: false, // For correct slice order
}}
emptySizeRatio={0.4} // To create a donut chart
clockwiseSectors={false} // For correct slice order
/>
</Chart>`,
},
Expand Down
41 changes: 23 additions & 18 deletions src-docs/src/views/elastic_charts/pie_slices.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -71,7 +70,7 @@ export default () => {
clockwiseSectors: false,
});
const [sliceOrderConfigText, setSliceOrderConfigText] = useState(
'clockwiseSectors: false,'
'clockwiseSectors={false}'
);

const [pieTypeIdSelected, setPieTypeIdSelected] = useState(
Expand All @@ -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('');
Expand Down Expand Up @@ -140,15 +139,26 @@ export default () => {
}
};

const themeOverrides = {
partition: {
emptySizeRatio: pieTypeIdSelected.includes('Donut') && 0.4,
},
};

return (
<Fragment>
{customTitle}
<div style={{ position: 'relative' }}>
<Chart size={{ height: 200 }}>
<Settings showLegend={showLegend} showLegendExtra />
<Settings
theme={[themeOverrides, euiChartTheme.theme]}
showLegend={showLegend}
showLegendExtra
/>
<Partition
id="donutByLanguage"
data={pieData()}
layout={PartitionLayout.sunburst}
valueAccessor={(d) => Number(d.percent)}
valueFormatter={showValues ? undefined : () => ''}
valueGetter={showValues ? 'percent' : undefined}
Expand All @@ -161,11 +171,7 @@ export default () => {
},
},
]}
config={{
...euiPartitionConfig,
emptySizeRatio: pieTypeIdSelected.includes('Donut') && 0.4,
...sliceOrderConfig,
}}
{...sliceOrderConfig}
/>
</Chart>
</div>
Expand Down Expand Up @@ -273,8 +279,10 @@ export default () => {
textToCopy={`<EuiTitle size="xxs">
<h4>Distribution of the top ${numSlices} browsers from 2019</h4>
</EuiTitle>
<Chart size={{height: 200}}>
${showLegend ? '<Settings showLegend />' : ''}
<Chart size={{ height: 200 }}>
<Settings${showLegend ? '\nshowLegend' : ''}
theme={[themeOverrides, euiChartTheme.theme]}
/>
<Partition
id={chartID}
data={[
Expand Down Expand Up @@ -303,11 +311,8 @@ export default () => {
},
},
]}
config={{
...euiPartitionConfig,
${pieTypeIdSelected.includes('Donut') ? 'emptySizeRatio: 0.4,' : ''}
${sliceOrderConfigText}
}}
${pieTypeIdSelected.includes('Donut') ? 'emptySizeRatio={0.4}' : ''}
${sliceOrderConfigText}
/>
</Chart>`}
>
Expand Down
Loading