dosubot[bot] commented on issue #30045:
URL: https://github.com/apache/superset/issues/30045#issuecomment-2320684718
<!-- Answer -->
The `forecastValue` array can be found in the tooltip formatter function
within the `echartOptions` object. Specifically, it is defined as follows:
```ts
const forecastValue: any[] = richTooltip ? params : [params];
```
To implement the `sort_series_ascending` parameter, you can modify the
sorting logic within the tooltip formatter function. Here is an example of how
you can implement it:
1. Add the `sort_series_ascending` parameter to the
`EchartsTimeseriesFormData` type and extract it from `formData`.
2. Modify the sorting logic in the tooltip formatter function to use this
parameter.
Here is the modified code:
```ts
const {
// other parameters
sortSeriesAscending,
} = formData;
const echartOptions: EChartsCoreOption = {
// other options
tooltip: {
// other tooltip options
formatter: (params: any) => {
const xValue: number = richTooltip ? params[0].value[0] :
params.value[0];
const forecastValue: any[] = richTooltip ? params : [params];
if (richTooltip && tooltipSortByMetric) {
forecastValue.sort((a, b) => {
return sortSeriesAscending ? a.data[1] - b.data[1] : b.data[1] -
a.data[1];
});
}
// rest of the formatter logic
},
},
// other options
};
```
Additionally, you can use the utility functions provided in
`superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts` to
handle forecast values more effectively. For example, you can use
`extractForecastValuesFromTooltipParams` to extract forecast values from the
tooltip parameters:
```ts
import { extractForecastValuesFromTooltipParams } from
'superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast';
const echartOptions: EChartsCoreOption = {
// other options
tooltip: {
// other tooltip options
formatter: (params: any) => {
const forecastValues = extractForecastValuesFromTooltipParams(params,
richTooltip);
if (richTooltip && tooltipSortByMetric) {
forecastValues.sort((a, b) => {
return sortSeriesAscending ? a.data[1] - b.data[1] : b.data[1] -
a.data[1];
});
}
// rest of the formatter logic
},
},
// other options
};
```
This code snippet shows how to add the `sortSeriesAscending` parameter and
use it to control the sorting order of the `forecastValue` array in the
tooltip, while also leveraging utility functions for better handling of
forecast values
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]