XYChart: Lift restrictions around re-using fields for color and size (#106690)

This commit is contained in:
Leon Sorokin
2025-07-23 14:55:58 +00:00
committed by GitHub
parent 0483544b06
commit 0f9ea44144
3 changed files with 9 additions and 17 deletions
@@ -256,7 +256,6 @@ export const SeriesEditor = ({
settings: {
// TODO: filter out series.y?.exclude.options, series.size.matcher.options, series.color.matcher.options
filter: (field) =>
field.name !== series.x?.matcher.options &&
(mapping === SeriesMapping.Auto ||
field.state?.origin?.frameIndex === series.frame?.matcher.options) &&
field.type === FieldType.number &&
@@ -292,7 +291,6 @@ export const SeriesEditor = ({
settings: {
// TODO: filter out series.y?.exclude.options, series.size.matcher.options, series.color.matcher.options
filter: (field) =>
field.name !== series.x?.matcher.options &&
(mapping === SeriesMapping.Auto ||
field.state?.origin?.frameIndex === series.frame?.matcher.options) &&
field.type === FieldType.number &&
@@ -63,18 +63,18 @@ export const XYChartTooltip = ({
let label = series.name.value;
let seriesColor = series.color.fixed;
// let colorField = series.color.field;
// let pointColor: string;
let seriesColor = colorField?.display?.(colorField.values[rowIndex]).color ?? series.color.fixed ?? '#fff';
let fillOpacity = colorField?.config.custom?.fillOpacity;
// if (colorField != null) {
// pointColor = colorField.display?.(colorField.values[rowIndex]).color!;
// }
// TODO: skip this if seriesColor already has an alpha component, such as opacity-by-value or opacity gradient schemes
if (fillOpacity != null) {
seriesColor = colorManipulator.alpha(seriesColor, fillOpacity / 100);
}
const headerItem: VizTooltipItem = {
label,
value: '',
color: colorManipulator.alpha(seriesColor ?? '#fff', 0.5),
color: seriesColor,
colorIndicator: ColorIndicator.marker_md,
};
+2 -8
View File
@@ -99,14 +99,8 @@ export function prepSeries(
// only grabbing number fields (exclude time, string, enum, other)
let onlyNumFields = onlyNumTimeFields.filter((field) => field.type === FieldType.number);
let color =
colorMatcher != null
? onlyNumFields.find((field) => field !== x && colorMatcher!(field, frame, frames))
: undefined;
let size =
sizeMatcher != null
? onlyNumFields.find((field) => field !== x && field !== color && sizeMatcher!(field, frame, frames))
: undefined;
let color = colorMatcher != null ? onlyNumFields.find((field) => colorMatcher(field, frame, frames)) : undefined;
let size = sizeMatcher != null ? onlyNumFields.find((field) => sizeMatcher(field, frame, frames)) : undefined;
// x field is required
if (x != null) {