@blokkli/editor 2.0.0-alpha.35 → 2.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/global/types/blockOptions.d.ts +9 -2
- package/dist/global/types/definitions.d.ts +12 -5
- package/dist/module.d.mts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +56 -4
- package/dist/modules/agent/index.d.mts +1 -1
- package/dist/modules/agent/index.mjs +38 -20
- package/dist/modules/agent/runtime/app/composables/agentProvider.d.ts +2 -2
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +3 -3
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +34 -60
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.d.vue.ts +8 -0
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue +138 -0
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue.d.ts +8 -0
- package/dist/modules/agent/runtime/app/features/agent/index.vue +5 -1
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +175 -0
- package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +5 -0
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +10 -1
- package/dist/modules/agent/runtime/app/tools/schemas.js +36 -23
- package/dist/modules/agent/runtime/server/Session.d.ts +4 -2
- package/dist/modules/agent/runtime/server/Session.js +61 -57
- package/dist/modules/agent/runtime/server/agentPrompt.d.ts +9 -1
- package/dist/modules/agent/runtime/server/agentPrompt.js +26 -0
- package/dist/modules/agent/runtime/shared/types.d.ts +35 -1
- package/dist/modules/charts/index.d.mts +35 -0
- package/dist/modules/charts/index.mjs +43 -0
- package/dist/modules/charts/runtime/blokkli/skills/charts.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/skills/charts.js +42 -0
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +63 -0
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +98 -0
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +86 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +74 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +42 -0
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +101 -0
- package/dist/modules/charts/runtime/chartTypes/area.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/area.js +68 -0
- package/dist/modules/charts/runtime/chartTypes/bar.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/bar.js +76 -0
- package/dist/modules/charts/runtime/chartTypes/define.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/define.js +3 -0
- package/dist/modules/charts/runtime/chartTypes/donut.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/donut.js +45 -0
- package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/heatmap.js +54 -0
- package/dist/modules/charts/runtime/chartTypes/index.d.ts +21 -0
- package/dist/modules/charts/runtime/chartTypes/index.js +47 -0
- package/dist/modules/charts/runtime/chartTypes/line.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/line.js +68 -0
- package/dist/modules/charts/runtime/chartTypes/pie.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/pie.js +28 -0
- package/dist/modules/charts/runtime/chartTypes/radar.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/radar.js +52 -0
- package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/radialBar.js +44 -0
- package/dist/modules/charts/runtime/chartTypes/shared.d.ts +52 -0
- package/dist/modules/charts/runtime/chartTypes/shared.js +103 -0
- package/dist/modules/charts/runtime/chartTypes/types.d.ts +29 -0
- package/dist/modules/charts/runtime/chartTypes/types.js +0 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +4 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +120 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +4 -0
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.d.vue.ts +3 -0
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue +29 -0
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue.d.ts +3 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +15 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue +97 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +15 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.d.vue.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue +34 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue.d.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.d.vue.ts +12 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue +49 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue.d.ts +12 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.d.vue.ts +19 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +90 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue.d.ts +19 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.d.vue.ts +23 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue +224 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue.d.ts +23 -0
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.d.vue.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +61 -0
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue.d.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +8 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +23 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +8 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue +243 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.d.ts +17 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +90 -0
- package/dist/modules/charts/runtime/features/charts/index.d.vue.ts +3 -0
- package/dist/modules/charts/runtime/features/charts/index.vue +72 -0
- package/dist/modules/charts/runtime/features/charts/index.vue.d.ts +3 -0
- package/dist/modules/charts/runtime/helpers/index.d.ts +1 -0
- package/dist/modules/charts/runtime/helpers/index.js +17 -0
- package/dist/modules/charts/runtime/types.d.ts +51 -0
- package/dist/modules/charts/runtime/types.js +64 -0
- package/dist/modules/drupal/graphql/features/fragments.graphql +2 -0
- package/dist/modules/drupal/index.d.mts +1 -1
- package/dist/modules/drupal/runtime/adapter/index.js +12 -8
- package/dist/modules/table-of-contents/index.d.mts +11 -0
- package/dist/modules/table-of-contents/index.mjs +24 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.d.vue.ts +44 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue +43 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue.d.ts +44 -0
- package/dist/modules/table-of-contents/runtime/types/index.d.ts +4 -0
- package/dist/modules/table-of-contents/runtime/types/index.js +0 -0
- package/dist/runtime/components/Blocks/Fragment/index.vue +6 -2
- package/dist/runtime/components/BlokkliItem.vue +8 -3
- package/dist/runtime/components/BlokkliProvider.d.vue.ts +7 -0
- package/dist/runtime/components/BlokkliProvider.vue +7 -1
- package/dist/runtime/components/BlokkliProvider.vue.d.ts +7 -0
- package/dist/runtime/composables/useBlokkliHelper.js +4 -2
- package/dist/runtime/editor/components/AnimationCanvas/index.vue +4 -20
- package/dist/runtime/editor/components/Banner/index.d.vue.ts +12 -2
- package/dist/runtime/editor/components/Banner/index.vue +4 -2
- package/dist/runtime/editor/components/Banner/index.vue.d.ts +12 -2
- package/dist/runtime/editor/components/Dropdown/index.d.vue.ts +27 -0
- package/dist/runtime/editor/components/Dropdown/index.vue +107 -0
- package/dist/runtime/editor/components/Dropdown/index.vue.d.ts +27 -0
- package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue +1 -1
- package/dist/runtime/editor/components/EditProvider.d.vue.ts +2 -0
- package/dist/runtime/editor/components/EditProvider.vue +4 -3
- package/dist/runtime/editor/components/EditProvider.vue.d.ts +2 -0
- package/dist/runtime/editor/components/Form/Radio/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/Form/Radio/index.vue +3 -2
- package/dist/runtime/editor/components/Form/Radio/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/ItemIcon/index.vue +10 -2
- package/dist/runtime/editor/components/NestedEditorOverlay/index.d.vue.ts +13 -3
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +15 -7
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue.d.ts +13 -3
- package/dist/runtime/editor/components/PreviewProvider.d.vue.ts +2 -0
- package/dist/runtime/editor/components/PreviewProvider.vue +3 -2
- package/dist/runtime/editor/components/PreviewProvider.vue.d.ts +2 -0
- package/dist/runtime/editor/components/ShortcutIndicator/index.vue +1 -1
- package/dist/runtime/editor/components/index.d.ts +3 -1
- package/dist/runtime/editor/components/index.js +4 -0
- package/dist/runtime/editor/composables/onElementResize.js +0 -1
- package/dist/runtime/editor/composables/useEditableFieldOverride.js +4 -5
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +7 -0
- package/dist/runtime/editor/features/add-list/Help/Item.vue +5 -2
- package/dist/runtime/editor/features/artboard/Renderer.vue +1 -1
- package/dist/runtime/editor/features/clipboard/index.vue +1 -1
- package/dist/runtime/editor/features/debug/index.vue +1 -1
- package/dist/runtime/editor/features/dev-mode/index.vue +86 -2
- package/dist/runtime/editor/features/edit/index.vue +20 -0
- package/dist/runtime/editor/features/fragments/types.d.ts +1 -0
- package/dist/runtime/editor/features/hover/Renderer/index.vue +30 -3
- package/dist/runtime/editor/features/hover/index.vue +1 -1
- package/dist/runtime/editor/features/options/Form/Checkbox/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkbox/index.vue +3 -3
- package/dist/runtime/editor/features/options/Form/Checkbox/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue +5 -5
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Item.vue +14 -48
- package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Number/index.d.vue.ts +3 -3
- package/dist/runtime/editor/features/options/Form/Number/index.vue +7 -17
- package/dist/runtime/editor/features/options/Form/Number/index.vue.d.ts +3 -3
- package/dist/runtime/editor/features/options/Form/Range/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Range/index.vue +4 -4
- package/dist/runtime/editor/features/options/Form/Range/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/index.vue +10 -5
- package/dist/runtime/editor/features/selection/index.vue +2 -2
- package/dist/runtime/editor/features/transform/index.vue +1 -3
- package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +1 -1
- package/dist/runtime/editor/providers/definition.d.ts +2 -2
- package/dist/runtime/editor/providers/definition.js +7 -1
- package/dist/runtime/editor/providers/dom.d.ts +5 -0
- package/dist/runtime/editor/providers/dom.js +11 -2
- package/dist/runtime/editor/providers/fields.d.ts +19 -1
- package/dist/runtime/editor/providers/fields.js +54 -2
- package/dist/runtime/editor/translations/de.json +269 -1
- package/dist/runtime/editor/translations/fr.json +269 -1
- package/dist/runtime/editor/translations/gsw_CH.json +269 -1
- package/dist/runtime/editor/translations/it.json +269 -1
- package/dist/runtime/helpers/imports/index.d.ts +8 -1
- package/dist/runtime/helpers/imports/index.js +15 -6
- package/dist/runtime/helpers/injections.d.ts +5 -1
- package/dist/runtime/helpers/injections.js +3 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +14 -0
- package/dist/runtime/types/definitions.d.ts +8 -5
- package/dist/runtime/types/provider.d.ts +2 -0
- package/dist/shared/editor.6D5vApr0.mjs +30 -0
- package/dist/shared/{editor.DMFfaLVE.mjs → editor.BFIzNSQM.mjs} +1 -30
- package/dist/shared/{editor.Iax3GCvt.d.mts → editor.CWQIFIEQ.d.mts} +22 -0
- package/dist/types.d.mts +1 -1
- package/package.json +17 -1
- package/dist/modules/agent/runtime/app/tools/get_available_bundles/index.js +0 -104
- /package/dist/modules/agent/runtime/app/tools/{get_available_bundles → get_bundle_info}/index.d.ts +0 -0
- /package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.d.vue.ts +0 -0
- /package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue.d.ts +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import { chartTypeEnum, chartColorEnum, chartSeriesSchema } from "../chart_schemas.js";
|
|
4
|
+
import { COLORS } from "#blokkli-build/charts-config";
|
|
5
|
+
import { getDefaultChartData } from "#blokkli/charts/types";
|
|
6
|
+
import { fragmentBlockBundle } from "#blokkli-build/config";
|
|
7
|
+
const paramsSchema = z.object({
|
|
8
|
+
uuid: z.string().describe("UUID of the chart paragraph")
|
|
9
|
+
});
|
|
10
|
+
const resultSchema = z.object({
|
|
11
|
+
title: z.string().describe("Chart title"),
|
|
12
|
+
type: chartTypeEnum.describe("Chart type"),
|
|
13
|
+
categories: z.array(z.string()).describe("Category labels"),
|
|
14
|
+
series: z.array(chartSeriesSchema.required()).describe("Data series with colors"),
|
|
15
|
+
categoryColors: z.array(chartColorEnum).describe("Color IDs per category"),
|
|
16
|
+
footnotes: z.array(z.string()).describe("Footnote texts"),
|
|
17
|
+
typeOptions: z.record(z.string(), z.union([z.string(), z.boolean(), z.number()])).describe("Current type-specific rendering options")
|
|
18
|
+
});
|
|
19
|
+
export default defineBlokkliAgentTool({
|
|
20
|
+
name: "get_chart_data",
|
|
21
|
+
description: "Get the current data of a chart. Returns the chart type, categories, series, colors, footnotes, and typeOptions. Use this to inspect a chart before updating it.",
|
|
22
|
+
category: "query",
|
|
23
|
+
volatile: true,
|
|
24
|
+
prunedSummary: (r) => `chart data (${r.type})`,
|
|
25
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
26
|
+
lazy: true,
|
|
27
|
+
label($t) {
|
|
28
|
+
return $t("aiAgentGetChartDataRunning", "Getting chart data...");
|
|
29
|
+
},
|
|
30
|
+
paramsSchema,
|
|
31
|
+
resultSchema,
|
|
32
|
+
execute(ctx, params) {
|
|
33
|
+
const { blocks, state, $t } = ctx.app;
|
|
34
|
+
const block = blocks.getBlock(params.uuid);
|
|
35
|
+
if (!block) {
|
|
36
|
+
return { error: `Paragraph not found: ${params.uuid}` };
|
|
37
|
+
}
|
|
38
|
+
if (block.bundle !== fragmentBlockBundle) {
|
|
39
|
+
return {
|
|
40
|
+
error: `Paragraph "${params.uuid}" is a "${block.bundle}", not a fragment.`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (block.fragment?.name !== "blokkli_chart") {
|
|
44
|
+
return {
|
|
45
|
+
error: `Fragment "${params.uuid}" is a "${block.fragment?.name}", not a "blokkli_chart".`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const item = state.getFieldListItem(params.uuid);
|
|
49
|
+
const rawData = item?.options?.data;
|
|
50
|
+
let data;
|
|
51
|
+
if (rawData) {
|
|
52
|
+
try {
|
|
53
|
+
data = JSON.parse(rawData);
|
|
54
|
+
} catch {
|
|
55
|
+
data = getDefaultChartData(COLORS);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
data = getDefaultChartData(COLORS);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
result: {
|
|
62
|
+
title: data.title || "",
|
|
63
|
+
type: data.type,
|
|
64
|
+
categories: data.categories,
|
|
65
|
+
series: data.series,
|
|
66
|
+
categoryColors: data.categoryColors || [],
|
|
67
|
+
footnotes: data.footnotes || [],
|
|
68
|
+
typeOptions: data.typeOptions || {}
|
|
69
|
+
},
|
|
70
|
+
label: $t("aiAgentGetChartDataDone", "Got chart data"),
|
|
71
|
+
affectedUuids: [params.uuid]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import {
|
|
4
|
+
blockOptionsMapSchema,
|
|
5
|
+
buildBlockOptionsMapFromDefinitions
|
|
6
|
+
} from "#blokkli/agent/app/tools/schemas";
|
|
7
|
+
import { getChartTypeRuntime } from "../../../chartTypes/index.js";
|
|
8
|
+
import { chartTypeEnum } from "../chart_schemas.js";
|
|
9
|
+
const paramsSchema = z.object({
|
|
10
|
+
type: chartTypeEnum.describe("The chart type to get options for")
|
|
11
|
+
});
|
|
12
|
+
const resultSchema = z.object({
|
|
13
|
+
type: z.string().describe("The chart type ID"),
|
|
14
|
+
options: blockOptionsMapSchema.describe("Available typeOptions")
|
|
15
|
+
});
|
|
16
|
+
export default defineBlokkliAgentTool({
|
|
17
|
+
name: "get_chart_type_options",
|
|
18
|
+
description: "Get available typeOptions for a chart type. Call this before setting typeOptions on create_chart or update_chart to know which keys are valid, their types, defaults, and allowed values.",
|
|
19
|
+
category: "query",
|
|
20
|
+
volatile: true,
|
|
21
|
+
lazy: true,
|
|
22
|
+
prunedSummary: (r) => `options for ${r.type}`,
|
|
23
|
+
modes: ["editing"],
|
|
24
|
+
label($t) {
|
|
25
|
+
return $t("aiAgentGetChartTypeOptionsRunning", "Getting chart options...");
|
|
26
|
+
},
|
|
27
|
+
paramsSchema,
|
|
28
|
+
resultSchema,
|
|
29
|
+
execute(_ctx, params) {
|
|
30
|
+
const def = getChartTypeRuntime(params.type);
|
|
31
|
+
if (!def) {
|
|
32
|
+
return { error: `Unknown chart type: ${params.type}` };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
result: {
|
|
36
|
+
type: params.type,
|
|
37
|
+
options: buildBlockOptionsMapFromDefinitions(def.editor.options)
|
|
38
|
+
},
|
|
39
|
+
label: `Chart options for "${def.editor.label}"`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import { mutationResultSchema } from "#blokkli/agent/app/tools/schemas";
|
|
4
|
+
import {
|
|
5
|
+
chartTypeEnum,
|
|
6
|
+
chartColorEnum,
|
|
7
|
+
chartSeriesSchema,
|
|
8
|
+
validateChartData
|
|
9
|
+
} from "../chart_schemas.js";
|
|
10
|
+
import { COLORS } from "#blokkli-build/charts-config";
|
|
11
|
+
import { getDefaultChartData } from "#blokkli/charts/types";
|
|
12
|
+
import { fragmentBlockBundle } from "#blokkli-build/config";
|
|
13
|
+
const paramsSchema = z.object({
|
|
14
|
+
uuid: z.string().describe("UUID of the chart paragraph to update"),
|
|
15
|
+
title: z.string().optional().describe("Chart title"),
|
|
16
|
+
type: chartTypeEnum.optional().describe("Chart type"),
|
|
17
|
+
categories: z.array(z.string()).min(1).optional().describe(
|
|
18
|
+
"Category labels (x-axis or slice names). Replaces all existing categories."
|
|
19
|
+
),
|
|
20
|
+
series: z.array(chartSeriesSchema).min(1).optional().describe("Data series. Replaces all existing series."),
|
|
21
|
+
categoryColors: z.array(chartColorEnum).optional().describe(
|
|
22
|
+
"Color IDs per category (for pie/donut/radialBar). Auto-assigned if omitted."
|
|
23
|
+
),
|
|
24
|
+
footnotes: z.array(z.string()).optional().describe(
|
|
25
|
+
"Footnote texts. Reference in categories/series names as {1}, {2}, etc."
|
|
26
|
+
),
|
|
27
|
+
typeOptions: z.record(z.string(), z.union([z.string(), z.boolean(), z.number()])).optional().describe(
|
|
28
|
+
"Type-specific rendering options. Use get_chart_type_options to see available keys."
|
|
29
|
+
)
|
|
30
|
+
});
|
|
31
|
+
export default defineBlokkliAgentTool({
|
|
32
|
+
name: "update_chart",
|
|
33
|
+
description: "Update an existing chart. Provide only the properties you want to change \u2014 they will be merged with the current chart data. Arrays (series, categories, footnotes) are replaced entirely when provided, not merged element-by-element.",
|
|
34
|
+
category: "mutation",
|
|
35
|
+
prunedSummary: (r) => r.success ? "updated chart" : "rejected",
|
|
36
|
+
modes: ["editing"],
|
|
37
|
+
lazy: true,
|
|
38
|
+
label($t) {
|
|
39
|
+
return $t("aiAgentUpdateChartRunning", "Updating chart...");
|
|
40
|
+
},
|
|
41
|
+
paramsSchema,
|
|
42
|
+
resultSchema: mutationResultSchema,
|
|
43
|
+
requiredAdapterMethods: ["updateOptions"],
|
|
44
|
+
execute(ctx, params) {
|
|
45
|
+
const { blocks, state } = ctx.app;
|
|
46
|
+
const block = blocks.getBlock(params.uuid);
|
|
47
|
+
if (!block) {
|
|
48
|
+
return { error: `Paragraph not found: ${params.uuid}` };
|
|
49
|
+
}
|
|
50
|
+
if (block.bundle !== fragmentBlockBundle) {
|
|
51
|
+
return {
|
|
52
|
+
error: `Paragraph "${params.uuid}" is a "${block.bundle}", not a "${fragmentBlockBundle}".`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (block.fragment?.name !== "blokkli_chart") {
|
|
56
|
+
return {
|
|
57
|
+
error: `Fragment "${params.uuid}" is a "${block.fragment?.name}", not a "blokkli_chart".`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
let current;
|
|
61
|
+
const item = state.getFieldListItem(params.uuid);
|
|
62
|
+
const rawData = item?.options?.data;
|
|
63
|
+
if (rawData) {
|
|
64
|
+
try {
|
|
65
|
+
current = JSON.parse(rawData);
|
|
66
|
+
} catch {
|
|
67
|
+
current = getDefaultChartData(COLORS);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
current = getDefaultChartData(COLORS);
|
|
71
|
+
}
|
|
72
|
+
const merged = {
|
|
73
|
+
title: params.title !== void 0 ? params.title : current.title,
|
|
74
|
+
type: params.type !== void 0 ? params.type : current.type,
|
|
75
|
+
categories: params.categories !== void 0 ? params.categories : current.categories,
|
|
76
|
+
series: params.series !== void 0 ? params.series.map((s) => ({
|
|
77
|
+
name: s.name,
|
|
78
|
+
color: s.color || "",
|
|
79
|
+
data: s.data
|
|
80
|
+
})) : current.series,
|
|
81
|
+
categoryColors: params.categoryColors !== void 0 ? params.categoryColors : current.categoryColors,
|
|
82
|
+
footnotes: params.footnotes !== void 0 ? params.footnotes : current.footnotes,
|
|
83
|
+
typeOptions: params.typeOptions !== void 0 ? params.typeOptions : current.typeOptions || {}
|
|
84
|
+
};
|
|
85
|
+
const result = validateChartData(merged, COLORS);
|
|
86
|
+
if ("error" in result) return result;
|
|
87
|
+
const { $t } = ctx.app;
|
|
88
|
+
return {
|
|
89
|
+
type: "options",
|
|
90
|
+
label: $t("aiAgentUpdateChartDone", "Updated chart"),
|
|
91
|
+
affectedUuids: [params.uuid],
|
|
92
|
+
apply: (adapter) => adapter.updateOptions([
|
|
93
|
+
{
|
|
94
|
+
uuid: params.uuid,
|
|
95
|
+
key: "data",
|
|
96
|
+
value: JSON.stringify(result.data)
|
|
97
|
+
}
|
|
98
|
+
])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
import {
|
|
3
|
+
xAxisOptions,
|
|
4
|
+
buildXAxisLabelOptions,
|
|
5
|
+
dataLabelsOptions,
|
|
6
|
+
buildDataLabelsOptions,
|
|
7
|
+
legendOptions,
|
|
8
|
+
buildLegendOptions,
|
|
9
|
+
gridOptions,
|
|
10
|
+
buildGridOptions,
|
|
11
|
+
strokeWidthOptions,
|
|
12
|
+
buildStrokeWidthOptions,
|
|
13
|
+
mergeShared
|
|
14
|
+
} from "./shared.js";
|
|
15
|
+
export default defineChartType(($t) => {
|
|
16
|
+
const shared = mergeShared(
|
|
17
|
+
xAxisOptions($t),
|
|
18
|
+
dataLabelsOptions($t),
|
|
19
|
+
legendOptions($t),
|
|
20
|
+
gridOptions($t),
|
|
21
|
+
strokeWidthOptions($t)
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
id: "area",
|
|
25
|
+
hasMultipleSeries: true,
|
|
26
|
+
hasSeriesColors: true,
|
|
27
|
+
hasCategoryColors: false,
|
|
28
|
+
buildChartOptions(ctx) {
|
|
29
|
+
const strokeWidth = buildStrokeWidthOptions(ctx.typeOptions);
|
|
30
|
+
return {
|
|
31
|
+
stroke: {
|
|
32
|
+
curve: ctx.typeOptions.curved ? "smooth" : "straight",
|
|
33
|
+
...strokeWidth.stroke
|
|
34
|
+
},
|
|
35
|
+
markers: { size: ctx.typeOptions.markers ? 5 : 0 },
|
|
36
|
+
xaxis: {
|
|
37
|
+
categories: ctx.categories,
|
|
38
|
+
...buildXAxisLabelOptions(ctx.typeOptions)
|
|
39
|
+
},
|
|
40
|
+
...buildDataLabelsOptions(ctx.typeOptions),
|
|
41
|
+
...buildLegendOptions(ctx.typeOptions),
|
|
42
|
+
...buildGridOptions(ctx.typeOptions)
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
buildSeries(ctx) {
|
|
46
|
+
return ctx.series.map((s) => ({ name: s.name, data: s.data }));
|
|
47
|
+
},
|
|
48
|
+
editor: {
|
|
49
|
+
label: $t("chartsTypeArea", "Area"),
|
|
50
|
+
icon: "bk_mdi_area_chart",
|
|
51
|
+
options: {
|
|
52
|
+
curved: {
|
|
53
|
+
type: "checkbox",
|
|
54
|
+
label: $t("chartsAreaCurved", "Smooth curves"),
|
|
55
|
+
default: false,
|
|
56
|
+
group: "display"
|
|
57
|
+
},
|
|
58
|
+
markers: {
|
|
59
|
+
type: "checkbox",
|
|
60
|
+
label: $t("chartsAreaMarkers", "Show markers"),
|
|
61
|
+
default: false,
|
|
62
|
+
group: "display"
|
|
63
|
+
},
|
|
64
|
+
...shared.options
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
import {
|
|
3
|
+
xAxisOptions,
|
|
4
|
+
buildXAxisLabelOptions,
|
|
5
|
+
dataLabelsOptions,
|
|
6
|
+
buildDataLabelsOptions,
|
|
7
|
+
legendOptions,
|
|
8
|
+
buildLegendOptions,
|
|
9
|
+
gridOptions,
|
|
10
|
+
buildGridOptions,
|
|
11
|
+
mergeShared
|
|
12
|
+
} from "./shared.js";
|
|
13
|
+
export default defineChartType(($t) => {
|
|
14
|
+
const shared = mergeShared(
|
|
15
|
+
xAxisOptions($t),
|
|
16
|
+
dataLabelsOptions($t),
|
|
17
|
+
legendOptions($t),
|
|
18
|
+
gridOptions($t)
|
|
19
|
+
);
|
|
20
|
+
return {
|
|
21
|
+
id: "bar",
|
|
22
|
+
hasMultipleSeries: true,
|
|
23
|
+
hasSeriesColors: true,
|
|
24
|
+
hasCategoryColors: false,
|
|
25
|
+
buildChartOptions(ctx) {
|
|
26
|
+
return {
|
|
27
|
+
chart: { stacked: !!ctx.typeOptions.stacked },
|
|
28
|
+
plotOptions: {
|
|
29
|
+
bar: {
|
|
30
|
+
horizontal: !!ctx.typeOptions.horizontal,
|
|
31
|
+
borderRadius: Number(ctx.typeOptions.borderRadius) || 0
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
xaxis: {
|
|
35
|
+
categories: ctx.categories,
|
|
36
|
+
...buildXAxisLabelOptions(ctx.typeOptions)
|
|
37
|
+
},
|
|
38
|
+
...buildDataLabelsOptions(ctx.typeOptions),
|
|
39
|
+
...buildLegendOptions(ctx.typeOptions),
|
|
40
|
+
...buildGridOptions(ctx.typeOptions)
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
buildSeries(ctx) {
|
|
44
|
+
return ctx.series.map((s) => ({ name: s.name, data: s.data }));
|
|
45
|
+
},
|
|
46
|
+
editor: {
|
|
47
|
+
label: $t("chartsTypeBar", "Bar"),
|
|
48
|
+
icon: "bk_mdi_bar_chart",
|
|
49
|
+
options: {
|
|
50
|
+
stacked: {
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
label: $t("chartsBarStacked", "Stacked"),
|
|
53
|
+
default: false,
|
|
54
|
+
group: "display"
|
|
55
|
+
},
|
|
56
|
+
horizontal: {
|
|
57
|
+
type: "checkbox",
|
|
58
|
+
label: $t("chartsBarHorizontal", "Horizontal"),
|
|
59
|
+
default: false,
|
|
60
|
+
group: "display"
|
|
61
|
+
},
|
|
62
|
+
borderRadius: {
|
|
63
|
+
type: "radios",
|
|
64
|
+
label: $t("chartsBorderRadius", "Corner radius"),
|
|
65
|
+
default: "0",
|
|
66
|
+
options: {
|
|
67
|
+
"0": $t("chartsBorderRadiusNone", "None"),
|
|
68
|
+
"4": $t("chartsBorderRadiusSmall", "Small"),
|
|
69
|
+
"8": $t("chartsBorderRadiusLarge", "Large")
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
...shared.options
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
export default defineChartType(($t) => ({
|
|
3
|
+
id: "donut",
|
|
4
|
+
hasMultipleSeries: false,
|
|
5
|
+
hasSeriesColors: false,
|
|
6
|
+
hasCategoryColors: true,
|
|
7
|
+
buildChartOptions(ctx) {
|
|
8
|
+
const show = !!ctx.typeOptions.showTotal;
|
|
9
|
+
return {
|
|
10
|
+
labels: ctx.categories,
|
|
11
|
+
dataLabels: { enabled: !!ctx.typeOptions.showLabels },
|
|
12
|
+
plotOptions: {
|
|
13
|
+
pie: {
|
|
14
|
+
donut: {
|
|
15
|
+
labels: {
|
|
16
|
+
show,
|
|
17
|
+
total: { show }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
buildSeries(ctx) {
|
|
25
|
+
return ctx.series[0]?.data || [];
|
|
26
|
+
},
|
|
27
|
+
editor: {
|
|
28
|
+
label: $t("chartsTypeDonut", "Donut"),
|
|
29
|
+
icon: "bk_mdi_donut_large",
|
|
30
|
+
options: {
|
|
31
|
+
showTotal: {
|
|
32
|
+
type: "checkbox",
|
|
33
|
+
label: $t("chartsDonutShowTotal", "Show total"),
|
|
34
|
+
default: false,
|
|
35
|
+
group: "display"
|
|
36
|
+
},
|
|
37
|
+
showLabels: {
|
|
38
|
+
type: "checkbox",
|
|
39
|
+
label: $t("chartsDonutShowLabels", "Show labels"),
|
|
40
|
+
default: true,
|
|
41
|
+
group: "labels"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
import {
|
|
3
|
+
xAxisOptions,
|
|
4
|
+
buildXAxisLabelOptions,
|
|
5
|
+
legendOptions,
|
|
6
|
+
buildLegendOptions,
|
|
7
|
+
gridOptions,
|
|
8
|
+
buildGridOptions,
|
|
9
|
+
mergeShared
|
|
10
|
+
} from "./shared.js";
|
|
11
|
+
export default defineChartType(($t) => {
|
|
12
|
+
const shared = mergeShared(
|
|
13
|
+
xAxisOptions($t),
|
|
14
|
+
legendOptions($t),
|
|
15
|
+
gridOptions($t)
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
id: "heatmap",
|
|
19
|
+
hasMultipleSeries: true,
|
|
20
|
+
hasSeriesColors: false,
|
|
21
|
+
hasCategoryColors: false,
|
|
22
|
+
buildChartOptions(ctx) {
|
|
23
|
+
return {
|
|
24
|
+
dataLabels: { enabled: true },
|
|
25
|
+
plotOptions: {
|
|
26
|
+
heatmap: {
|
|
27
|
+
colorScale: { ranges: [] }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
xaxis: {
|
|
31
|
+
...buildXAxisLabelOptions(ctx.typeOptions)
|
|
32
|
+
},
|
|
33
|
+
...buildLegendOptions(ctx.typeOptions),
|
|
34
|
+
...buildGridOptions(ctx.typeOptions)
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
buildSeries(ctx) {
|
|
38
|
+
return ctx.series.map((s) => ({
|
|
39
|
+
name: s.name,
|
|
40
|
+
data: s.data.map((value, i) => ({
|
|
41
|
+
x: ctx.categories[i] || "",
|
|
42
|
+
y: value
|
|
43
|
+
}))
|
|
44
|
+
}));
|
|
45
|
+
},
|
|
46
|
+
editor: {
|
|
47
|
+
label: $t("chartsTypeHeatmap", "Heatmap"),
|
|
48
|
+
icon: "bk_mdi_grid_view",
|
|
49
|
+
options: {
|
|
50
|
+
...shared.options
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TranslateFunction, ChartTypeDefinition } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get a chart type definition using fallback labels (no real translations).
|
|
4
|
+
* Used by ChartRenderer which runs in both edit mode and production.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getChartTypeRuntime(id: string): ChartTypeDefinition | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Get all chart type definitions with translated labels.
|
|
9
|
+
* Used by editor components only.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getChartTypes($t: TranslateFunction): ChartTypeDefinition[];
|
|
12
|
+
/**
|
|
13
|
+
* Get a single chart type definition with translated labels.
|
|
14
|
+
* Used by editor components only.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getChartType(id: string, $t: TranslateFunction): ChartTypeDefinition | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get the default type options for a chart type.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getDefaultTypeOptions(id: string): Record<string, unknown>;
|
|
21
|
+
export type { ChartTypeDefinition, ChartBuildContext, TranslateFunction, } from './types.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import barFactory from "./bar.js";
|
|
2
|
+
import lineFactory from "./line.js";
|
|
3
|
+
import areaFactory from "./area.js";
|
|
4
|
+
import pieFactory from "./pie.js";
|
|
5
|
+
import donutFactory from "./donut.js";
|
|
6
|
+
import heatmapFactory from "./heatmap.js";
|
|
7
|
+
import radialBarFactory from "./radialBar.js";
|
|
8
|
+
import radarFactory from "./radar.js";
|
|
9
|
+
const factories = [
|
|
10
|
+
barFactory,
|
|
11
|
+
lineFactory,
|
|
12
|
+
pieFactory,
|
|
13
|
+
areaFactory,
|
|
14
|
+
donutFactory,
|
|
15
|
+
heatmapFactory,
|
|
16
|
+
radialBarFactory,
|
|
17
|
+
radarFactory
|
|
18
|
+
];
|
|
19
|
+
const noopT = (_key, fallback) => fallback;
|
|
20
|
+
const runtimeCache = {};
|
|
21
|
+
function ensureRuntimeCache() {
|
|
22
|
+
if (Object.keys(runtimeCache).length === 0) {
|
|
23
|
+
for (const factory of factories) {
|
|
24
|
+
const def = factory(noopT);
|
|
25
|
+
runtimeCache[def.id] = def;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function getChartTypeRuntime(id) {
|
|
30
|
+
ensureRuntimeCache();
|
|
31
|
+
return runtimeCache[id];
|
|
32
|
+
}
|
|
33
|
+
export function getChartTypes($t) {
|
|
34
|
+
return factories.map((factory) => factory($t));
|
|
35
|
+
}
|
|
36
|
+
export function getChartType(id, $t) {
|
|
37
|
+
return getChartTypes($t).find((def) => def.id === id);
|
|
38
|
+
}
|
|
39
|
+
export function getDefaultTypeOptions(id) {
|
|
40
|
+
const def = getChartTypeRuntime(id);
|
|
41
|
+
if (!def) return {};
|
|
42
|
+
const defaults = {};
|
|
43
|
+
for (const [key, opt] of Object.entries(def.editor.options)) {
|
|
44
|
+
defaults[key] = opt.default;
|
|
45
|
+
}
|
|
46
|
+
return defaults;
|
|
47
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
import {
|
|
3
|
+
xAxisOptions,
|
|
4
|
+
buildXAxisLabelOptions,
|
|
5
|
+
dataLabelsOptions,
|
|
6
|
+
buildDataLabelsOptions,
|
|
7
|
+
legendOptions,
|
|
8
|
+
buildLegendOptions,
|
|
9
|
+
gridOptions,
|
|
10
|
+
buildGridOptions,
|
|
11
|
+
strokeWidthOptions,
|
|
12
|
+
buildStrokeWidthOptions,
|
|
13
|
+
mergeShared
|
|
14
|
+
} from "./shared.js";
|
|
15
|
+
export default defineChartType(($t) => {
|
|
16
|
+
const shared = mergeShared(
|
|
17
|
+
xAxisOptions($t),
|
|
18
|
+
dataLabelsOptions($t),
|
|
19
|
+
legendOptions($t),
|
|
20
|
+
gridOptions($t),
|
|
21
|
+
strokeWidthOptions($t)
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
id: "line",
|
|
25
|
+
hasMultipleSeries: true,
|
|
26
|
+
hasSeriesColors: true,
|
|
27
|
+
hasCategoryColors: false,
|
|
28
|
+
buildChartOptions(ctx) {
|
|
29
|
+
const strokeWidth = buildStrokeWidthOptions(ctx.typeOptions);
|
|
30
|
+
return {
|
|
31
|
+
stroke: {
|
|
32
|
+
curve: ctx.typeOptions.curved ? "smooth" : "straight",
|
|
33
|
+
...strokeWidth.stroke
|
|
34
|
+
},
|
|
35
|
+
markers: { size: ctx.typeOptions.markers ? 5 : 0 },
|
|
36
|
+
xaxis: {
|
|
37
|
+
categories: ctx.categories,
|
|
38
|
+
...buildXAxisLabelOptions(ctx.typeOptions)
|
|
39
|
+
},
|
|
40
|
+
...buildDataLabelsOptions(ctx.typeOptions),
|
|
41
|
+
...buildLegendOptions(ctx.typeOptions),
|
|
42
|
+
...buildGridOptions(ctx.typeOptions)
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
buildSeries(ctx) {
|
|
46
|
+
return ctx.series.map((s) => ({ name: s.name, data: s.data }));
|
|
47
|
+
},
|
|
48
|
+
editor: {
|
|
49
|
+
label: $t("chartsTypeLine", "Line"),
|
|
50
|
+
icon: "bk_mdi_show_chart",
|
|
51
|
+
options: {
|
|
52
|
+
curved: {
|
|
53
|
+
type: "checkbox",
|
|
54
|
+
label: $t("chartsLineCurved", "Smooth curves"),
|
|
55
|
+
default: false,
|
|
56
|
+
group: "display"
|
|
57
|
+
},
|
|
58
|
+
markers: {
|
|
59
|
+
type: "checkbox",
|
|
60
|
+
label: $t("chartsLineMarkers", "Show markers"),
|
|
61
|
+
default: false,
|
|
62
|
+
group: "display"
|
|
63
|
+
},
|
|
64
|
+
...shared.options
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineChartType } from "./define.js";
|
|
2
|
+
export default defineChartType(($t) => ({
|
|
3
|
+
id: "pie",
|
|
4
|
+
hasMultipleSeries: false,
|
|
5
|
+
hasSeriesColors: false,
|
|
6
|
+
hasCategoryColors: true,
|
|
7
|
+
buildChartOptions(ctx) {
|
|
8
|
+
return {
|
|
9
|
+
labels: ctx.categories,
|
|
10
|
+
dataLabels: { enabled: !!ctx.typeOptions.showLabels }
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
buildSeries(ctx) {
|
|
14
|
+
return ctx.series[0]?.data || [];
|
|
15
|
+
},
|
|
16
|
+
editor: {
|
|
17
|
+
label: $t("chartsTypePie", "Pie"),
|
|
18
|
+
icon: "bk_mdi_pie_chart",
|
|
19
|
+
options: {
|
|
20
|
+
showLabels: {
|
|
21
|
+
type: "checkbox",
|
|
22
|
+
label: $t("chartsPieShowLabels", "Show labels"),
|
|
23
|
+
default: true,
|
|
24
|
+
group: "labels"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}));
|