mirror of https://github.com/buster-so/buster.git
Update schema to include color by
This commit is contained in:
parent
85ff4f88de
commit
0fdaa5cbb7
|
@ -1,5 +1,20 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const ColorBySchema = z
|
||||
.object({
|
||||
//will use the values from the column to assign colors to the bars or lines
|
||||
columnId: z.string().nullable().optional(),
|
||||
overrideColorByValue: z
|
||||
.object({
|
||||
//the value and the color to assign to the value
|
||||
value: z.string(),
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
})
|
||||
.nullable()
|
||||
.default(null);
|
||||
|
||||
export const BarAndLineAxisSchema = z
|
||||
.object({
|
||||
// the column ids to use for the x axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this.
|
||||
|
@ -10,12 +25,15 @@ export const BarAndLineAxisSchema = z
|
|||
category: z.array(z.string()).default([]),
|
||||
// if null the y axis will automatically be used, the y axis will be used for the tooltip.
|
||||
tooltip: z.nullable(z.array(z.string())).default(null),
|
||||
//if the user wants to override the color by value
|
||||
colorBy: ColorBySchema,
|
||||
})
|
||||
.default({
|
||||
x: [],
|
||||
y: [],
|
||||
category: [],
|
||||
tooltip: null,
|
||||
colorBy: null,
|
||||
});
|
||||
|
||||
export const ScatterAxisSchema = z
|
||||
|
@ -30,6 +48,8 @@ export const ScatterAxisSchema = z
|
|||
size: z.tuple([z.string()]).or(z.array(z.string()).length(0)).default([]),
|
||||
// if null the y axis will automatically be used, the y axis will be used for the tooltip.
|
||||
tooltip: z.nullable(z.array(z.string())).default(null),
|
||||
//if the user wants to override the color by value
|
||||
colorBy: ColorBySchema,
|
||||
})
|
||||
.default({
|
||||
x: [],
|
||||
|
@ -37,6 +57,7 @@ export const ScatterAxisSchema = z
|
|||
size: [],
|
||||
category: [],
|
||||
tooltip: null,
|
||||
colorBy: null,
|
||||
});
|
||||
|
||||
export const ComboChartAxisSchema = z
|
||||
|
@ -51,6 +72,8 @@ export const ComboChartAxisSchema = z
|
|||
category: z.array(z.string()).default([]),
|
||||
// if null the y axis will automatically be used, the y axis will be used for the tooltip.
|
||||
tooltip: z.nullable(z.array(z.string())).default(null),
|
||||
//if the user wants to override the color by value
|
||||
colorBy: ColorBySchema,
|
||||
})
|
||||
.default({
|
||||
x: [],
|
||||
|
@ -58,6 +81,7 @@ export const ComboChartAxisSchema = z
|
|||
y2: [],
|
||||
category: [],
|
||||
tooltip: null,
|
||||
colorBy: null,
|
||||
});
|
||||
|
||||
export const PieChartAxisSchema = z
|
||||
|
@ -68,11 +92,14 @@ export const PieChartAxisSchema = z
|
|||
y: z.array(z.string()).default([]),
|
||||
// if null the y axis will automatically be used, the y axis will be used for the tooltip.
|
||||
tooltip: z.nullable(z.array(z.string())).default(null),
|
||||
//if the user wants to override the color by value
|
||||
colorBy: ColorBySchema,
|
||||
})
|
||||
.default({
|
||||
x: [],
|
||||
y: [],
|
||||
tooltip: null,
|
||||
colorBy: null,
|
||||
});
|
||||
|
||||
export const ChartEncodesSchema = z.union([
|
||||
|
@ -88,3 +115,4 @@ export type ScatterAxis = z.infer<typeof ScatterAxisSchema>;
|
|||
export type ComboChartAxis = z.infer<typeof ComboChartAxisSchema>;
|
||||
export type PieChartAxis = z.infer<typeof PieChartAxisSchema>;
|
||||
export type ChartEncodes = z.infer<typeof ChartEncodesSchema>;
|
||||
export type ColorBy = z.infer<typeof ColorBySchema>;
|
||||
|
|
Loading…
Reference in New Issue