-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
.../plugins/lens/public/xy_visualization/visual_options_popover/fill_opacity_option.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; | ||
import { EuiRange } from '@elastic/eui'; | ||
import { FillOpacityOption } from './fill_opacity_option'; | ||
|
||
describe('Line curve option', () => { | ||
it('should show currently selected opacity value', () => { | ||
const component = shallow(<FillOpacityOption onChange={jest.fn()} value={0.3} />); | ||
|
||
expect(component.find(EuiRange).prop('value')).toEqual(0.3); | ||
}); | ||
|
||
it('should show fill opacity option when enabled', () => { | ||
const component = mount( | ||
<FillOpacityOption onChange={jest.fn()} value={0.3} isFillOpacityEnabled={true} /> | ||
); | ||
|
||
expect(component.exists('[data-test-subj="lnsFillOpacity"]')).toEqual(true); | ||
}); | ||
|
||
it('should hide curve option when disabled', () => { | ||
const component = mount( | ||
<FillOpacityOption onChange={jest.fn()} value={1} isFillOpacityEnabled={false} /> | ||
); | ||
|
||
expect(component.exists('[data-test-subj="lnsFillOpacity"]')).toEqual(false); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/lens/public/xy_visualization/visual_options_popover/fill_opacity_option.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiFormRow, EuiSpacer, EuiRange } from '@elastic/eui'; | ||
|
||
export interface FillOpacityOptionProps { | ||
/** | ||
* Currently selected value | ||
*/ | ||
value: number; | ||
/** | ||
* Callback on display option change | ||
*/ | ||
onChange: (value: number) => void; | ||
isFillOpacityEnabled?: boolean; | ||
} | ||
|
||
export const FillOpacityOption: React.FC<FillOpacityOptionProps> = ({ | ||
onChange, | ||
value, | ||
isFillOpacityEnabled = true, | ||
}) => { | ||
return isFillOpacityEnabled ? ( | ||
<> | ||
<EuiFormRow | ||
display="columnCompressedSwitch" | ||
label={i18n.translate('xpack.lens.xyChart.fillOpacityLabel', { | ||
defaultMessage: 'Fill opacity', | ||
})} | ||
> | ||
<EuiRange | ||
data-test-subj="lnsFillOpacity" | ||
value={value} | ||
min={0.1} | ||
max={1} | ||
step={0.1} | ||
showInput | ||
compressed | ||
onChange={(e) => { | ||
onChange(Number(e.currentTarget.value)); | ||
}} | ||
/> | ||
</EuiFormRow> | ||
<EuiSpacer /> | ||
</> | ||
) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters