mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -04:00
[Lens] Fix rotating number example (#134234)
* fix rotating number example * fix nav * add label
This commit is contained in:
parent
c1915ea61d
commit
b5583eb5ec
3 changed files with 27 additions and 14 deletions
|
@ -669,6 +669,7 @@ export const App = (props: {
|
|||
value={undefined}
|
||||
onChange={(e) => switchChartPreset(Number(e.target.value))}
|
||||
aria-label="Load from a preset"
|
||||
prepend={'Load preset'}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
|
|
|
@ -91,18 +91,24 @@ export class EmbeddedLensExamplePlugin
|
|||
id: 'third_party_lens_vis_example',
|
||||
title: 'Third party Lens vis example',
|
||||
navLinkStatus: AppNavLinkStatus.hidden,
|
||||
mount: (params) => {
|
||||
mount: ({ history }) => {
|
||||
(async () => {
|
||||
const [, { lens: lensStart, dataViews }] = await core.getStartServices();
|
||||
const defaultDataView = await dataViews.getDefault();
|
||||
lensStart.navigateToPrefilledEditor({
|
||||
id: '',
|
||||
timeRange: {
|
||||
from: 'now-5d',
|
||||
to: 'now',
|
||||
},
|
||||
attributes: getLensAttributes(defaultDataView!),
|
||||
});
|
||||
const [coreStart, { lens: lensStart, dataViews }] = await core.getStartServices();
|
||||
// if it's a regular navigation, redirect to Lens
|
||||
if (history.action === 'PUSH') {
|
||||
const defaultDataView = await dataViews.getDefault();
|
||||
lensStart.navigateToPrefilledEditor({
|
||||
id: '',
|
||||
timeRange: {
|
||||
from: 'now-5d',
|
||||
to: 'now',
|
||||
},
|
||||
attributes: getLensAttributes(defaultDataView!),
|
||||
});
|
||||
} else {
|
||||
// if it's a "back" navigation, go to developer examples
|
||||
coreStart.application.navigateToApp('developerExamples');
|
||||
}
|
||||
})();
|
||||
return () => {};
|
||||
},
|
||||
|
|
|
@ -16,7 +16,10 @@ import { layerTypes } from '@kbn/lens-plugin/public';
|
|||
import type { RotatingNumberState } from '../common/types';
|
||||
import { DEFAULT_COLOR } from '../common/constants';
|
||||
|
||||
const toExpression = (state: RotatingNumberState): Ast | null => {
|
||||
const toExpression = (
|
||||
state: RotatingNumberState,
|
||||
datasourceExpressionsByLayers?: Record<string, Ast>
|
||||
): Ast | null => {
|
||||
if (!state.accessor) {
|
||||
return null;
|
||||
}
|
||||
|
@ -24,6 +27,7 @@ const toExpression = (state: RotatingNumberState): Ast | null => {
|
|||
return {
|
||||
type: 'expression',
|
||||
chain: [
|
||||
...Object.values(datasourceExpressionsByLayers || {})[0].chain,
|
||||
{
|
||||
type: 'function',
|
||||
function: 'rotating_number',
|
||||
|
@ -149,8 +153,10 @@ export const getRotatingNumberVisualization = ({
|
|||
}
|
||||
},
|
||||
|
||||
toExpression: (state) => toExpression(state),
|
||||
toPreviewExpression: (state) => toExpression(state),
|
||||
toExpression: (state, _layers, _attributes, datasourceExpression) =>
|
||||
toExpression(state, datasourceExpression),
|
||||
toPreviewExpression: (state, _layers, datasourceExpression) =>
|
||||
toExpression(state, datasourceExpression),
|
||||
|
||||
setDimension({ prevState, columnId }) {
|
||||
return { ...prevState, accessor: columnId };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue