-
Notifications
You must be signed in to change notification settings - Fork 122
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(xy): apply the data value formatter to data values over bars #1419
Changes from 15 commits
06bef45
a9eee2f
a78455b
29eb5eb
2c7bdf5
5287727
9822ee5
8e768d2
3c3a349
89a2fb5
e152fc4
dd4e132
afd4d57
dad8361
9dc836a
d80f9e2
6f69be9
1418a2f
50a4d49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,27 @@ describe('Bar series stories', () => { | |
}); | ||
}); | ||
|
||
describe('value label positioning and formatting', () => { | ||
eachRotation.describe((rotation) => { | ||
describe.each<NonNullable<DisplayValueStyle['alignment']>['vertical']>([ | ||
VerticalAlignment.Middle, | ||
VerticalAlignment.Top, | ||
VerticalAlignment.Bottom, | ||
])('Vertical Alignment - %s', (verticalAlignment) => { | ||
describe.each<NonNullable<DisplayValueStyle['alignment']>['horizontal']>([ | ||
HorizontalAlignment.Left, | ||
HorizontalAlignment.Center, | ||
HorizontalAlignment.Right, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
])('Horizontal Alignment - %s', (horizontalAlignment) => { | ||
const url = `http://localhost:9001/?path=/story/bar-chart--data-value&args=&globals=theme:light&knob-chartRotation=${rotation}&knob-Horizontal alignment=${horizontalAlignment}&knob-Vertical alignment=${verticalAlignment}`; | ||
it('place the value labels on the correct area', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot(url); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('functional accessors', () => { | ||
it('functional accessors with fieldName', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { select } from '@storybook/addon-knobs'; | ||
import React from 'react'; | ||
|
||
import { Axis, BarSeries, Chart, ScaleType, Settings, PartialTheme } from '@elastic/charts'; | ||
|
||
import { BARCHART_1Y0G_LINEAR } from '../../../packages/charts/src/utils/data_samples/test_dataset'; | ||
import { useBaseTheme } from '../../use_base_theme'; | ||
import { getChartRotationKnob } from '../utils/knobs'; | ||
|
||
export const Example = () => { | ||
const theme: PartialTheme = { | ||
barSeriesStyle: { | ||
displayValue: { | ||
fontSize: 10, | ||
fill: 'black', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest making this larger because it blends in. For others that view this story I'd be easier to view the change when the value is more pronounced. |
||
alignment: { | ||
horizontal: select( | ||
'Horizontal alignment', | ||
{ | ||
Default: undefined, | ||
Left: 'left', | ||
Center: 'center', | ||
Right: 'right', | ||
}, | ||
undefined, | ||
), | ||
vertical: select( | ||
'Vertical alignment', | ||
{ | ||
Default: undefined, | ||
Top: 'top', | ||
Middle: 'middle', | ||
Bottom: 'bottom', | ||
}, | ||
undefined, | ||
), | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Chart> | ||
<Settings theme={theme} baseTheme={useBaseTheme()} rotation={getChartRotationKnob()} /> | ||
<BarSeries | ||
id="bars" | ||
data={BARCHART_1Y0G_LINEAR} | ||
yAccessors={['y']} | ||
xScaleType={ScaleType.Linear} | ||
displayValueSettings={{ showValueLabel: true }} | ||
/> | ||
<Axis id="bottom-axis" position="bottom" tickFormat={(d) => `${d} H`} /> | ||
<Axis id="left-axis" position="left" tickFormat={(d) => `${d} V`} /> | ||
</Chart> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, works well and visually is easy to read and check for defects!
I think we can really remove the screenshots and tests that looks similar to this but with a different story (the describe test before this one:
value labels positioning
.I think we can remove it, but keeping the additional test in the describe called
clip both geometry and chart area values
. The reason is the following: that set screenshot is difficult to read, the high decimal values + very thin bars makes it difficult to understand what is the test about (rendering value labels with different configurations)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - updated vrts in 14182f by deleting the old bar_stories vrts and rerunning.