Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

fix(plugin-chart-echarts): fix tick labels and tooltip #1447

Merged
merged 2 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export default function EchartsMixedTimeseries({
handleChange([seriesName], seriesIndex);
}
},
mousemove: params => {
currentSeries.name = params.seriesName;
},
mouseout: () => {
currentSeries.name = '';
},
mouseover: params => {
currentSeries.name = params.seriesName;
},
villebro marked this conversation as resolved.
Show resolved Hide resolved
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,30 +283,6 @@ const config: ControlPanelConfig = {
...legendSection,
[<h1 className="section-header">{t('X Axis')}</h1>],
['x_axis_time_format'],
[
{
name: 'xAxisShowMinLabel',
config: {
type: 'CheckboxControl',
label: t('Show Min Label'),
default: true,
renderTrigger: true,
description: t('Show Min Label'),
},
},
],
[
{
name: 'xAxisShowMaxLabel',
config: {
type: 'CheckboxControl',
label: t('Show Max Label'),
default: true,
renderTrigger: true,
description: t('Show Max Label'),
},
},
],
[
{
name: 'xAxisLabelRotation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export default function transformProps(
tooltipTimeFormat,
yAxisFormat,
yAxisFormatSecondary,
xAxisShowMinLabel,
xAxisShowMaxLabel,
xAxisTimeFormat,
yAxisBounds,
yAxisIndex,
Expand Down Expand Up @@ -244,8 +242,6 @@ export default function transformProps(
nameGap: xAxisTitleMargin,
nameLocation: 'middle',
axisLabel: {
showMinLabel: xAxisShowMinLabel,
showMaxLabel: xAxisShowMaxLabel,
formatter: xAxisFormatter,
rotate: xAxisLabelRotation,
},
Expand Down Expand Up @@ -282,14 +278,14 @@ export default function transformProps(
appendToBody: true,
trigger: richTooltip ? 'axis' : 'item',
formatter: (params: any) => {
const value: number = !richTooltip ? params.value : params[0].value[0];
const prophetValue: any[] = !richTooltip ? [params] : params;
const xValue: number = richTooltip ? params[0].value[0] : params.value[0];
const prophetValue: any[] = richTooltip ? params : [params];
villebro marked this conversation as resolved.
Show resolved Hide resolved

if (richTooltip && tooltipSortByMetric) {
prophetValue.sort((a, b) => b.data[1] - a.data[1]);
}

const rows: Array<string> = [`${tooltipTimeFormatter(value)}`];
const rows: Array<string> = [`${tooltipTimeFormatter(xValue)}`];
const prophetValues = extractProphetValuesFromTooltipParams(prophetValue);

Object.keys(prophetValues).forEach(key => {
Expand Down
4 changes: 0 additions & 4 deletions plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export type EchartsMixedTimeseriesFormData = QueryFormData & {
zoomable: boolean;
richTooltip: boolean;
xAxisLabelRotation: number;
xAxisShowMinLabel?: boolean;
xAxisShowMaxLabel?: boolean;
colorScheme?: string;
// types specific to Query A and Query B
area: boolean;
Expand Down Expand Up @@ -127,8 +125,6 @@ export const DEFAULT_FORM_DATA: EchartsMixedTimeseriesFormData = {
yAxisIndexB: 0,
groupby: [],
groupbyB: [],
xAxisShowMinLabel: TIMESERIES_DEFAULTS.xAxisShowMinLabel,
xAxisShowMaxLabel: TIMESERIES_DEFAULTS.xAxisShowMaxLabel,
zoomable: TIMESERIES_DEFAULTS.zoomable,
richTooltip: TIMESERIES_DEFAULTS.richTooltip,
xAxisLabelRotation: TIMESERIES_DEFAULTS.xAxisLabelRotation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ export default function transformProps(
appendToBody: true,
trigger: richTooltip ? 'axis' : 'item',
formatter: (params: any) => {
const value: number = !richTooltip ? params.value : params[0].value[0];
const prophetValue: any[] = !richTooltip ? [params] : params;
const xValue: number = richTooltip ? params[0].value[0] : params.value[0];
const prophetValue: any[] = richTooltip ? params : [params];
villebro marked this conversation as resolved.
Show resolved Hide resolved

if (richTooltip && tooltipSortByMetric) {
prophetValue.sort((a, b) => b.data[1] - a.data[1]);
}

const rows: Array<string> = [`${tooltipFormatter(value)}`];
const rows: Array<string> = [`${tooltipFormatter(xValue)}`];
const prophetValues: Record<string, ProphetValue> =
extractProphetValuesFromTooltipParams(prophetValue);

Expand Down
12 changes: 6 additions & 6 deletions plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ export function transformSeries(
step: ['start', 'middle', 'end'].includes(seriesType as string) ? seriesType : undefined,
stack: stackId,
lineStyle,
areaStyle: {
opacity:
forecastSeries.type === ForecastSeriesEnum.ForecastUpper || area
? opacity * areaOpacity
: 0,
},
areaStyle: area
? {
opacity:
forecastSeries.type === ForecastSeriesEnum.ForecastUpper ? opacity * areaOpacity : 0,
}
: undefined,
emphasis,
showSymbol,
symbolSize: markerSize,
Expand Down
2 changes: 0 additions & 2 deletions plugins/plugin-chart-echarts/src/Timeseries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export type EchartsTimeseriesFormData = QueryFormData & {
tooltipTimeFormat?: string;
truncateYAxis: boolean;
yAxisFormat?: string;
xAxisShowMinLabel?: boolean;
xAxisShowMaxLabel?: boolean;
xAxisTimeFormat?: string;
timeGrainSqla?: TimeGranularity;
yAxisBounds: [number | undefined | null, number | undefined | null];
Expand Down