Skip to content

Commit

Permalink
Update dependency @elastic/charts to v34 (#5077)
Browse files Browse the repository at this point in the history
* Update dependency @elastic/charts to v34
* add tickFormatting to xy chart axes
* Updating theme with `goal` settings and cleaning up some docs
* More theme fixes based on text-specific colors and forced a dark mode version of color palette on bullet graph
* Better font stack for both default and Ams themes

Co-authored-by: Renovate Bot
Co-authored-by: nickofthyme
Co-authored-by: cchaos
  • Loading branch information
renovate[bot] committed Aug 25, 2021
1 parent db1f6f4 commit fa14cf4
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
- Updated `EuiToolTip` to remain showing tooltip while child element is in focus ([#5066](https://github.com/elastic/eui/pull/5066))
- Removed `children` from TypeScript definition in `EuiIconTip` ([#5066](https://github.com/elastic/eui/pull/5066))
- Removed `children` as a possible prop on `EuiTreeView` ([#5053](https://github.com/elastic/eui/pull/5053))
- Updated `elast-charts` theme with better text colors, font stack and `goal` styles ([#5077](https://github.com/elastic/eui/pull/5077))

**Bug fixes**

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -101,7 +101,7 @@
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.12.1",
"@elastic/charts": "^33.0.1",
"@elastic/charts": "^34.2.0",
"@elastic/datemath": "^5.0.3",
"@elastic/eslint-config-kibana": "^0.15.0",
"@svgr/core": "5.4.0",
Expand Down
10 changes: 6 additions & 4 deletions renovate.json
@@ -1,12 +1,13 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"extends": ["config:base", ":disableDependencyDashboard"],
"ignorePaths": ["./.github/**"],
"enabledManagers": ["npm"],
"baseBranches": ["master"],
"separateMajorMinor": false,
"rangeStrategy": "bump",
"semanticCommits": "disabled",
"assignAutomerge": true,
"vulnerabilityAlerts": {
"enabled": false
},
Expand All @@ -18,15 +19,16 @@
{
"groupName": "@elastic/charts",
"matchPackageNames": ["@elastic/charts"],
"reviewers": ["team:datavis"],
"labels": ["dependencies"],
"enabled": true
},
{
"matchPackageNames": ["@elastic/charts"],
"matchUpdateTypes": ["major"],
"matchBaseBranches": ["master"],
"automerge": true
"reviewers": ["team:datavis"],
"labels": ["dependencies"],
"automerge": true,
"enabled": true
}
]
}
87 changes: 51 additions & 36 deletions src-docs/src/views/elastic_charts/accessibility_bullet.js
@@ -1,15 +1,38 @@
import React from 'react';
import React, { useContext } from 'react';
import { Chart, Settings, Goal } from '@elastic/charts';
import { EuiSpacer, EuiTitle, EuiPanel } from '../../../../src/components';
import { htmlIdGenerator, euiPalettePositive } from '../../../../src/services';
import { EuiSpacer, EuiTitle } from '../../../../src/components';
import {
htmlIdGenerator,
euiPalettePositive,
colorPalette,
euiPaletteGray,
} from '../../../../src/services';
import { ThemeContext } from '../../components';
import {
EUI_CHARTS_THEME_DARK,
EUI_CHARTS_THEME_LIGHT,
} from '../../../../src/themes/charts/themes';

export const AccessibilityBullet = () => {
const themeContext = useContext(ThemeContext);
const id = htmlIdGenerator()();

/**
* Setup theme based on current light/dark theme
*/
const isDarkTheme = themeContext.theme.includes('dark');
const euiChartTheme = isDarkTheme
? EUI_CHARTS_THEME_DARK
: EUI_CHARTS_THEME_LIGHT;

const bandLabels = ['freezing', 'cold', 'brisk', 'warm', 'hot'];
const bands = [0, 100, 125, 150, 250];

const spectrum = euiPalettePositive(5);
let spectrum = euiPalettePositive(5);
// For dark theme, start with the brightest positive color and create a palette that goes to dark gray instead of light
if (isDarkTheme) {
spectrum = colorPalette([spectrum[4], euiPaletteGray(5)[4]], 5).reverse();
}

const colorMap = {
'0': spectrum[0],
Expand All @@ -25,38 +48,30 @@ export const AccessibilityBullet = () => {
<h3 id={`bullet--example--${id}`}>Example bullet chart</h3>
</EuiTitle>
<EuiSpacer />
<EuiPanel
hasShadow={false}
hasBorder={false}
style={{
backgroundColor: 'aliceblue',
}}
grow={false}
>
<Chart size={{ height: 200 }}>
<Settings
ariaLabelledBy={id}
ariaDescription="This goal chart has a target of 260."
ariaUseDefaultSummary={false}
/>
<Goal
id="spec_1"
subtype="horizontalBullet"
base={0}
target={260}
actual={280}
bands={bands}
ticks={[0, 50, 100, 150, 200, 250, 300]}
tickValueFormatter={({ value }) => String(value)}
bandFillColor={({ value }) => bandFillColor(value)}
labelMajor="Revenue 2020 YTD "
labelMinor="(thousand USD) "
centralMajor="280"
centralMinor="target: 260"
bandLabels={bandLabels}
/>
</Chart>
</EuiPanel>
<Chart size={{ height: 200 }}>
<Settings
theme={euiChartTheme.theme}
ariaLabelledBy={id}
ariaDescription="This goal chart has a target of 260."
ariaUseDefaultSummary={false}
/>
<Goal
id="spec_1"
subtype="horizontalBullet"
base={0}
target={260}
actual={280}
bands={bands}
ticks={[0, 50, 100, 150, 200, 250, 300]}
tickValueFormatter={({ value }) => String(value)}
bandFillColor={({ value }) => bandFillColor(value)}
labelMajor="Revenue 2020 YTD "
labelMinor="(thousand USD) "
centralMajor="280"
centralMinor="target: 260"
bandLabels={bandLabels}
/>
</Chart>
</>
);
};
37 changes: 13 additions & 24 deletions src-docs/src/views/elastic_charts/accessibility_example.js
Expand Up @@ -8,7 +8,7 @@ import {
EuiLink,
} from '../../../../src/components';
import { GuideSectionTypes } from '../../components';
import { ExternalBadge } from './shared';
import { chartsVersion, ExternalBadge } from './shared';
import { TextureMultiSeriesChart } from './texture';
import { TexturedStylesProps } from './texture_props';
import { AccessibilitySunburst } from './accessibility_sunburst';
Expand Down Expand Up @@ -184,15 +184,15 @@ export const ElasticChartsAccessibilityExample = {
<EuiCallOut
title={
<>
Currently, data tables are only available for{' '}
In version {chartsVersion}, data tables are only available for{' '}
<strong>partition charts</strong>.
</>
}
iconType="visPie"
>
<p>
Version <ExternalBadge />, partition charts include: sunburst,
treemap, icicle, flame, and mosaic.
Partition charts include: sunburst, treemap, icicle, flame, and
mosaic.
</p>
</EuiCallOut>
</>
Expand Down Expand Up @@ -269,15 +269,15 @@ export const ElasticChartsAccessibilityExample = {
<EuiCallOut
title={
<>
Currently, texture fills are only available for{' '}
In version {chartsVersion}, texture fills are only available for{' '}
<strong>XY charts</strong>.
</>
}
iconType="visAreaStacked"
>
<p>
At time of this writing, XY charts include: area, bar, bubble,
histogram, line, and heatmap.
XY charts include: area, bar, bubble, histogram, line, and
heatmap.
</p>
</EuiCallOut>
</>
Expand Down Expand Up @@ -319,8 +319,8 @@ export const ElasticChartsAccessibilityExample = {
<EuiCallOut
title={
<>
Currently, semantic groupings are only available for{' '}
<strong>goal and gauge charts</strong>.
In version {chartsVersion}, semantic groupings are only
available for <strong>goal and gauge charts</strong>.
</>
}
iconType="visGoal"
Expand All @@ -346,23 +346,12 @@ export const ElasticChartsAccessibilityExample = {
{
text: (
<>
<EuiCallOut
title={
<>
<ExternalBadge /> does not have configuration options to set the
color of the labels.
</>
}
color="warning"
iconType="alert"
/>
<EuiSpacer />
<p>
For the provided example, a visually hidden content is rendered with
a goal description list generated from the{' '}
For the provided example, visually hidden content is rendered with a
goal description list generated from the{' '}
<EuiCode>bandLabels</EuiCode> prop.
</p>
<EuiCode language="jsx" inline={false}>
<EuiCodeBlock language="jsx">
{`<p>Revenue 2020 YTD</p>
<p>(thousand USD</p>
<p>This goal chart has a target of 260.</p>
Expand All @@ -389,7 +378,7 @@ export const ElasticChartsAccessibilityExample = {
<dt>150 - 250</dt>
<dd>hot</dd>
</dl>`}
</EuiCode>
</EuiCodeBlock>
</>
),
},
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/elastic_charts/shared.js
Expand Up @@ -12,7 +12,7 @@ import {
import { BarSeries, LineSeries, AreaSeries } from '@elastic/charts';
import { devDependencies } from '../../../../package';

const chartsVersion = devDependencies['@elastic/charts'].match(
export const chartsVersion = devDependencies['@elastic/charts'].match(
/\d+\.\d+\.\d+/
)[0];

Expand Down
8 changes: 7 additions & 1 deletion src-docs/src/views/elastic_charts/sizes.js
Expand Up @@ -238,7 +238,12 @@ export class Sizes extends Component {
showGridLines={false}
style={xAxisStyle}
/>
<Axis id="left-axis" position="left" style={yAxisStyle} />
<Axis
id="left-axis"
position="left"
style={yAxisStyle}
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>
</EuiPageContent>
</EuiPage>
Expand Down Expand Up @@ -343,6 +348,7 @@ export class Sizes extends Component {
id="left-axis"
position="left"
style={${JSON.stringify(yAxisStyle)}}
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>`}
>
Expand Down
7 changes: 7 additions & 0 deletions src-docs/src/views/elastic_charts/texture.js
Expand Up @@ -5,6 +5,8 @@ import {
BarSeries,
AreaSeries,
Settings,
Axis,
Position,
} from '@elastic/charts';
import { EuiSpacer, EuiTitle } from '../../../../src/components';
import { SAMPLE_SMALL_DATA, SAMPLE_SMALL_DATA_2 } from './data';
Expand Down Expand Up @@ -67,6 +69,11 @@ export const TextureMultiSeriesChart = () => {
}}
data={SAMPLE_SMALL_DATA_2}
/>
<Axis
hide
position={Position.left}
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>
</Fragment>
);
Expand Down
7 changes: 6 additions & 1 deletion src-docs/src/views/elastic_charts/theming.js
Expand Up @@ -119,7 +119,12 @@ export const Theming = () => {
color={['black']}
/>
<Axis id="bottom-axis" position="bottom" showGridLines />
<Axis id="left-axis" position="left" showGridLines />
<Axis
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>
<EuiSpacer size="xxl" />
<EuiFlexGroup justifyContent="center">
Expand Down
8 changes: 7 additions & 1 deletion src-docs/src/views/elastic_charts/theming_categorical.js
Expand Up @@ -337,7 +337,12 @@ export const Categorical = () => {
position="bottom"
showGridLines={chartType !== 'BarSeries'}
/>
<Axis id="left-axis" position="left" showGridLines />
<Axis
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>
</div>

Expand Down Expand Up @@ -441,6 +446,7 @@ export const Categorical = () => {
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>`}
>
Expand Down
8 changes: 7 additions & 1 deletion src-docs/src/views/elastic_charts/time_chart.js
Expand Up @@ -111,7 +111,12 @@ export const TimeChart = () => {
showGridLines={chartType !== 'BarSeries'}
tickPadding={0}
/>
<Axis id="left-axis" position="left" showGridLines />
<Axis
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>

<EuiSpacer />
Expand Down Expand Up @@ -180,6 +185,7 @@ export const TimeChart = () => {
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>`}
>
Expand Down
Expand Up @@ -252,7 +252,12 @@ const ChartMarkdownRenderer = ({ palette, categories }) => {
stackAccessors={['g']}
/>
<Axis id="bottom-axis" position="bottom" showGridLines />
<Axis id="left-axis" position="left" showGridLines />
<Axis
id="left-axis"
position="left"
showGridLines
tickFormat={(d) => Number(d).toFixed(2)}
/>
</Chart>
);
};
Expand Down

0 comments on commit fa14cf4

Please sign in to comment.