@sqlrooms/mosaic 0.29.0-rc.8 → 0.29.0-rc.9
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/README.md +84 -74
- package/dist/ai/agentIntent.d.ts +5 -0
- package/dist/ai/agentIntent.d.ts.map +1 -0
- package/dist/ai/agentIntent.js +8 -0
- package/dist/ai/agentIntent.js.map +1 -0
- package/dist/ai/block-document/constants.d.ts +9 -0
- package/dist/ai/block-document/constants.d.ts.map +1 -0
- package/dist/ai/block-document/constants.js +9 -0
- package/dist/ai/block-document/constants.js.map +1 -0
- package/dist/ai/block-document/createAddMosaicDashboardBlockTool.d.ts +48 -0
- package/dist/ai/block-document/createAddMosaicDashboardBlockTool.d.ts.map +1 -0
- package/dist/ai/block-document/createAddMosaicDashboardBlockTool.js +59 -0
- package/dist/ai/block-document/createAddMosaicDashboardBlockTool.js.map +1 -0
- package/dist/ai/block-document/createBlockDocumentChartTools.d.ts +19 -0
- package/dist/ai/block-document/createBlockDocumentChartTools.d.ts.map +1 -0
- package/dist/ai/block-document/createBlockDocumentChartTools.js +37 -0
- package/dist/ai/block-document/createBlockDocumentChartTools.js.map +1 -0
- package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.d.ts +32 -0
- package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.d.ts.map +1 -0
- package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.js +37 -0
- package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.js.map +1 -0
- package/dist/ai/constants.d.ts +3 -0
- package/dist/ai/constants.d.ts.map +1 -0
- package/dist/ai/constants.js +3 -0
- package/dist/ai/constants.js.map +1 -0
- package/dist/ai/createDataTableExplorerTool.d.ts +69 -0
- package/dist/ai/createDataTableExplorerTool.d.ts.map +1 -0
- package/dist/ai/createDataTableExplorerTool.js +68 -0
- package/dist/ai/createDataTableExplorerTool.js.map +1 -0
- package/dist/ai/dashboard/constants.d.ts +6 -0
- package/dist/ai/dashboard/constants.d.ts.map +1 -0
- package/dist/ai/dashboard/constants.js +6 -0
- package/dist/ai/dashboard/constants.js.map +1 -0
- package/dist/ai/dashboard/createDashboardAgentTool.d.ts +17 -0
- package/dist/ai/dashboard/createDashboardAgentTool.d.ts.map +1 -0
- package/dist/ai/dashboard/createDashboardAgentTool.js +205 -0
- package/dist/ai/dashboard/createDashboardAgentTool.js.map +1 -0
- package/dist/ai/dashboard/createDashboardAiAdapter.d.ts +14 -0
- package/dist/ai/dashboard/createDashboardAiAdapter.d.ts.map +1 -0
- package/dist/ai/dashboard/createDashboardAiAdapter.js +75 -0
- package/dist/ai/dashboard/createDashboardAiAdapter.js.map +1 -0
- package/dist/ai/dashboard/createDashboardAiTools.d.ts +26 -0
- package/dist/ai/dashboard/createDashboardAiTools.d.ts.map +1 -0
- package/dist/ai/dashboard/createDashboardAiTools.js +40 -0
- package/dist/ai/dashboard/createDashboardAiTools.js.map +1 -0
- package/dist/ai/dashboard/createDashboardChartTools.d.ts +27 -0
- package/dist/ai/dashboard/createDashboardChartTools.d.ts.map +1 -0
- package/dist/ai/dashboard/createDashboardChartTools.js +55 -0
- package/dist/ai/dashboard/createDashboardChartTools.js.map +1 -0
- package/dist/ai/dashboard/createDashboardDataTableExplorerTool.d.ts +23 -0
- package/dist/ai/dashboard/createDashboardDataTableExplorerTool.d.ts.map +1 -0
- package/dist/ai/dashboard/createDashboardDataTableExplorerTool.js +29 -0
- package/dist/ai/dashboard/createDashboardDataTableExplorerTool.js.map +1 -0
- package/dist/ai/dashboard/createListDashboardPanelsTool.d.ts +28 -0
- package/dist/ai/dashboard/createListDashboardPanelsTool.d.ts.map +1 -0
- package/dist/ai/dashboard/createListDashboardPanelsTool.js +54 -0
- package/dist/ai/dashboard/createListDashboardPanelsTool.js.map +1 -0
- package/dist/ai/dashboard/dashboard-types.d.ts +59 -0
- package/dist/ai/dashboard/dashboard-types.d.ts.map +1 -0
- package/dist/ai/dashboard/dashboard-types.js +2 -0
- package/dist/ai/dashboard/dashboard-types.js.map +1 -0
- package/dist/ai/database-types.d.ts +12 -0
- package/dist/ai/database-types.d.ts.map +1 -0
- package/dist/ai/database-types.js +2 -0
- package/dist/ai/database-types.js.map +1 -0
- package/dist/ai/errors.d.ts +8 -0
- package/dist/ai/errors.d.ts.map +1 -0
- package/dist/ai/errors.js +11 -0
- package/dist/ai/errors.js.map +1 -0
- package/dist/ai/tool-helpers.d.ts +28 -29
- package/dist/ai/tool-helpers.d.ts.map +1 -1
- package/dist/ai/tool-helpers.js +38 -76
- package/dist/ai/tool-helpers.js.map +1 -1
- package/dist/ai/tool-schemas.d.ts +9 -4
- package/dist/ai/tool-schemas.d.ts.map +1 -1
- package/dist/ai/tool-schemas.js +12 -12
- package/dist/ai/tool-schemas.js.map +1 -1
- package/dist/ai/tool-types.d.ts +19 -1
- package/dist/ai/tool-types.d.ts.map +1 -1
- package/dist/ai/tool-types.js.map +1 -1
- package/dist/ai/types.d.ts +64 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +2 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/ai.d.ts +16 -2
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js +14 -5
- package/dist/ai.js.map +1 -1
- package/dist/charts/MosaicChart.js +1 -1
- package/dist/charts/MosaicChart.js.map +1 -1
- package/dist/charts/MosaicChartView.d.ts.map +1 -1
- package/dist/charts/MosaicChartView.js +1 -2
- package/dist/charts/MosaicChartView.js.map +1 -1
- package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.d.ts.map +1 -1
- package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.js +2 -1
- package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.js.map +1 -1
- package/dist/charts/chart-settings/MosaicChartTypeSelector.d.ts.map +1 -1
- package/dist/charts/chart-settings/MosaicChartTypeSelector.js +4 -11
- package/dist/charts/chart-settings/MosaicChartTypeSelector.js.map +1 -1
- package/dist/charts/chart-types/base-types.d.ts +27 -23
- package/dist/charts/chart-types/base-types.d.ts.map +1 -1
- package/dist/charts/chart-types/base-types.js +3 -1
- package/dist/charts/chart-types/base-types.js.map +1 -1
- package/dist/charts/chart-types/box-plot/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/box-plot/definition.js +1 -0
- package/dist/charts/chart-types/box-plot/definition.js.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.d.ts +37 -3
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.d.ts.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js +26 -6
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js +2 -2
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.d.ts +12 -1
- package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.d.ts.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.js +13 -3
- package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.js.map +1 -1
- package/dist/charts/chart-types/box-plot/tool.d.ts +20 -24
- package/dist/charts/chart-types/box-plot/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/box-plot/tool.js +25 -33
- package/dist/charts/chart-types/box-plot/tool.js.map +1 -1
- package/dist/charts/chart-types/box-plot/validation.d.ts +9 -0
- package/dist/charts/chart-types/box-plot/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/box-plot/validation.js +32 -0
- package/dist/charts/chart-types/box-plot/validation.js.map +1 -0
- package/dist/charts/chart-types/column-types.d.ts +8 -0
- package/dist/charts/chart-types/column-types.d.ts.map +1 -0
- package/dist/charts/chart-types/column-types.js +2 -0
- package/dist/charts/chart-types/column-types.js.map +1 -0
- package/dist/charts/chart-types/count-plot/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/count-plot/definition.js +1 -0
- package/dist/charts/chart-types/count-plot/definition.js.map +1 -1
- package/dist/charts/chart-types/count-plot/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/count-plot/spec.js +1 -19
- package/dist/charts/chart-types/count-plot/spec.js.map +1 -1
- package/dist/charts/chart-types/count-plot/tool.d.ts +19 -24
- package/dist/charts/chart-types/count-plot/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/count-plot/tool.js +25 -32
- package/dist/charts/chart-types/count-plot/tool.js.map +1 -1
- package/dist/charts/chart-types/count-plot/validation.d.ts +8 -0
- package/dist/charts/chart-types/count-plot/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/count-plot/validation.js +20 -0
- package/dist/charts/chart-types/count-plot/validation.js.map +1 -0
- package/dist/charts/chart-types/createChartInstructions.d.ts +3 -0
- package/dist/charts/chart-types/createChartInstructions.d.ts.map +1 -0
- package/dist/charts/chart-types/createChartInstructions.js +12 -0
- package/dist/charts/chart-types/createChartInstructions.js.map +1 -0
- package/dist/charts/chart-types/createChartTools.d.ts +15 -9
- package/dist/charts/chart-types/createChartTools.d.ts.map +1 -1
- package/dist/charts/chart-types/createChartTools.js +16 -10
- package/dist/charts/chart-types/createChartTools.js.map +1 -1
- package/dist/charts/chart-types/custom-spec/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/custom-spec/definition.js +1 -0
- package/dist/charts/chart-types/custom-spec/definition.js.map +1 -1
- package/dist/charts/chart-types/errors.d.ts +10 -0
- package/dist/charts/chart-types/errors.d.ts.map +1 -1
- package/dist/charts/chart-types/errors.js +18 -0
- package/dist/charts/chart-types/errors.js.map +1 -1
- package/dist/charts/chart-types/heatmap/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/heatmap/definition.js +1 -0
- package/dist/charts/chart-types/heatmap/definition.js.map +1 -1
- package/dist/charts/chart-types/heatmap/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/heatmap/spec.js +1 -33
- package/dist/charts/chart-types/heatmap/spec.js.map +1 -1
- package/dist/charts/chart-types/heatmap/tool.d.ts +20 -24
- package/dist/charts/chart-types/heatmap/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/heatmap/tool.js +26 -36
- package/dist/charts/chart-types/heatmap/tool.js.map +1 -1
- package/dist/charts/chart-types/heatmap/validation.d.ts +9 -0
- package/dist/charts/chart-types/heatmap/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/heatmap/validation.js +34 -0
- package/dist/charts/chart-types/heatmap/validation.js.map +1 -0
- package/dist/charts/chart-types/histogram/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/definition.js +1 -0
- package/dist/charts/chart-types/histogram/definition.js.map +1 -1
- package/dist/charts/chart-types/histogram/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/spec.js +1 -21
- package/dist/charts/chart-types/histogram/spec.js.map +1 -1
- package/dist/charts/chart-types/histogram/tool.d.ts +37 -24
- package/dist/charts/chart-types/histogram/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/tool.js +38 -32
- package/dist/charts/chart-types/histogram/tool.js.map +1 -1
- package/dist/charts/chart-types/histogram/validation.d.ts +9 -0
- package/dist/charts/chart-types/histogram/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/histogram/validation.js +22 -0
- package/dist/charts/chart-types/histogram/validation.js.map +1 -0
- package/dist/charts/chart-types/index.d.ts +1 -7
- package/dist/charts/chart-types/index.d.ts.map +1 -1
- package/dist/charts/chart-types/index.js +2 -8
- package/dist/charts/chart-types/index.js.map +1 -1
- package/dist/charts/chart-types/line-chart/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/definition.js +1 -0
- package/dist/charts/chart-types/line-chart/definition.js.map +1 -1
- package/dist/charts/chart-types/line-chart/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/spec.js +5 -46
- package/dist/charts/chart-types/line-chart/spec.js.map +1 -1
- package/dist/charts/chart-types/line-chart/tool.d.ts +26 -24
- package/dist/charts/chart-types/line-chart/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/tool.js +26 -38
- package/dist/charts/chart-types/line-chart/tool.js.map +1 -1
- package/dist/charts/chart-types/line-chart/validation.d.ts +16 -0
- package/dist/charts/chart-types/line-chart/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/line-chart/validation.js +43 -0
- package/dist/charts/chart-types/line-chart/validation.js.map +1 -0
- package/dist/charts/chart-types/resolveChartTypes.d.ts +3 -0
- package/dist/charts/chart-types/resolveChartTypes.d.ts.map +1 -0
- package/dist/charts/chart-types/resolveChartTypes.js +8 -0
- package/dist/charts/chart-types/resolveChartTypes.js.map +1 -0
- package/dist/charts/chart-types/scatter-plot/definition.d.ts.map +1 -1
- package/dist/charts/chart-types/scatter-plot/definition.js +1 -0
- package/dist/charts/chart-types/scatter-plot/definition.js.map +1 -1
- package/dist/charts/chart-types/scatter-plot/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/scatter-plot/spec.js +1 -45
- package/dist/charts/chart-types/scatter-plot/spec.js.map +1 -1
- package/dist/charts/chart-types/scatter-plot/tool.d.ts +21 -24
- package/dist/charts/chart-types/scatter-plot/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/scatter-plot/tool.js +28 -41
- package/dist/charts/chart-types/scatter-plot/tool.js.map +1 -1
- package/dist/charts/chart-types/scatter-plot/validation.d.ts +13 -0
- package/dist/charts/chart-types/scatter-plot/validation.d.ts.map +1 -0
- package/dist/charts/chart-types/scatter-plot/validation.js +52 -0
- package/dist/charts/chart-types/scatter-plot/validation.js.map +1 -0
- package/dist/charts/chart-types/tool-types.d.ts +43 -0
- package/dist/charts/chart-types/tool-types.d.ts.map +1 -0
- package/dist/charts/chart-types/tool-types.js +2 -0
- package/dist/charts/chart-types/tool-types.js.map +1 -0
- package/dist/charts/chart-types/utils.d.ts +3 -0
- package/dist/charts/chart-types/utils.d.ts.map +1 -0
- package/dist/charts/chart-types/utils.js +4 -0
- package/dist/charts/chart-types/utils.js.map +1 -0
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.d.ts.map +1 -1
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.js +5 -3
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.js.map +1 -1
- package/dist/charts/useChartDataPolicy.js +2 -2
- package/dist/charts/useChartDataPolicy.js.map +1 -1
- package/dist/components/AggregationSelector.d.ts.map +1 -1
- package/dist/components/AggregationSelector.js +1 -1
- package/dist/components/AggregationSelector.js.map +1 -1
- package/dist/components/ColorSelector.d.ts.map +1 -1
- package/dist/components/ColorSelector.js +1 -2
- package/dist/components/ColorSelector.js.map +1 -1
- package/dist/components/FieldSelectorInput.d.ts.map +1 -1
- package/dist/components/FieldSelectorInput.js +3 -3
- package/dist/components/FieldSelectorInput.js.map +1 -1
- package/dist/components/TemporalGranularitySelector.d.ts.map +1 -1
- package/dist/components/TemporalGranularitySelector.js +1 -1
- package/dist/components/TemporalGranularitySelector.js.map +1 -1
- package/dist/dashboard/MosaicDashboardCommands.d.ts +19 -0
- package/dist/dashboard/MosaicDashboardCommands.d.ts.map +1 -0
- package/dist/dashboard/MosaicDashboardCommands.js +226 -0
- package/dist/dashboard/MosaicDashboardCommands.js.map +1 -0
- package/dist/dashboard/dashboard-types.d.ts.map +1 -1
- package/dist/dashboard/dashboard-types.js.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanel.d.ts.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanel.js +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanel.js.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanelLayout.d.ts.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanelLayout.js +3 -3
- package/dist/dashboard/panel/MosaicDashboardPanelLayout.js.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanels.d.ts.map +1 -1
- package/dist/dashboard/panel/MosaicDashboardPanels.js +4 -2
- package/dist/dashboard/panel/MosaicDashboardPanels.js.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.d.ts.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js +4 -4
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js +5 -3
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js.map +1 -1
- package/dist/dashboard/useSelectedOrFirstTable.d.ts +1 -1
- package/dist/dashboard/useSelectedOrFirstTable.d.ts.map +1 -1
- package/dist/dashboard/useSelectedOrFirstTable.js +10 -8
- package/dist/dashboard/useSelectedOrFirstTable.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.d.ts +3 -2
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.js +3 -3
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCountClient.d.ts +3 -1
- package/dist/data-table-explorer/DataTableExplorerCountClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCountClient.js +3 -3
- package/dist/data-table-explorer/DataTableExplorerCountClient.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerHistogramClient.d.ts +3 -2
- package/dist/data-table-explorer/DataTableExplorerHistogramClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerHistogramClient.js +4 -4
- package/dist/data-table-explorer/DataTableExplorerHistogramClient.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerPageClient.d.ts +3 -1
- package/dist/data-table-explorer/DataTableExplorerPageClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerPageClient.js +3 -1
- package/dist/data-table-explorer/DataTableExplorerPageClient.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.d.ts +3 -2
- package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.js +3 -3
- package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.js.map +1 -1
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.d.ts.map +1 -1
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js +7 -4
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js.map +1 -1
- package/dist/data-table-explorer/dataTableExplorerController.d.ts +58 -2
- package/dist/data-table-explorer/dataTableExplorerController.d.ts.map +1 -1
- package/dist/data-table-explorer/dataTableExplorerController.js +68 -8
- package/dist/data-table-explorer/dataTableExplorerController.js.map +1 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts +23 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts.map +1 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js +46 -13
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js.map +1 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts +17 -3
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts.map +1 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js +9 -6
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js.map +1 -1
- package/dist/data-table-explorer/types.d.ts +10 -0
- package/dist/data-table-explorer/types.d.ts.map +1 -1
- package/dist/data-table-explorer/types.js.map +1 -1
- package/dist/data-table-explorer/useDataTableExplorer.d.ts.map +1 -1
- package/dist/data-table-explorer/useDataTableExplorer.js +10 -6
- package/dist/data-table-explorer/useDataTableExplorer.js.map +1 -1
- package/dist/data-table-explorer/utils.d.ts +64 -6
- package/dist/data-table-explorer/utils.d.ts.map +1 -1
- package/dist/data-table-explorer/utils.js +58 -0
- package/dist/data-table-explorer/utils.js.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.d.ts.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js +2 -2
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js.map +1 -1
- package/dist/index.d.ts +49 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -25
- package/dist/index.js.map +1 -1
- package/dist/mosaicTableReference.d.ts +59 -0
- package/dist/mosaicTableReference.d.ts.map +1 -0
- package/dist/mosaicTableReference.js +68 -0
- package/dist/mosaicTableReference.js.map +1 -0
- package/dist/useVgPlotChartRender.d.ts.map +1 -1
- package/dist/useVgPlotChartRender.js +26 -1
- package/dist/useVgPlotChartRender.js.map +1 -1
- package/dist/utils/table-lookup.d.ts +7 -0
- package/dist/utils/table-lookup.d.ts.map +1 -0
- package/dist/utils/table-lookup.js +10 -0
- package/dist/utils/table-lookup.js.map +1 -0
- package/package.json +14 -14
- package/dist/ai/ai.d.ts +0 -108
- package/dist/ai/ai.d.ts.map +0 -1
- package/dist/ai/ai.js +0 -461
- package/dist/ai/ai.js.map +0 -1
- package/dist/ai/data-table-explorer-tool.d.ts +0 -40
- package/dist/ai/data-table-explorer-tool.d.ts.map +0 -1
- package/dist/ai/data-table-explorer-tool.js +0 -75
- package/dist/ai/data-table-explorer-tool.js.map +0 -1
- package/dist/ai/list-panels-tool.d.ts +0 -35
- package/dist/ai/list-panels-tool.d.ts.map +0 -1
- package/dist/ai/list-panels-tool.js +0 -66
- package/dist/ai/list-panels-tool.js.map +0 -1
- package/dist/ai/remove-panel-tool.d.ts +0 -31
- package/dist/ai/remove-panel-tool.d.ts.map +0 -1
- package/dist/ai/remove-panel-tool.js +0 -55
- package/dist/ai/remove-panel-tool.js.map +0 -1
- package/dist/ai/tool-validation.d.ts +0 -3
- package/dist/ai/tool-validation.d.ts.map +0 -1
- package/dist/ai/tool-validation.js +0 -11
- package/dist/ai/tool-validation.js.map +0 -1
- package/dist/components/Combobox.d.ts +0 -45
- package/dist/components/Combobox.d.ts.map +0 -1
- package/dist/components/Combobox.js +0 -58
- package/dist/components/Combobox.js.map +0 -1
- package/dist/components/useCombobox.d.ts +0 -23
- package/dist/components/useCombobox.d.ts.map +0 -1
- package/dist/components/useCombobox.js +0 -26
- package/dist/components/useCombobox.js.map +0 -1
|
@@ -9,6 +9,7 @@ export const histogramChartType = {
|
|
|
9
9
|
id: 'histogram',
|
|
10
10
|
label: 'Histogram',
|
|
11
11
|
description: DESCRIPTION,
|
|
12
|
+
aiDescription: `${DESCRIPTION} - distribution of numeric values (always safe, aggregates automatically)`,
|
|
12
13
|
icon: BarChart3,
|
|
13
14
|
schema: HistogramChartSettings,
|
|
14
15
|
settingsComponent: HistogramSettingsComponent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,QAAQ,CAAC;AAE3C,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAC7B;IACE,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,sBAAsB;IAC9B,iBAAiB,EAAE,0BAA0B;IAC7C,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,mBAAmB;CAChC,CAAC","sourcesContent":["import type {SpecChartTypeDefinition} from '../base-types';\nimport {HistogramChartConfig, HistogramChartSettings} from './schema';\nimport {titleFromDescription} from '../../../chart-builders/chartTypeUtils';\nimport {HistogramSettingsComponent} from './HistogramSettings';\nimport {createHistogramAiTool} from './tool';\nimport {BarChart3} from 'lucide-react';\nimport {createHistogramSpec} from './spec';\n\nconst DESCRIPTION = 'Create a histogram of a field';\n\nexport const histogramChartType: SpecChartTypeDefinition<HistogramChartConfig> =\n {\n id: 'histogram',\n label: 'Histogram',\n description: DESCRIPTION,\n icon: BarChart3,\n schema: HistogramChartSettings,\n settingsComponent: HistogramSettingsComponent,\n buildTitle: titleFromDescription(DESCRIPTION),\n createTool: createHistogramAiTool,\n createSpec: createHistogramSpec,\n };\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,QAAQ,CAAC;AAE3C,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAC7B;IACE,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,GAAG,WAAW,2EAA2E;IACxG,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,sBAAsB;IAC9B,iBAAiB,EAAE,0BAA0B;IAC7C,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,mBAAmB;CAChC,CAAC","sourcesContent":["import type {SpecChartTypeDefinition} from '../base-types';\nimport {HistogramChartConfig, HistogramChartSettings} from './schema';\nimport {titleFromDescription} from '../../../chart-builders/chartTypeUtils';\nimport {HistogramSettingsComponent} from './HistogramSettings';\nimport {createHistogramAiTool} from './tool';\nimport {BarChart3} from 'lucide-react';\nimport {createHistogramSpec} from './spec';\n\nconst DESCRIPTION = 'Create a histogram of a field';\n\nexport const histogramChartType: SpecChartTypeDefinition<HistogramChartConfig> =\n {\n id: 'histogram',\n label: 'Histogram',\n description: DESCRIPTION,\n aiDescription: `${DESCRIPTION} - distribution of numeric values (always safe, aggregates automatically)`,\n icon: BarChart3,\n schema: HistogramChartSettings,\n settingsComponent: HistogramSettingsComponent,\n buildTitle: titleFromDescription(DESCRIPTION),\n createTool: createHistogramAiTool,\n createSpec: createHistogramSpec,\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAyB,MAAM,eAAe,CAAC;AAOxE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,iBAAiB,CAAC,sBAAsB,CAAC,GACjD,IAAI,CAsCN"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_BINS_COUNT } from './schema';
|
|
2
1
|
import { getChartTableReference } from '../base-types';
|
|
3
|
-
import { InvalidColumnTypeError, MissingColumnsError, RequiredFieldsError, } from '../errors';
|
|
4
|
-
import { isQuantitativeType } from '../../../column-types-utils';
|
|
5
2
|
import { DEFAULT_CHART_FALLBACK_COLOR } from '../../../constants/chart-colors';
|
|
3
|
+
import { validateHistogramSettings } from './validation';
|
|
6
4
|
const BG_COLOR = 'var(--color-chart-overlay)';
|
|
7
5
|
const DEFAULT_FG_COLOR = DEFAULT_CHART_FALLBACK_COLOR;
|
|
8
6
|
export function createHistogramSpec(options) {
|
|
@@ -39,22 +37,4 @@ export function createHistogramSpec(options) {
|
|
|
39
37
|
params: { brush: { select: 'crossfilter' } },
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
function validateHistogramSettings({ dataTable, settings: { field, maxBins = DEFAULT_BINS_COUNT }, }) {
|
|
43
|
-
// Basic validation for required fields
|
|
44
|
-
if (!field) {
|
|
45
|
-
throw new RequiredFieldsError('Field');
|
|
46
|
-
}
|
|
47
|
-
// Validate field existence and type
|
|
48
|
-
const fieldColumn = dataTable.columns.find((col) => col.name === field);
|
|
49
|
-
if (!fieldColumn) {
|
|
50
|
-
throw new MissingColumnsError(field);
|
|
51
|
-
}
|
|
52
|
-
if (!isQuantitativeType(fieldColumn.type)) {
|
|
53
|
-
throw new InvalidColumnTypeError(fieldColumn.name, 'quantitative');
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
fieldColumn,
|
|
57
|
-
maxBins,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
40
|
//# sourceMappingURL=spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACxE,OAAO,EAAC,4BAA4B,EAAC,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAC,yBAAyB,EAAC,MAAM,cAAc,CAAC;AAEvD,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAC9C,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAEtD,MAAM,UAAU,mBAAmB,CACjC,OAAkD;IAElD,MAAM,EAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC;IAErD,MAAM,EAAC,WAAW,EAAE,OAAO,EAAC,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,IAAI,gBAAgB,CAAC;IACnD,MAAM,cAAc,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAEzD,MAAM,IAAI,GAAc;QACtB;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAC,IAAI,EAAE,cAAc,EAAC;YAC5B,CAAC,EAAE,EAAC,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAC;YAC1C,CAAC,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC;YAChB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;SACX;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAC;YAChD,CAAC,EAAE,EAAC,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAC;YAC1C,CAAC,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC;YAChB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG;SACX;KACF,CAAC;IAEF,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,WAAW,CAAC,IAAI;QACxB,MAAM,EAAE,OAAO;QAEf,OAAO,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAC;QACnD,MAAM,EAAE,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAC;KACjC,CAAC;AACZ,CAAC","sourcesContent":["import type {Spec} from '@uwdata/mosaic-spec';\nimport {HistogramChartSettings} from './schema';\nimport {CreateSpecOptions, getChartTableReference} from '../base-types';\nimport {DEFAULT_CHART_FALLBACK_COLOR} from '../../../constants/chart-colors';\nimport {validateHistogramSettings} from './validation';\n\nconst BG_COLOR = 'var(--color-chart-overlay)';\nconst DEFAULT_FG_COLOR = DEFAULT_CHART_FALLBACK_COLOR;\n\nexport function createHistogramSpec(\n options: CreateSpecOptions<HistogramChartSettings>,\n): Spec {\n const {dataTable, selectionName, settings} = options;\n\n const {fieldColumn, maxBins} = validateHistogramSettings(options);\n const fgColor = settings.color ?? DEFAULT_FG_COLOR;\n const tableReference = getChartTableReference(dataTable);\n\n const plot: unknown[] = [\n {\n mark: 'rectY',\n data: {from: tableReference},\n x: {bin: fieldColumn.name, steps: maxBins},\n y: {count: null},\n fill: BG_COLOR,\n inset: 0.5,\n },\n {\n mark: 'rectY',\n data: {from: tableReference, filterBy: '$brush'},\n x: {bin: fieldColumn.name, steps: maxBins},\n y: {count: null},\n fill: fgColor,\n inset: 0.5,\n },\n ];\n\n if (selectionName) {\n plot.push({select: 'intervalX', as: '$brush'});\n }\n\n return {\n plot,\n xLabel: fieldColumn.name,\n yLabel: 'Count',\n\n margins: {left: 50, right: 20, top: 20, bottom: 50},\n params: {brush: {select: 'crossfilter'}},\n } as Spec;\n}\n"]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { ChartToolParams, ChartToolOutput } from '../tool-types';
|
|
3
|
+
/**
|
|
4
|
+
* Input schema for the histogram chart tool.
|
|
5
|
+
* Extends base chart input with histogram-specific settings including field and bin configuration.
|
|
6
|
+
*/
|
|
7
|
+
export declare const HistogramToolInput: z.ZodObject<{
|
|
8
|
+
tableName: z.ZodString;
|
|
9
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
10
|
panelId: z.ZodOptional<z.ZodString>;
|
|
8
11
|
reasoning: z.ZodString;
|
|
9
12
|
settings: z.ZodObject<{
|
|
@@ -12,31 +15,41 @@ export declare const HistogramToolParameters: z.ZodObject<{
|
|
|
12
15
|
color: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
|
|
13
16
|
}, z.core.$strip>;
|
|
14
17
|
}, z.core.$strip>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Type representing validated input for histogram chart creation.
|
|
20
|
+
*/
|
|
21
|
+
export type HistogramToolInput = z.infer<typeof HistogramToolInput>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an AI tool for generating histogram charts.
|
|
24
|
+
* Histograms show distribution of numeric values by grouping data into bins/ranges.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Chart tool parameters
|
|
27
|
+
* @param params.databaseAdapter - Database adapter for table and column validation
|
|
28
|
+
* @param params.addChart - Function to add the generated chart to the target artifact
|
|
29
|
+
* @returns AI tool instance for histogram chart creation
|
|
30
|
+
*/
|
|
31
|
+
export declare function createHistogramAiTool({ databaseAdapter, addChart, }: ChartToolParams): import("ai").Tool<{
|
|
32
|
+
tableName: string;
|
|
18
33
|
reasoning: string;
|
|
19
34
|
settings: {
|
|
20
35
|
field: string;
|
|
21
36
|
maxBins: number;
|
|
22
37
|
color: string;
|
|
23
38
|
};
|
|
24
|
-
|
|
25
|
-
tableName?: string | undefined;
|
|
39
|
+
title?: string | undefined;
|
|
26
40
|
panelId?: string | undefined;
|
|
27
|
-
}, {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
} | {
|
|
35
|
-
llmResult: {
|
|
36
|
-
success: boolean;
|
|
37
|
-
errorMessage: string;
|
|
38
|
-
details?: undefined;
|
|
39
|
-
data?: undefined;
|
|
41
|
+
}, ChartToolOutput<{
|
|
42
|
+
chartType: "histogram";
|
|
43
|
+
settings: {
|
|
44
|
+
field?: string | undefined;
|
|
45
|
+
maxBins?: number | undefined;
|
|
46
|
+
color?: string | undefined;
|
|
40
47
|
};
|
|
41
|
-
|
|
48
|
+
settingsOpen?: boolean | undefined;
|
|
49
|
+
dataPolicy?: {
|
|
50
|
+
disabled?: boolean | undefined;
|
|
51
|
+
maxRows?: number | undefined;
|
|
52
|
+
reason?: string | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
}>>;
|
|
42
55
|
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAUtB,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAI/D;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAE7B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,eAAe,EACf,QAAQ,GACT,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;IAkDjB"}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { tool } from 'ai';
|
|
2
2
|
import { HistogramChartSettings, MIN_BINS_COUNT, MAX_BINS_COUNT, DEFAULT_BINS_COUNT, } from './schema';
|
|
3
|
-
import {
|
|
4
|
-
import { validateColumnExists } from '../../../ai/tool-validation';
|
|
3
|
+
import { BaseChartToolInput } from '../../../ai/tool-schemas';
|
|
5
4
|
import { QUANTITATIVE_COLUMN_TYPES } from '../../../column-types-utils';
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { validateHistogramSettings } from './validation';
|
|
6
|
+
import { ensureTable } from '../../../ai/tool-helpers';
|
|
7
|
+
/**
|
|
8
|
+
* Input schema for the histogram chart tool.
|
|
9
|
+
* Extends base chart input with histogram-specific settings including field and bin configuration.
|
|
10
|
+
*/
|
|
11
|
+
export const HistogramToolInput = BaseChartToolInput.extend({
|
|
8
12
|
settings: HistogramChartSettings.required(),
|
|
9
13
|
});
|
|
10
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates an AI tool for generating histogram charts.
|
|
16
|
+
* Histograms show distribution of numeric values by grouping data into bins/ranges.
|
|
17
|
+
*
|
|
18
|
+
* @param params - Chart tool parameters
|
|
19
|
+
* @param params.databaseAdapter - Database adapter for table and column validation
|
|
20
|
+
* @param params.addChart - Function to add the generated chart to the target artifact
|
|
21
|
+
* @returns AI tool instance for histogram chart creation
|
|
22
|
+
*/
|
|
23
|
+
export function createHistogramAiTool({ databaseAdapter, addChart, }) {
|
|
11
24
|
return tool({
|
|
12
25
|
description: `Histogram: shows distribution of numeric values by automatically grouping data into bins/ranges.
|
|
13
26
|
|
|
@@ -18,45 +31,38 @@ Required: field must be quantitative not text/categorical: (${QUANTITATIVE_COLUM
|
|
|
18
31
|
|
|
19
32
|
NOTE: Histograms automatically bin data into ranges and aggregate counts, so they handle large datasets efficiently (no data point limit).
|
|
20
33
|
|
|
21
|
-
To UPDATE an existing histogram: provide the panelId parameter. Otherwise creates new panel.
|
|
22
|
-
|
|
23
34
|
Optional: maxBins (${MIN_BINS_COUNT}-${MAX_BINS_COUNT}, default ${DEFAULT_BINS_COUNT}) controls the number of bins/bars in the histogram. Use fewer bins for coarse overview, more bins for detailed distribution.
|
|
24
35
|
|
|
25
36
|
CRITICAL: Only for quantitative continuous data to see distribution shape, outliers, skewness.
|
|
26
37
|
Do NOT use for: categorical data (use count-plot), relationships between columns (use scatter-plot), time series trends (use line-chart).`,
|
|
27
|
-
inputSchema:
|
|
28
|
-
execute: async (
|
|
38
|
+
inputSchema: HistogramToolInput,
|
|
39
|
+
execute: async ({ tableName, settings, title, panelId }) => {
|
|
29
40
|
try {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const dataTable = ensureTable(databaseAdapter, tableName);
|
|
42
|
+
validateHistogramSettings({
|
|
43
|
+
dataTable,
|
|
44
|
+
settings,
|
|
45
|
+
});
|
|
46
|
+
const chartConfig = {
|
|
47
|
+
chartType: 'histogram',
|
|
48
|
+
settings,
|
|
49
|
+
};
|
|
50
|
+
await addChart({
|
|
37
51
|
tableName,
|
|
38
|
-
|
|
39
|
-
config:
|
|
40
|
-
|
|
41
|
-
settings: params.settings,
|
|
42
|
-
},
|
|
52
|
+
panelId,
|
|
53
|
+
config: chartConfig,
|
|
54
|
+
title,
|
|
43
55
|
});
|
|
44
56
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
? `Updated histogram "${result.title}".`
|
|
49
|
-
: `Created histogram "${result.title}".`,
|
|
50
|
-
data: result,
|
|
51
|
-
},
|
|
57
|
+
success: true,
|
|
58
|
+
details: `Generated histogram configuration for "${settings.field}".`,
|
|
59
|
+
data: chartConfig,
|
|
52
60
|
};
|
|
53
61
|
}
|
|
54
62
|
catch (error) {
|
|
55
63
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
errorMessage: error instanceof Error ? error.message : String(error),
|
|
59
|
-
},
|
|
64
|
+
success: false,
|
|
65
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAExB,OAAO,EAEL,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAC,yBAAyB,EAAC,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAC1D,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAOH;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,eAAe,EACf,QAAQ,GACQ;IAChB,OAAO,IAAI,CAA4D;QACrE,WAAW,EAAE;;;;;8DAK6C,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;;;;qBAI7E,cAAc,IAAI,cAAc,aAAa,kBAAkB;;;0IAGsD;QACtI,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,KAAK,EAAE,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAC,EAAE,EAAE;YACvD,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,WAAW,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;gBAE1D,yBAAyB,CAAC;oBACxB,SAAS;oBACT,QAAQ;iBACT,CAAC,CAAC;gBAEH,MAAM,WAAW,GAAyB;oBACxC,SAAS,EAAE,WAAoB;oBAC/B,QAAQ;iBACT,CAAC;gBAEF,MAAM,QAAQ,CAAC;oBACb,SAAS;oBACT,OAAO;oBACP,MAAM,EAAE,WAAW;oBACnB,KAAK;iBACN,CAAC,CAAC;gBAEH,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,0CAA0C,QAAQ,CAAC,KAAK,IAAI;oBACrE,IAAI,EAAE,WAAW;iBAClB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,YAAY,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBACrE,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {tool} from 'ai';\nimport {z} from 'zod';\nimport {\n HistogramChartConfig,\n HistogramChartSettings,\n MIN_BINS_COUNT,\n MAX_BINS_COUNT,\n DEFAULT_BINS_COUNT,\n} from './schema';\nimport {BaseChartToolInput} from '../../../ai/tool-schemas';\nimport {QUANTITATIVE_COLUMN_TYPES} from '../../../column-types-utils';\nimport {ChartToolParams, ChartToolOutput} from '../tool-types';\nimport {validateHistogramSettings} from './validation';\nimport {ensureTable} from '../../../ai/tool-helpers';\n\n/**\n * Input schema for the histogram chart tool.\n * Extends base chart input with histogram-specific settings including field and bin configuration.\n */\nexport const HistogramToolInput = BaseChartToolInput.extend({\n settings: HistogramChartSettings.required(),\n});\n\n/**\n * Type representing validated input for histogram chart creation.\n */\nexport type HistogramToolInput = z.infer<typeof HistogramToolInput>;\n\n/**\n * Creates an AI tool for generating histogram charts.\n * Histograms show distribution of numeric values by grouping data into bins/ranges.\n *\n * @param params - Chart tool parameters\n * @param params.databaseAdapter - Database adapter for table and column validation\n * @param params.addChart - Function to add the generated chart to the target artifact\n * @returns AI tool instance for histogram chart creation\n */\nexport function createHistogramAiTool({\n databaseAdapter,\n addChart,\n}: ChartToolParams) {\n return tool<HistogramToolInput, ChartToolOutput<HistogramChartConfig>>({\n description: `Histogram: shows distribution of numeric values by automatically grouping data into bins/ranges.\n\nUse when: user asks about \"distribution of [numeric column]\", \"spread of\", \"range of\", \"how values are distributed\", \"show histogram\".\nExample queries: \"distribution of population density\", \"show elevation distribution\", \"histogram of parcel areas\", \"how are building heights spread\", \"temperature range distribution\".\n\nRequired: field must be quantitative not text/categorical: (${QUANTITATIVE_COLUMN_TYPES.join(', ')}).\n\nNOTE: Histograms automatically bin data into ranges and aggregate counts, so they handle large datasets efficiently (no data point limit).\n\nOptional: maxBins (${MIN_BINS_COUNT}-${MAX_BINS_COUNT}, default ${DEFAULT_BINS_COUNT}) controls the number of bins/bars in the histogram. Use fewer bins for coarse overview, more bins for detailed distribution.\n\nCRITICAL: Only for quantitative continuous data to see distribution shape, outliers, skewness.\nDo NOT use for: categorical data (use count-plot), relationships between columns (use scatter-plot), time series trends (use line-chart).`,\n inputSchema: HistogramToolInput,\n execute: async ({tableName, settings, title, panelId}) => {\n try {\n const dataTable = ensureTable(databaseAdapter, tableName);\n\n validateHistogramSettings({\n dataTable,\n settings,\n });\n\n const chartConfig: HistogramChartConfig = {\n chartType: 'histogram' as const,\n settings,\n };\n\n await addChart({\n tableName,\n panelId,\n config: chartConfig,\n title,\n });\n\n return {\n success: true,\n details: `Generated histogram configuration for \"${settings.field}\".`,\n data: chartConfig,\n };\n } catch (error) {\n return {\n success: false,\n errorMessage: error instanceof Error ? error.message : String(error),\n };\n }\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HistogramChartSettings } from './schema';
|
|
2
|
+
import { ValidateSpecOptions } from '../base-types';
|
|
3
|
+
import { TableColumn } from '@sqlrooms/duckdb';
|
|
4
|
+
export type ValidatedHistogramSettings = {
|
|
5
|
+
fieldColumn: TableColumn;
|
|
6
|
+
maxBins: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function validateHistogramSettings({ dataTable, settings: { field, maxBins }, }: ValidateSpecOptions<HistogramChartSettings>): ValidatedHistogramSettings;
|
|
9
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAqB,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAOlD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EACxC,SAAS,EACT,QAAQ,EAAE,EAAC,KAAK,EAAE,OAA4B,EAAC,GAChD,EAAE,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,0BAA0B,CAqB1E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DEFAULT_BINS_COUNT } from './schema';
|
|
2
|
+
import { InvalidColumnTypeError, MissingColumnsError, RequiredFieldsError, } from '../errors';
|
|
3
|
+
import { isQuantitativeType } from '../../../column-types-utils';
|
|
4
|
+
export function validateHistogramSettings({ dataTable, settings: { field, maxBins = DEFAULT_BINS_COUNT }, }) {
|
|
5
|
+
// Basic validation for required fields
|
|
6
|
+
if (!field) {
|
|
7
|
+
throw new RequiredFieldsError('Field');
|
|
8
|
+
}
|
|
9
|
+
// Validate field existence and type
|
|
10
|
+
const fieldColumn = dataTable.columns.find((col) => col.name === field);
|
|
11
|
+
if (!fieldColumn) {
|
|
12
|
+
throw new MissingColumnsError(field);
|
|
13
|
+
}
|
|
14
|
+
if (!isQuantitativeType(fieldColumn.type)) {
|
|
15
|
+
throw new InvalidColumnTypeError(fieldColumn.name, 'quantitative');
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
fieldColumn,
|
|
19
|
+
maxBins,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/histogram/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAEpE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAQ/D,MAAM,UAAU,yBAAyB,CAAC,EACxC,SAAS,EACT,QAAQ,EAAE,EAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,EAAC,GACH;IAC5C,uCAAuC;IACvC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,oCAAoC;IACpC,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;IAExE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,sBAAsB,CAAC,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {HistogramChartSettings, DEFAULT_BINS_COUNT} from './schema';\nimport {ValidateSpecOptions} from '../base-types';\nimport {\n InvalidColumnTypeError,\n MissingColumnsError,\n RequiredFieldsError,\n} from '../errors';\nimport {isQuantitativeType} from '../../../column-types-utils';\nimport {TableColumn} from '@sqlrooms/duckdb';\n\nexport type ValidatedHistogramSettings = {\n fieldColumn: TableColumn;\n maxBins: number;\n};\n\nexport function validateHistogramSettings({\n dataTable,\n settings: {field, maxBins = DEFAULT_BINS_COUNT},\n}: ValidateSpecOptions<HistogramChartSettings>): ValidatedHistogramSettings {\n // Basic validation for required fields\n if (!field) {\n throw new RequiredFieldsError('Field');\n }\n\n // Validate field existence and type\n const fieldColumn = dataTable.columns.find((col) => col.name === field);\n\n if (!fieldColumn) {\n throw new MissingColumnsError(field);\n }\n\n if (!isQuantitativeType(fieldColumn.type)) {\n throw new InvalidColumnTypeError(fieldColumn.name, 'quantitative');\n }\n\n return {\n fieldColumn,\n maxBins,\n };\n}\n"]}
|
|
@@ -23,19 +23,13 @@ export * from './heatmap/definition';
|
|
|
23
23
|
export * from './box-plot/definition';
|
|
24
24
|
export * from './scatter-plot/definition';
|
|
25
25
|
export * from './custom-spec/definition';
|
|
26
|
-
export * from '
|
|
27
|
-
export * from '../../ai/tool-schemas';
|
|
28
|
-
export * from '../../ai/tool-validation';
|
|
29
|
-
export * from '../../ai/tool-helpers';
|
|
26
|
+
export * from './tool-types';
|
|
30
27
|
export * from './histogram/tool';
|
|
31
28
|
export * from './line-chart/tool';
|
|
32
29
|
export * from './count-plot/tool';
|
|
33
30
|
export * from './heatmap/tool';
|
|
34
31
|
export * from './scatter-plot/tool';
|
|
35
32
|
export * from './box-plot/tool';
|
|
36
|
-
export * from '../../ai/data-table-explorer-tool';
|
|
37
|
-
export * from '../../ai/list-panels-tool';
|
|
38
|
-
export * from '../../ai/remove-panel-tool';
|
|
39
33
|
export { mosaicChartTypes } from './mosaicChartTypes';
|
|
40
34
|
export { createDefaultChartTypes } from './createDefaultChartTypes';
|
|
41
35
|
export { createChartTools } from './createChartTools';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/charts/chart-types/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,UAAU,CAAC;AAMzB,OAAO,EAAC,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC/E,cAAc,sBAAsB,CAAC;AAGrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAC,0BAA0B,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAG7E,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/charts/chart-types/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,UAAU,CAAC;AAMzB,OAAO,EAAC,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC/E,cAAc,sBAAsB,CAAC;AAGrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAC,0BAA0B,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAG7E,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC"}
|
|
@@ -32,20 +32,14 @@ export * from './heatmap/definition';
|
|
|
32
32
|
export * from './box-plot/definition';
|
|
33
33
|
export * from './scatter-plot/definition';
|
|
34
34
|
export * from './custom-spec/definition';
|
|
35
|
-
// Re-export tool types
|
|
36
|
-
export * from '
|
|
37
|
-
export * from '../../ai/tool-schemas';
|
|
38
|
-
export * from '../../ai/tool-validation';
|
|
39
|
-
export * from '../../ai/tool-helpers';
|
|
35
|
+
// Re-export tool types and schemas
|
|
36
|
+
export * from './tool-types';
|
|
40
37
|
export * from './histogram/tool';
|
|
41
38
|
export * from './line-chart/tool';
|
|
42
39
|
export * from './count-plot/tool';
|
|
43
40
|
export * from './heatmap/tool';
|
|
44
41
|
export * from './scatter-plot/tool';
|
|
45
42
|
export * from './box-plot/tool';
|
|
46
|
-
export * from '../../ai/data-table-explorer-tool';
|
|
47
|
-
export * from '../../ai/list-panels-tool';
|
|
48
|
-
export * from '../../ai/remove-panel-tool';
|
|
49
43
|
// Re-export chart type utilities
|
|
50
44
|
export { mosaicChartTypes } from './mosaicChartTypes';
|
|
51
45
|
export { createDefaultChartTypes } from './createDefaultChartTypes';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/charts/chart-types/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,cAAc,cAAc,CAAC;AAE7B,gDAAgD;AAChD,cAAc,UAAU,CAAC;AAEzB,2EAA2E;AAC3E,uEAAuE;AACvE,qFAAqF;AACrF,6BAA6B;AAC7B,OAAO,EAAC,WAAW,EAAqC,MAAM,gBAAgB,CAAC;AAC/E,cAAc,sBAAsB,CAAC;AAErC,oBAAoB;AACpB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,gCAAgC;AAChC,OAAO,EAAC,0BAA0B,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAE7E,wBAAwB;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/charts/chart-types/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,cAAc,cAAc,CAAC;AAE7B,gDAAgD;AAChD,cAAc,UAAU,CAAC;AAEzB,2EAA2E;AAC3E,uEAAuE;AACvE,qFAAqF;AACrF,6BAA6B;AAC7B,OAAO,EAAC,WAAW,EAAqC,MAAM,gBAAgB,CAAC;AAC/E,cAAc,sBAAsB,CAAC;AAErC,oBAAoB;AACpB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,gCAAgC;AAChC,OAAO,EAAC,0BAA0B,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,0BAA0B,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAE7E,wBAAwB;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAEzC,mCAAmC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,iCAAiC;AACjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC","sourcesContent":["// Re-export base types\nexport * from './base-types';\n\n// Re-export error classes for chart definitions\nexport * from './errors';\n\n// CRITICAL: Export ChartConfig FIRST, before importing Settings components\n// Export ChartConfig from separate file to avoid circular dependencies\n// (chart-types/index imports Settings components, which import ChartSettingsContext,\n// which imports ChartConfig)\nexport {ChartConfig, type ChartSettings, type ChartType} from './chart-config';\nexport * from './data-policy-schema';\n\n// Re-export schemas\nexport * from './histogram/schema';\nexport * from './line-chart/schema';\nexport * from './count-plot/schema';\nexport * from './heatmap/schema';\nexport * from './box-plot/schema';\nexport * from './scatter-plot/schema';\nexport * from './custom-spec/schema';\n\n// Re-export Settings components\nexport {HistogramSettingsComponent} from './histogram/HistogramSettings';\nexport {LineChartSettingsComponent} from './line-chart/LineChartSettings';\nexport {CountPlotSettingsComponent} from './count-plot/CountPlotSettings';\nexport {HeatmapSettingsComponent} from './heatmap/HeatmapSettings';\nexport {BoxPlotSettingsComponent} from './box-plot/BoxPlotSettings';\nexport {ScatterPlotSettingsComponent} from './scatter-plot/ScatterPlotSettings';\nexport {CustomSpecSettingsComponent} from './custom-spec/CustomSpecSettings';\n\n// Re-export definitions\nexport * from './histogram/definition';\nexport * from './line-chart/definition';\nexport * from './count-plot/definition';\nexport * from './heatmap/definition';\nexport * from './box-plot/definition';\nexport * from './scatter-plot/definition';\nexport * from './custom-spec/definition';\n\n// Re-export tool types and schemas\nexport * from './tool-types';\nexport * from './histogram/tool';\nexport * from './line-chart/tool';\nexport * from './count-plot/tool';\nexport * from './heatmap/tool';\nexport * from './scatter-plot/tool';\nexport * from './box-plot/tool';\n\n// Re-export chart type utilities\nexport {mosaicChartTypes} from './mosaicChartTypes';\nexport {createDefaultChartTypes} from './createDefaultChartTypes';\nexport {createChartTools} from './createChartTools';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAoB,MAAM,UAAU,CAAC;AAU5D,eAAO,MAAM,kBAAkB,EAAE,uBAAuB,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAoB,MAAM,UAAU,CAAC;AAU5D,eAAO,MAAM,kBAAkB,EAAE,uBAAuB,CAAC,eAAe,CAmBvE,CAAC"}
|
|
@@ -10,6 +10,7 @@ export const lineChartChartType = {
|
|
|
10
10
|
id: 'line-chart',
|
|
11
11
|
label: 'Line Chart',
|
|
12
12
|
description: DESCRIPTION,
|
|
13
|
+
aiDescription: `${DESCRIPTION} - trends over time or ordered variable (use with aggregations for >10k rows)`,
|
|
13
14
|
icon: LineChart,
|
|
14
15
|
schema: LineChartSettings,
|
|
15
16
|
settingsComponent: LineChartSettingsComponent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAA6C;IAC1E,EAAE,EAAE,YAAY;IAChB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,iBAAiB;IACzB,iBAAiB,EAAE,0BAA0B;IAC7C,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB;IACjC,aAAa,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAC1B,MAAM,CAAC,QAAQ,CAAC,SAAS;QACvB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC;YACE,OAAO,EAAE,6BAA6B;YACtC,MAAM,EACJ,sHAAsH;SACzH;IACP,UAAU,EAAE,mBAAmB;CAChC,CAAC","sourcesContent":["import type {SpecChartTypeDefinition} from '../base-types';\nimport {LineChartConfig, LineChartSettings} from './schema';\nimport {titleFromDescription} from '../../../chart-builders/chartTypeUtils';\nimport {LineChartSettingsComponent} from './LineChartSettings';\nimport {createLineChartAiTool} from './tool';\nimport {LineChart} from 'lucide-react';\nimport {createLineChartSpec} from './spec';\nimport {DEFAULT_CHART_MAX_DATA_POINTS} from '../../../chart-runtime';\n\nconst DESCRIPTION = 'Create a line chart of two fields';\n\nexport const lineChartChartType: SpecChartTypeDefinition<LineChartConfig> = {\n id: 'line-chart',\n label: 'Line Chart',\n description: DESCRIPTION,\n icon: LineChart,\n schema: LineChartSettings,\n settingsComponent: LineChartSettingsComponent,\n buildTitle: titleFromDescription(DESCRIPTION),\n createTool: createLineChartAiTool,\n getDataPolicy: ({config}) =>\n config.settings.xInterval\n ? null\n : {\n maxRows: DEFAULT_CHART_MAX_DATA_POINTS,\n reason:\n 'Unaggregated line charts render source rows. Add a temporal interval or use an aggregated chart for larger datasets.',\n },\n createSpec: createLineChartSpec,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAA6C;IAC1E,EAAE,EAAE,YAAY;IAChB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,GAAG,WAAW,+EAA+E;IAC5G,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,iBAAiB;IACzB,iBAAiB,EAAE,0BAA0B;IAC7C,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC7C,UAAU,EAAE,qBAAqB;IACjC,aAAa,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAC1B,MAAM,CAAC,QAAQ,CAAC,SAAS;QACvB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC;YACE,OAAO,EAAE,6BAA6B;YACtC,MAAM,EACJ,sHAAsH;SACzH;IACP,UAAU,EAAE,mBAAmB;CAChC,CAAC","sourcesContent":["import type {SpecChartTypeDefinition} from '../base-types';\nimport {LineChartConfig, LineChartSettings} from './schema';\nimport {titleFromDescription} from '../../../chart-builders/chartTypeUtils';\nimport {LineChartSettingsComponent} from './LineChartSettings';\nimport {createLineChartAiTool} from './tool';\nimport {LineChart} from 'lucide-react';\nimport {createLineChartSpec} from './spec';\nimport {DEFAULT_CHART_MAX_DATA_POINTS} from '../../../chart-runtime';\n\nconst DESCRIPTION = 'Create a line chart of two fields';\n\nexport const lineChartChartType: SpecChartTypeDefinition<LineChartConfig> = {\n id: 'line-chart',\n label: 'Line Chart',\n description: DESCRIPTION,\n aiDescription: `${DESCRIPTION} - trends over time or ordered variable (use with aggregations for >10k rows)`,\n icon: LineChart,\n schema: LineChartSettings,\n settingsComponent: LineChartSettingsComponent,\n buildTitle: titleFromDescription(DESCRIPTION),\n createTool: createLineChartAiTool,\n getDataPolicy: ({config}) =>\n config.settings.xInterval\n ? null\n : {\n maxRows: DEFAULT_CHART_MAX_DATA_POINTS,\n reason:\n 'Unaggregated line charts render source rows. Add a temporal interval or use an aggregated chart for larger datasets.',\n },\n createSpec: createLineChartSpec,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAC,iBAAiB,EAAyB,MAAM,eAAe,CAAC;AAcxE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,GAC5C,IAAI,CAsFN"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isTemporalType } from '../../../column-types-utils';
|
|
2
2
|
import { getChartTableReference } from '../base-types';
|
|
3
|
-
import { isNumericType, isQuantitativeType, isTemporalType, } from '../../../column-types-utils';
|
|
4
3
|
import { DEFAULT_CHART_FALLBACK_COLOR } from '../../../constants/chart-colors';
|
|
4
|
+
import { validateLineChartSettings } from './validation';
|
|
5
5
|
function getLegendLabel(yColumn, hasAggregation) {
|
|
6
6
|
if (hasAggregation && yColumn.aggregate) {
|
|
7
7
|
return `${yColumn.field} (${yColumn.aggregate.toUpperCase()})`;
|
|
@@ -19,9 +19,7 @@ export function createLineChartSpec(options) {
|
|
|
19
19
|
filterBy: '$brush',
|
|
20
20
|
};
|
|
21
21
|
// Generate lineY marks for each Y field
|
|
22
|
-
yColumns.forEach((
|
|
23
|
-
const color = yColumn.color ?? DEFAULT_CHART_FALLBACK_COLOR;
|
|
24
|
-
const aggregate = yColumn.aggregate ?? 'sum';
|
|
22
|
+
yColumns.forEach(({ color, column, aggregate }) => {
|
|
25
23
|
// When temporal aggregation is active, use bin for X and aggregation for Y
|
|
26
24
|
if (isXTemporal && xInterval) {
|
|
27
25
|
// Use bin syntax for temporal aggregation
|
|
@@ -29,7 +27,7 @@ export function createLineChartSpec(options) {
|
|
|
29
27
|
mark: 'lineY',
|
|
30
28
|
data: dataSource,
|
|
31
29
|
x: { bin: xColumn.name, interval: xInterval },
|
|
32
|
-
y: { [aggregate]:
|
|
30
|
+
y: { [aggregate]: column.name },
|
|
33
31
|
stroke: color,
|
|
34
32
|
});
|
|
35
33
|
}
|
|
@@ -39,7 +37,7 @@ export function createLineChartSpec(options) {
|
|
|
39
37
|
mark: 'lineY',
|
|
40
38
|
data: dataSource,
|
|
41
39
|
x: xColumn.name,
|
|
42
|
-
y:
|
|
40
|
+
y: column.name,
|
|
43
41
|
stroke: color,
|
|
44
42
|
});
|
|
45
43
|
}
|
|
@@ -81,43 +79,4 @@ export function createLineChartSpec(options) {
|
|
|
81
79
|
params: { brush: { select: 'crossfilter' } },
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
|
-
function validateLineChartSettings({ dataTable, settings: { x, yFields = [], xInterval }, }) {
|
|
85
|
-
// Basic validation for required fields
|
|
86
|
-
if (!x || yFields.length === 0) {
|
|
87
|
-
throw new RequiredFieldsError([
|
|
88
|
-
...(x ? [] : ['X-axis']),
|
|
89
|
-
...(yFields.length > 0 ? [] : ['Y-axis']),
|
|
90
|
-
]);
|
|
91
|
-
}
|
|
92
|
-
// Validate X and Y field existence
|
|
93
|
-
const xColumn = dataTable.columns.find((col) => col.name === x);
|
|
94
|
-
const yColumns = yFields.map((y) => ({
|
|
95
|
-
field: y.field,
|
|
96
|
-
column: dataTable.columns.find((col) => col.name === y.field),
|
|
97
|
-
aggregate: y.aggregate,
|
|
98
|
-
color: y.color,
|
|
99
|
-
}));
|
|
100
|
-
const missingYColumns = yColumns.filter((y) => !y.column);
|
|
101
|
-
if (!xColumn || missingYColumns.length > 0) {
|
|
102
|
-
throw new MissingColumnsError([
|
|
103
|
-
...(xColumn ? [] : ['X-axis']),
|
|
104
|
-
...missingYColumns.map((y) => y.field),
|
|
105
|
-
]);
|
|
106
|
-
}
|
|
107
|
-
// Validate X and Y field types
|
|
108
|
-
if (!isQuantitativeType(xColumn.type)) {
|
|
109
|
-
throw new InvalidColumnTypeError(xColumn.name, 'quantitative');
|
|
110
|
-
}
|
|
111
|
-
const invalidYFields = yColumns.filter((y) => {
|
|
112
|
-
return y.column && !isNumericType(y.column.type);
|
|
113
|
-
});
|
|
114
|
-
if (invalidYFields.length > 0) {
|
|
115
|
-
throw new InvalidColumnTypeError(invalidYFields.map(({ field }) => field), 'numeric');
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
xColumn,
|
|
119
|
-
yColumns,
|
|
120
|
-
xInterval,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
82
|
//# sourceMappingURL=spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/spec.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/charts/chart-types/line-chart/spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAoB,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACxE,OAAO,EAAC,4BAA4B,EAAC,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAC,yBAAyB,EAAC,MAAM,cAAc,CAAC;AAEvD,SAAS,cAAc,CACrB,OAAuD,EACvD,cAAuB;IAEvB,IAAI,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACxC,OAAO,GAAG,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAA6C;IAE7C,MAAM,EAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC;IAErD,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAE1E,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,SAAS,GAAc,EAAE,CAAC;IAEhC,iDAAiD;IACjD,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC;QACvC,QAAQ,EAAE,QAAQ;KACnB,CAAC;IAEF,wCAAwC;IACxC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAC,EAAE,EAAE;QAC9C,2EAA2E;QAC3E,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;YAC7B,0CAA0C;YAC1C,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,UAAU;gBAChB,CAAC,EAAE,EAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC;gBAC3C,CAAC,EAAE,EAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,EAAC;gBAC7B,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,2CAA2C;YAC3C,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,UAAU;gBAChB,CAAC,EAAE,OAAO,CAAC,IAAI;gBACf,CAAC,EAAE,MAAM,CAAC,IAAI;gBACd,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,sDAAsD;IACtD,IAAI,aAAa,EAAE,CAAC;QAClB,SAAS,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAC,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,IAAI,CAAC;IAE/C,MAAM,QAAQ,GAAG;QACf,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,OAAO,CAAC,IAAI;QACpB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,GAAG,EAAE,EAAE;YACP,MAAM,EAAE,EAAE;SACX;QACD,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACpC,cAAc,CACZ,EAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAC,EAC1D,OAAO,CAAC,WAAW,IAAI,SAAS,CAAC,CAClC,CACF;QACD,UAAU,EAAE,QAAQ,CAAC,GAAG,CACtB,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,4BAA4B,CAC3D;KACF,CAAC;IAEF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;YACL,GAAG,QAAQ;YACX,MAAM,EAAE,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAC;SACjC,CAAC;IACZ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,QAAQ;YACR;gBACE,MAAM,EAAE,OAAO;gBACf,GAAG,EAAE,WAAW;gBAChB,OAAO,EAAE,QAAQ,CAAC,MAAM;aACzB;SACF;QACD,MAAM,EAAE,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAC;KACjC,CAAC;AACZ,CAAC","sourcesContent":["import type {Spec} from '@uwdata/mosaic-spec';\nimport {LineChartSettings} from './schema';\nimport {isTemporalType} from '../../../column-types-utils';\nimport {AggregateFunction} from '../../../schemas';\nimport {CreateSpecOptions, getChartTableReference} from '../base-types';\nimport {DEFAULT_CHART_FALLBACK_COLOR} from '../../../constants/chart-colors';\nimport {validateLineChartSettings} from './validation';\n\nfunction getLegendLabel(\n yColumn: {field: string; aggregate?: AggregateFunction},\n hasAggregation: boolean,\n): string {\n if (hasAggregation && yColumn.aggregate) {\n return `${yColumn.field} (${yColumn.aggregate.toUpperCase()})`;\n }\n return yColumn.field;\n}\n\nexport function createLineChartSpec(\n options: CreateSpecOptions<LineChartSettings>,\n): Spec {\n const {dataTable, selectionName, settings} = options;\n\n const {xColumn, yColumns, xInterval} = validateLineChartSettings(options);\n\n const isXTemporal = isTemporalType(xColumn.type);\n\n const plotMarks: unknown[] = [];\n\n // Data source always includes filterBy for brush\n const dataSource = {\n from: getChartTableReference(dataTable),\n filterBy: '$brush',\n };\n\n // Generate lineY marks for each Y field\n yColumns.forEach(({color, column, aggregate}) => {\n // When temporal aggregation is active, use bin for X and aggregation for Y\n if (isXTemporal && xInterval) {\n // Use bin syntax for temporal aggregation\n plotMarks.push({\n mark: 'lineY',\n data: dataSource,\n x: {bin: xColumn.name, interval: xInterval},\n y: {[aggregate]: column.name},\n stroke: color,\n });\n } else {\n // No aggregation - direct field references\n plotMarks.push({\n mark: 'lineY',\n data: dataSource,\n x: xColumn.name,\n y: column.name,\n stroke: color,\n });\n }\n });\n\n // Add brush control only if selectionName is provided\n if (selectionName) {\n plotMarks.push({select: 'intervalX', as: '$brush'});\n }\n\n const showLegend = settings.showLegend ?? true;\n\n const plotSpec = {\n plot: plotMarks,\n name: 'lineChart',\n xLabel: xColumn.name,\n yLabel: undefined,\n margins: {\n left: 50,\n right: 20,\n top: 20,\n bottom: 50,\n },\n colorDomain: yColumns.map((yColumn) =>\n getLegendLabel(\n {field: yColumn.column.name, aggregate: yColumn.aggregate},\n Boolean(isXTemporal && xInterval),\n ),\n ),\n colorRange: yColumns.map(\n (yColumn) => yColumn.color ?? DEFAULT_CHART_FALLBACK_COLOR,\n ),\n };\n\n if (!showLegend) {\n return {\n ...plotSpec,\n params: {brush: {select: 'crossfilter'}},\n } as Spec;\n }\n\n return {\n vconcat: [\n plotSpec,\n {\n legend: 'color',\n for: 'lineChart',\n columns: yColumns.length,\n },\n ],\n params: {brush: {select: 'crossfilter'}},\n } as Spec;\n}\n"]}
|