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

[Charts] Multi-layer time axis (opt-out only) #115853

Merged
merged 27 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b8e18ec
[Charts] Add setting for using legacy time axis
nickofthyme Oct 20, 2021
0b570f6
Integrate new time axis in discover
markov00 Oct 21, 2021
59a0213
Integrate new time axis into Lens
markov00 Oct 21, 2021
31a2b4a
Integrate new time axis into TSVB
markov00 Oct 21, 2021
8b85467
add time axis flag to timelion
nickofthyme Oct 21, 2021
90440b2
fix(lens): hide/show tick labels
markov00 Oct 25, 2021
2687e5d
Integrate new time axis into visualize
markov00 Oct 25, 2021
8084fbb
remove console log from visualize xy
markov00 Oct 25, 2021
ca66064
temporarly remove multilayer axis in timelion
markov00 Oct 25, 2021
138fdeb
update telemetry schema
markov00 Oct 25, 2021
612a7c5
fix ech v38 breaking changes
markov00 Oct 25, 2021
389531e
update lens snapshot tests
markov00 Oct 25, 2021
0545050
Merge branch 'master' into pr/115853
markov00 Oct 25, 2021
09d9ade
fix wrong tick line on vertical axis
markov00 Oct 26, 2021
e1a2cca
fix TSVB screenshot test
markov00 Oct 26, 2021
274fd5e
Revert "Integrate new time axis in discover"
markov00 Oct 26, 2021
51bbfa3
Integrate multi-layer time axis in Discover
markov00 Oct 26, 2021
65eb9e9
Update elastic-charts to v38.1.0
markov00 Oct 26, 2021
63dea54
Merge branch 'master' into pr/115853
markov00 Oct 26, 2021
6ef7758
fix type errors
nickofthyme Oct 26, 2021
f83b61c
enable legacy time axis by default in test
markov00 Oct 26, 2021
c7eb934
Revert baseline screenshot changes
markov00 Oct 26, 2021
fa247a1
fix timelion test
markov00 Oct 26, 2021
7a216b4
fix settings text
markov00 Oct 26, 2021
6af5d3c
fix another functional test failure
nickofthyme Oct 26, 2021
fe59018
Merge branch 'master' into legacy-time-axis-setting
kibanamachine Oct 27, 2021
2545fd9
Merge branch 'master' into legacy-time-axis-setting
kibanamachine Oct 27, 2021
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
3 changes: 3 additions & 0 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ Enables the legacy charts library for timelion charts in Visualize.
**This setting is deprecated and will not be supported as of 8.0.**
Maps values to specific colors in charts using the *Compatibility* palette.

[[visualization-uselegacytimeaxis]]`visualization:useLegacyTimeAxis`::
Enables the legacy time axis for charts in Lens, Discover, Visualize and TSVB

[[visualization-heatmap-maxbuckets]]`visualization:heatmap:maxBuckets`::
The maximum number of buckets a datasource can return. High numbers can have a negative impact on your browser rendering performance.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/apm-rum": "^5.9.1",
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/charts": "38.0.1",
"@elastic/charts": "38.1.0",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35",
"@elastic/ems-client": "8.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/plugins/charts/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

export const COLOR_MAPPING_SETTING = 'visualization:colorMapping';
export const LEGACY_TIME_AXIS = 'visualization:useLegacyTimeAxis';

export {
CustomPaletteArguments,
Expand Down
17 changes: 16 additions & 1 deletion src/plugins/charts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { CoreSetup, Plugin } from 'kibana/server';
import { COLOR_MAPPING_SETTING, palette, systemPalette } from '../common';
import { COLOR_MAPPING_SETTING, LEGACY_TIME_AXIS, palette, systemPalette } from '../common';
import { ExpressionsServerSetup } from '../../expressions/server';

interface SetupDependencies {
Expand Down Expand Up @@ -45,6 +45,21 @@ export class ChartsServerPlugin implements Plugin<object, object> {
category: ['visualization'],
schema: schema.string(),
},
[LEGACY_TIME_AXIS]: {
name: i18n.translate('charts.advancedSettings.visualization.useLegacyTimeAxis.name', {
defaultMessage: 'Legacy chart time axis',
}),
value: false,
description: i18n.translate(
'charts.advancedSettings.visualization.useLegacyTimeAxis.description',
{
defaultMessage:
'Enables the legacy time axis for charts in Lens, Discover, Visualize and TSVB',
}
),
category: ['visualization'],
schema: schema.boolean(),
},
});

return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export function DiscoverChart({
onResetQuery={resetSavedSearch}
/>
</EuiFlexItem>

{showViewModeToggle && (
<EuiFlexItem grow={false}>
<DocumentViewModeToggle
Expand All @@ -124,7 +123,6 @@ export function DiscoverChart({
/>
</EuiFlexItem>
)}

{timefield && (
<EuiFlexItem className="dscResultCount__toggle" grow={false}>
<EuiPopover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
Settings,
TooltipType,
XYChartElementEvent,
GridLineStyle,
AxisStyle,
RecursivePartial,
} from '@elastic/charts';
import { IUiSettingsClient } from 'kibana/public';
import {
Expand All @@ -35,6 +38,7 @@ import { DataCharts$, DataChartsMessage } from '../../services/use_saved_search'
import { FetchStatus } from '../../../../types';
import { DiscoverServices } from '../../../../../build_services';
import { useDataState } from '../../utils/use_data_state';
import { LEGACY_TIME_AXIS } from '../../../../../../../charts/common';

export interface DiscoverHistogramProps {
savedSearchData$: DataCharts$;
Expand Down Expand Up @@ -179,6 +183,48 @@ export function DiscoverHistogram({

const xAxisFormatter = services.data.fieldFormats.deserialize(chartData.yAxisFormat);

const useLegacyTimeAxis = uiSettings.get(LEGACY_TIME_AXIS, false);
const gridLineStyle: RecursivePartial<GridLineStyle> = useLegacyTimeAxis
? {}
: { strokeWidth: 0.1, stroke: isDarkMode ? 'white' : 'black' };
monfera marked this conversation as resolved.
Show resolved Hide resolved
const verticalAxisStyle: RecursivePartial<AxisStyle> = useLegacyTimeAxis
? {}
: {
axisLine: {
visible: false,
},
tickLabel: {
fontSize: 11,
},
};
const xAxisStyle: RecursivePartial<AxisStyle> = useLegacyTimeAxis
? {}
: {
axisLine: {
stroke: isDarkMode ? 'lightgray' : 'darkgray',
strokeWidth: 1,
},
tickLine: {
size: 12,
strokeWidth: 0.15,
stroke: isDarkMode ? 'white' : 'black',
padding: -10,
visible: true,
},
tickLabel: {
fontSize: 11,
padding: 0,
alignment: {
vertical: Position.Bottom,
horizontal: Position.Left,
},
offset: {
x: 1.5,
y: 0,
},
},
};

return (
<React.Fragment>
<div className="dscHistogram" data-test-subj="discoverChart" data-time-range={timeRangeText}>
Expand All @@ -195,15 +241,19 @@ export function DiscoverHistogram({
<Axis
id="discover-histogram-left-axis"
position={Position.Left}
ticks={5}
ticks={2}
integersOnly
tickFormat={(value) => xAxisFormatter.convert(value)}
gridLine={gridLineStyle}
style={verticalAxisStyle}
/>
<Axis
id="discover-histogram-bottom-axis"
position={Position.Bottom}
tickFormat={formatXValue}
ticks={10}
timeAxisLayerCount={useLegacyTimeAxis ? 0 : 2}
gridLine={gridLineStyle}
style={xAxisStyle}
/>
<CurrentTime isDarkMode={isDarkMode} domainEnd={domainEnd} />
<Endzones
Expand All @@ -222,6 +272,7 @@ export function DiscoverHistogram({
xAccessor="x"
yAccessors={['y']}
data={data}
yNice
timeZone={timeZone}
name={chartData.yAxisLabel}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'text',
_meta: { description: 'Non-default value of setting.' },
},
'visualization:useLegacyTimeAxis': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'visualization:regionmap:showWarnings': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface UsageStats {
'visualize:enableLabs': boolean;
'visualization:heatmap:maxBuckets': number;
'visualization:colorMapping': string;
'visualization:useLegacyTimeAxis': boolean;
'visualization:regionmap:showWarnings': boolean;
'visualization:tileMap:maxPrecision': number;
'csv:separator': string;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7110,6 +7110,12 @@
"description": "Non-default value of setting."
}
},
"visualization:useLegacyTimeAxis": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"visualization:regionmap:showWarnings": {
"type": "boolean",
"_meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { createFieldFormatter } from '../../lib/create_field_formatter';
import { checkIfSeriesHaveSameFormatters } from '../../lib/check_if_series_have_same_formatters';
import { TimeSeries } from '../../../visualizations/views/timeseries';
import { MarkdownSimple } from '../../../../../../../../plugins/kibana_react/public';
import { LEGACY_TIME_AXIS } from '../../../../../../../../plugins/charts/common';
import { replaceVars } from '../../lib/replace_vars';
import { getInterval } from '../../lib/get_interval';
import { createIntervalBasedFormatter } from '../../lib/create_interval_based_formatter';
Expand Down Expand Up @@ -272,6 +273,7 @@ class TimeseriesVisualization extends Component {
syncColors={syncColors}
palettesService={palettesService}
interval={interval}
useLegacyTimeAxis={getConfig(LEGACY_TIME_AXIS, false)}
isLastBucketDropped={Boolean(
model.drop_last_bucket ||
model.series.some((series) => series.series_drop_last_bucket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const TimeSeries = ({
palettesService,
interval,
isLastBucketDropped,
useLegacyTimeAxis,
}) => {
// If the color isn't configured by the user, use the color mapping service
// to assign a color from the Kibana palette. Colors will be shared across the
Expand Down Expand Up @@ -138,6 +139,51 @@ export const TimeSeries = ({
},
[palettesService, series, syncColors]
);

const darkMode = uiSettings.get('theme:darkMode');
const gridLineStyle = !useLegacyTimeAxis
? {
visible: showGrid,
strokeWidth: 0.1,
stroke: darkMode ? 'white' : 'black',
}
: {
...GRID_LINE_CONFIG,
visible: showGrid,
};
const xAxisStyle = !useLegacyTimeAxis
? {
tickLabel: {
visible: true,
fontSize: 11,
padding: 0,
alignment: {
vertical: Position.Bottom,
horizontal: Position.Left,
},
offset: {
x: 1.5,
y: 0,
},
},
axisLine: {
stroke: darkMode ? 'lightgray' : 'darkgray',
strokeWidth: 1,
},
tickLine: {
size: 12,
strokeWidth: 0.15,
stroke: darkMode ? 'white' : 'black',
padding: -10,
visible: true,
},
axisTitle: {
visible: true,
padding: 0,
},
}
: {};
monfera marked this conversation as resolved.
Show resolved Hide resolved

return (
<Chart ref={chartRef} renderer="canvas" className={classes}>
<Settings
Expand Down Expand Up @@ -328,10 +374,9 @@ export const TimeSeries = ({
position={Position.Bottom}
title={getAxisLabelString(interval)}
tickFormat={xAxisFormatter}
gridLine={{
...GRID_LINE_CONFIG,
visible: showGrid,
}}
gridLine={gridLineStyle}
style={xAxisStyle}
timeAxisLayerCount={useLegacyTimeAxis ? 0 : 3}
/>
</Chart>
);
Expand All @@ -357,4 +402,5 @@ TimeSeries.propTypes = {
annotations: PropTypes.array,
interval: PropTypes.number,
isLastBucketDropped: PropTypes.bool,
useLegacyTimeAxis: PropTypes.bool,
};
2 changes: 2 additions & 0 deletions src/plugins/vis_types/xy/public/components/xy_axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const XYAxis: FC<XYAxisPros> = ({
domain,
style,
integersOnly,
timeAxisLayerCount,
}) => (
<Axis
id={`${id}__axis`}
Expand All @@ -40,5 +41,6 @@ export const XYAxis: FC<XYAxisPros> = ({
labelFormat={ticks?.labelFormatter}
showOverlappingLabels={ticks?.showOverlappingLabels}
showDuplicatedTicks={ticks?.showDuplicates}
timeAxisLayerCount={timeAxisLayerCount}
/>
);
Loading