@syncfusion/react-grid-chart 35.1.37
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 +136 -0
- package/grid-chart.d.ts +4 -0
- package/grid-chart.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +13 -0
- package/package.json +37 -0
- package/src/grid-chart/components/ColorPicker.d.ts +30 -0
- package/src/grid-chart/components/ColorPicker.js +39 -0
- package/src/grid-chart/components/index.d.ts +1 -0
- package/src/grid-chart/components/index.js +1 -0
- package/src/grid-chart/contexts/GridChartContext.d.ts +64 -0
- package/src/grid-chart/contexts/GridChartContext.js +140 -0
- package/src/grid-chart/contexts/index.d.ts +1 -0
- package/src/grid-chart/contexts/index.js +1 -0
- package/src/grid-chart/index.d.ts +5 -0
- package/src/grid-chart/index.js +5 -0
- package/src/grid-chart/types/grid-chart.interfaces.d.ts +1066 -0
- package/src/grid-chart/types/grid-chart.interfaces.js +1 -0
- package/src/grid-chart/types/index.d.ts +1 -0
- package/src/grid-chart/types/index.js +1 -0
- package/src/grid-chart/utils/index.d.ts +1 -0
- package/src/grid-chart/utils/index.js +1 -0
- package/src/grid-chart/utils/utils.d.ts +52 -0
- package/src/grid-chart/utils/utils.js +73 -0
- package/src/grid-chart/views/ChartPanel.d.ts +13 -0
- package/src/grid-chart/views/ChartPanel.js +67 -0
- package/src/grid-chart/views/ChartTab.d.ts +15 -0
- package/src/grid-chart/views/ChartTab.js +91 -0
- package/src/grid-chart/views/DataTab.d.ts +17 -0
- package/src/grid-chart/views/DataTab.js +77 -0
- package/src/grid-chart/views/ExportPanel.d.ts +15 -0
- package/src/grid-chart/views/ExportPanel.js +75 -0
- package/src/grid-chart/views/FormatTab.d.ts +20 -0
- package/src/grid-chart/views/FormatTab.js +135 -0
- package/src/grid-chart/views/GridChart.d.ts +42 -0
- package/src/grid-chart/views/GridChart.js +66 -0
- package/src/grid-chart/views/GridChartPanel.d.ts +13 -0
- package/src/grid-chart/views/GridChartPanel.js +35 -0
- package/src/grid-chart/views/PropertyPanel.d.ts +16 -0
- package/src/grid-chart/views/PropertyPanel.js +22 -0
- package/src/grid-chart/views/index.d.ts +8 -0
- package/src/grid-chart/views/index.js +8 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/styles/material.css +0 -0
- package/styles/material.scss +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './grid-chart.interfaces';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './grid-chart.interfaces';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ElementType, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartInfo, ChartType } from '../types/grid-chart.interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves chart metadata and classification information.
|
|
5
|
+
* Determines whether the chart is a regular chart or pie chart.
|
|
6
|
+
*
|
|
7
|
+
* @param {ChartType} chart - The chart type to analyze
|
|
8
|
+
* @returns {ChartInfo} Chart metadata including type, isChart flag, and isPieChart flag
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const chartInfo = getChartInfo('Column');
|
|
13
|
+
* // Returns: { chart: 'Column', isChart: true, isPieChart: false }
|
|
14
|
+
*
|
|
15
|
+
* const pieInfo = getChartInfo('Pie');
|
|
16
|
+
* // Returns: { chart: 'Pie', isChart: false, isPieChart: true }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getChartInfo(chart: ChartType): ChartInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Recursively searches React children for an element of a specific type.
|
|
22
|
+
* Useful for finding nested components in the React element tree.
|
|
23
|
+
*
|
|
24
|
+
* @param {ReactNode} children - The React children to search through
|
|
25
|
+
* @param {ElementType} targetType - The element type to find (e.g., a component class or function)
|
|
26
|
+
* @returns {ReactElement | null} The first matching element found, or null if not found
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Find a Dialog component in children
|
|
31
|
+
* const dialogElement = findElement(children, Dialog);
|
|
32
|
+
* if (dialogElement) {
|
|
33
|
+
* // Process dialog element
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function findElement(children: ReactNode, targetType: ElementType): ReactElement | null;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves a font family name to a usable CSS value.
|
|
40
|
+
* Converts the 'Default' placeholder to an empty string, allowing CSS to use system defaults.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} fontFamily - The font family name ('Default', 'Arial', 'Georgia', etc.)
|
|
43
|
+
* @returns {string} The resolved font family CSS value, or empty string if 'Default'
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* resolveFontFamily('Arial'); // Returns: 'Arial'
|
|
48
|
+
* resolveFontFamily('Default'); // Returns: ''
|
|
49
|
+
* resolveFontFamily('Times New Roman'); // Returns: 'Times New Roman'
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveFontFamily(fontFamily: string): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Children, isValidElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves chart metadata and classification information.
|
|
4
|
+
* Determines whether the chart is a regular chart or pie chart.
|
|
5
|
+
*
|
|
6
|
+
* @param {ChartType} chart - The chart type to analyze
|
|
7
|
+
* @returns {ChartInfo} Chart metadata including type, isChart flag, and isPieChart flag
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const chartInfo = getChartInfo('Column');
|
|
12
|
+
* // Returns: { chart: 'Column', isChart: true, isPieChart: false }
|
|
13
|
+
*
|
|
14
|
+
* const pieInfo = getChartInfo('Pie');
|
|
15
|
+
* // Returns: { chart: 'Pie', isChart: false, isPieChart: true }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function getChartInfo(chart) {
|
|
19
|
+
return {
|
|
20
|
+
chart,
|
|
21
|
+
isChart: chart !== 'Pie',
|
|
22
|
+
isPieChart: chart === 'Pie'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Recursively searches React children for an element of a specific type.
|
|
27
|
+
* Useful for finding nested components in the React element tree.
|
|
28
|
+
*
|
|
29
|
+
* @param {ReactNode} children - The React children to search through
|
|
30
|
+
* @param {ElementType} targetType - The element type to find (e.g., a component class or function)
|
|
31
|
+
* @returns {ReactElement | null} The first matching element found, or null if not found
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* // Find a Dialog component in children
|
|
36
|
+
* const dialogElement = findElement(children, Dialog);
|
|
37
|
+
* if (dialogElement) {
|
|
38
|
+
* // Process dialog element
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function findElement(children, targetType) {
|
|
43
|
+
for (const child of Children.toArray(children)) {
|
|
44
|
+
if (!isValidElement(child)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (child.type === targetType) {
|
|
48
|
+
return child;
|
|
49
|
+
}
|
|
50
|
+
const found = findElement(child.props.children, targetType);
|
|
51
|
+
if (found) {
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolves a font family name to a usable CSS value.
|
|
59
|
+
* Converts the 'Default' placeholder to an empty string, allowing CSS to use system defaults.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} fontFamily - The font family name ('Default', 'Arial', 'Georgia', etc.)
|
|
62
|
+
* @returns {string} The resolved font family CSS value, or empty string if 'Default'
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* resolveFontFamily('Arial'); // Returns: 'Arial'
|
|
67
|
+
* resolveFontFamily('Default'); // Returns: ''
|
|
68
|
+
* resolveFontFamily('Times New Roman'); // Returns: 'Times New Roman'
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function resolveFontFamily(fontFamily) {
|
|
72
|
+
return fontFamily !== 'Default' ? fontFamily : '';
|
|
73
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Chart visualization panel rendering either a regular chart or pie chart.
|
|
4
|
+
* Applies formatting settings including title, subtitle, legend, series colors, tooltips, and axis customization.
|
|
5
|
+
* Syncs chart state with GridChart context and updates on format changes.
|
|
6
|
+
* Internal component used by GridChartPanel.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @returns {JSX.Element} Chart container with Syncfusion Chart or PieChart component
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const ChartPanel: () => JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Chart, ChartSeries, ChartSeriesCollection, ChartTitle, ChartSubtitle, PieChart, PieChartDataLabel, PieChartSeries, PieChartSeriesCollection, PieChartTitle, PieChartSubtitle, ChartLegend, PieChartLegend, ChartTooltip, PieChartTooltip, ChartDataLabel, ChartMarker, ChartPrimaryXAxis, ChartPrimaryYAxis, ChartAxisTitle, ChartAxisLabel } from '@syncfusion/react-charts';
|
|
4
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
5
|
+
import { findElement, resolveFontFamily } from '../utils/utils';
|
|
6
|
+
/**
|
|
7
|
+
* Chart visualization panel rendering either a regular chart or pie chart.
|
|
8
|
+
* Applies formatting settings including title, subtitle, legend, series colors, tooltips, and axis customization.
|
|
9
|
+
* Syncs chart state with GridChart context and updates on format changes.
|
|
10
|
+
* Internal component used by GridChartPanel.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
* @returns {JSX.Element} Chart container with Syncfusion Chart or PieChart component
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const ChartPanel = () => {
|
|
18
|
+
const { settings, chartInfo, categoryAxis, series, valueAxis, chartRef, pieChartRef, showSidePanel, format } = useGridChartSettings();
|
|
19
|
+
const { dataSource, chartSettings, chartNode, pieChartSettings, pieChartNode } = settings.current;
|
|
20
|
+
const chartRenderer = useMemo(() => {
|
|
21
|
+
if (!chartInfo.isChart) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const chartSeriesCollection = series.map((seriesItem, i) => {
|
|
25
|
+
const currentSeriesFormat = format.chartSeriesStyle
|
|
26
|
+
.find((data) => data.series === seriesItem);
|
|
27
|
+
return (_jsx(ChartSeries, { dataSource: dataSource, xField: categoryAxis, yField: seriesItem, name: seriesItem, type: chartInfo.chart, fill: currentSeriesFormat.fill, children: _jsx(ChartMarker, { children: _jsx(ChartDataLabel, { visible: currentSeriesFormat.enableDataLabel }) }) }, i));
|
|
28
|
+
});
|
|
29
|
+
const chartPrimaryXAxis = findElement(chartNode, ChartPrimaryXAxis);
|
|
30
|
+
const chartPrimaryYAxis = findElement(chartNode, ChartPrimaryYAxis);
|
|
31
|
+
return (_jsxs(Chart, { ref: chartRef, width: '100%', height: '100%', ...chartSettings, margin: {
|
|
32
|
+
left: format.marginLeft,
|
|
33
|
+
right: format.marginRight,
|
|
34
|
+
top: format.marginTop,
|
|
35
|
+
bottom: format.marginBottom
|
|
36
|
+
}, background: format.background, children: [chartNode, _jsx(ChartTitle, { text: format.titleText, fontFamily: resolveFontFamily(format.titleFontFamily), fontSize: format.titleFontSize + 'px', color: format.titleColor }), _jsx(ChartSubtitle, { text: format.subtitleText, fontFamily: resolveFontFamily(format.subtitleFontFamily), fontSize: format.subtitleFontSize + 'px', color: format.subtitleColor }), _jsx(ChartLegend, { visible: format.enableLegend, position: format.legendPosition, textStyle: {
|
|
37
|
+
fontFamily: resolveFontFamily(format.legendFontFamily),
|
|
38
|
+
fontSize: format.legendFontSize + 'px',
|
|
39
|
+
color: format.legendColor
|
|
40
|
+
} }), _jsx(ChartTooltip, { enable: format.enableTooltip }), _jsxs(ChartPrimaryXAxis, { valueType: 'Category', ...chartPrimaryXAxis?.props, inverted: format.categoryInverted, children: [_jsx(ChartAxisTitle, { text: format.categoryTitleText, fontFamily: resolveFontFamily(format.categoryTitleFontFamily), fontSize: format.categoryTitleFontSize + 'px', color: format.categoryTitleColor }), _jsx(ChartAxisLabel, { fontFamily: resolveFontFamily(format.categoryLabelFontFamily), fontSize: format.categoryLabelFontSize + 'px', color: format.categoryLabelColor, rotationAngle: format.categoryLabelRotation })] }), _jsxs(ChartPrimaryYAxis, { ...chartPrimaryYAxis?.props, inverted: format.valueInverted, children: [_jsx(ChartAxisTitle, { text: format.valueTitleText, fontFamily: resolveFontFamily(format.valueTitleFontFamily), fontSize: format.valueTitleFontSize + 'px', color: format.valueTitleColor }), _jsx(ChartAxisLabel, { fontFamily: resolveFontFamily(format.valueLabelFontFamily), fontSize: format.valueLabelFontSize + 'px', color: format.valueLabelColor, rotationAngle: format.valueLabelRotation })] }), _jsx(ChartSeriesCollection, { children: chartSeriesCollection })] }));
|
|
41
|
+
}, [chartInfo, categoryAxis, series, showSidePanel, format]);
|
|
42
|
+
const pieRenderer = useMemo(() => {
|
|
43
|
+
if (!chartInfo.isPieChart) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const pieChartSeriesCollection = (_jsx(PieChartSeries, { dataSource: dataSource, xField: categoryAxis, yField: valueAxis, children: _jsx(PieChartDataLabel, { visible: format.enablePieChartDataLabel, position: "Outside" }) }));
|
|
47
|
+
return (_jsxs(PieChart, { ref: pieChartRef, width: '100%', height: '100%', ...pieChartSettings, margin: {
|
|
48
|
+
left: format.marginLeft,
|
|
49
|
+
right: format.marginRight,
|
|
50
|
+
top: format.marginTop,
|
|
51
|
+
bottom: format.marginBottom
|
|
52
|
+
}, background: format.background, children: [pieChartNode, _jsx(PieChartTitle, { text: format.titleText, font: {
|
|
53
|
+
fontFamily: resolveFontFamily(format.titleFontFamily),
|
|
54
|
+
fontSize: format.titleFontSize + 'px',
|
|
55
|
+
color: format.titleColor
|
|
56
|
+
} }), _jsx(PieChartSubtitle, { text: format.subtitleText, font: {
|
|
57
|
+
fontFamily: resolveFontFamily(format.subtitleFontFamily),
|
|
58
|
+
fontSize: format.subtitleFontSize + 'px',
|
|
59
|
+
color: format.subtitleColor
|
|
60
|
+
} }), _jsx(PieChartLegend, { visible: format.enableLegend, position: format.legendPosition, textStyle: {
|
|
61
|
+
fontFamily: resolveFontFamily(format.legendFontFamily),
|
|
62
|
+
fontSize: format.legendFontSize + 'px',
|
|
63
|
+
color: format.legendColor
|
|
64
|
+
} }), _jsx(PieChartTooltip, { enable: format.enableTooltip }), _jsx(PieChartSeriesCollection, { children: pieChartSeriesCollection })] }));
|
|
65
|
+
}, [chartInfo, categoryAxis, valueAxis, showSidePanel, format]);
|
|
66
|
+
return (_jsxs(_Fragment, { children: [chartRenderer, pieRenderer] }));
|
|
67
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Chart type selection tab within the property panel.
|
|
4
|
+
* Displays categorized chart options organized by type (Line, Area, Column, Bar, Scatter, Pie).
|
|
5
|
+
* Allows users to select and switch between different chart visualizations.
|
|
6
|
+
* Each chart type includes related variants (e.g., Stacked, 100% Stacked).
|
|
7
|
+
*
|
|
8
|
+
* Internal component used by PropertyPanel in the Chart tab.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
* @returns {JSX.Element} Accordion component with chart type categories and selection buttons
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const ChartTab: () => JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion, AccordionContent, AccordionHeader, AccordionIndicator, AccordionPanel, AccordionTrigger } from '@syncfusion/react-navigations';
|
|
3
|
+
import { Chart2dLineIcon } from '@syncfusion/react-icons/src/icons/chart-2d-line';
|
|
4
|
+
import { Chart2dStackedLineIcon } from '@syncfusion/react-icons/src/icons/chart-2d-stacked-line';
|
|
5
|
+
import { Chart2d100PercentStackedLineIcon } from '@syncfusion/react-icons/src/icons/chart-2d-100-percent-stacked-line';
|
|
6
|
+
import { Chart2dAreaIcon } from '@syncfusion/react-icons/src/icons/chart-2d-area';
|
|
7
|
+
import { Chart2dStackedAreaIcon } from '@syncfusion/react-icons/src/icons/chart-2d-stacked-area';
|
|
8
|
+
import { Chart2d100PercentStackedAreaIcon } from '@syncfusion/react-icons/src/icons/chart-2d-100-percent-stacked-area';
|
|
9
|
+
import { Chart2dClusteredColumnIcon } from '@syncfusion/react-icons/src/icons/chart-2d-clustered-column';
|
|
10
|
+
import { Chart2dStackedColumnIcon } from '@syncfusion/react-icons/src/icons/chart-2d-stacked-column';
|
|
11
|
+
import { Chart2d100PercentStackedColumnIcon } from '@syncfusion/react-icons/src/icons/chart-2d-100-percent-stacked-column';
|
|
12
|
+
import { Chart2dClusteredBarIcon } from '@syncfusion/react-icons/src/icons/chart-2d-clustered-bar';
|
|
13
|
+
import { Chart2dStackedBarIcon } from '@syncfusion/react-icons/src/icons/chart-2d-stacked-bar';
|
|
14
|
+
import { Chart2d100PercentStackedBarIcon } from '@syncfusion/react-icons/src/icons/chart-2d-100-percent-stacked-bar';
|
|
15
|
+
import { ChartScatter } from '@syncfusion/react-icons/src/icons/chart-scatter';
|
|
16
|
+
import { Chart2dPie2Icon } from '@syncfusion/react-icons/src/icons/chart-2d-pie-2';
|
|
17
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
18
|
+
import { getChartInfo } from '../utils/utils';
|
|
19
|
+
const chartData = [
|
|
20
|
+
{
|
|
21
|
+
value: 'line-chart',
|
|
22
|
+
title: 'Line Chart',
|
|
23
|
+
items: [
|
|
24
|
+
{ icon: Chart2dLineIcon, label: 'Line', chart: 'Line' },
|
|
25
|
+
{ icon: Chart2dStackedLineIcon, label: 'Stacked Line', chart: 'StackingLine' },
|
|
26
|
+
{ icon: Chart2d100PercentStackedLineIcon, label: '100% Stacked Line', chart: 'StackingLine100' }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: 'area-chart',
|
|
31
|
+
title: 'Area Chart',
|
|
32
|
+
items: [
|
|
33
|
+
{ icon: Chart2dAreaIcon, label: 'Area', chart: 'Area' },
|
|
34
|
+
{ icon: Chart2dStackedAreaIcon, label: 'Stacked Area', chart: 'StackingArea' },
|
|
35
|
+
{ icon: Chart2d100PercentStackedAreaIcon, label: '100% Stacked Area', chart: 'StackingArea100' }
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: 'column-chart',
|
|
40
|
+
title: 'Column Chart',
|
|
41
|
+
items: [
|
|
42
|
+
{ icon: Chart2dClusteredColumnIcon, label: 'Column', chart: 'Column' },
|
|
43
|
+
{ icon: Chart2dStackedColumnIcon, label: 'Stacked Column', chart: 'StackingColumn' },
|
|
44
|
+
{ icon: Chart2d100PercentStackedColumnIcon, label: '100% Stacked Column', chart: 'StackingColumn100' }
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 'bar-chart',
|
|
49
|
+
title: 'Bar Chart',
|
|
50
|
+
items: [
|
|
51
|
+
{ icon: Chart2dClusteredBarIcon, label: 'Bar', chart: 'Bar' },
|
|
52
|
+
{ icon: Chart2dStackedBarIcon, label: 'Stacked Bar', chart: 'StackingBar' },
|
|
53
|
+
{ icon: Chart2d100PercentStackedBarIcon, label: '100% Stacked Bar', chart: 'StackingBar100' }
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: 'scatter-chart',
|
|
58
|
+
title: 'Scatter Chart',
|
|
59
|
+
items: [
|
|
60
|
+
{ icon: ChartScatter, label: 'Scatter', chart: 'Scatter' }
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: 'pie-chart',
|
|
65
|
+
title: 'Pie Chart',
|
|
66
|
+
items: [
|
|
67
|
+
{ icon: Chart2dPie2Icon, label: 'Pie', chart: 'Pie' }
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Chart type selection tab within the property panel.
|
|
73
|
+
* Displays categorized chart options organized by type (Line, Area, Column, Bar, Scatter, Pie).
|
|
74
|
+
* Allows users to select and switch between different chart visualizations.
|
|
75
|
+
* Each chart type includes related variants (e.g., Stacked, 100% Stacked).
|
|
76
|
+
*
|
|
77
|
+
* Internal component used by PropertyPanel in the Chart tab.
|
|
78
|
+
*
|
|
79
|
+
* @private
|
|
80
|
+
* @returns {JSX.Element} Accordion component with chart type categories and selection buttons
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export const ChartTab = () => {
|
|
85
|
+
const { chartInfo, setChartInfo } = useGridChartSettings();
|
|
86
|
+
const defaultValues = chartData.map((chart) => chart.value);
|
|
87
|
+
return (_jsx(Accordion, { multiple: true, defaultValue: defaultValues, children: chartData.map((chart) => (_jsxs(AccordionPanel, { value: chart.value, children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: [chart.title, " ", _jsx(AccordionIndicator, {})] }) }), _jsx(AccordionContent, { children: chart.items.map((item, index) => {
|
|
88
|
+
const IconComponent = item.icon;
|
|
89
|
+
return (_jsxs("div", { className: `sf-${item.chart.toLowerCase()}-chart sf-chart-list sf-cursor-pointer ${chartInfo.chart === item.chart ? 'sf-chart-selected' : ''}`, onClick: () => setChartInfo(getChartInfo(item.chart)), children: [_jsx(IconComponent, {}), " ", _jsx("span", { className: 'sf-chart-text', children: item.label })] }, index));
|
|
90
|
+
}) })] }, chart.value))) }));
|
|
91
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Data field selection tab within the property panel.
|
|
4
|
+
* Allows users to configure chart data binding:
|
|
5
|
+
* - Select the category (X-axis) field from available columns
|
|
6
|
+
* - Add and remove data series (Y-axis fields) with drag-and-drop reordering
|
|
7
|
+
* - For pie charts, configure the value axis field
|
|
8
|
+
*
|
|
9
|
+
* Updates GridChart context when selections change, triggering chart re-render.
|
|
10
|
+
* Internal component used by PropertyPanel in the Data tab.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
* @returns {JSX.Element} Tab containing category dropdown and series management grid
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const DataTab: () => JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { DropDownList } from '@syncfusion/react-dropdowns';
|
|
3
|
+
import { Column, Columns, CommandColumnModule, CommandItem, Grid, ReorderModule } from '@syncfusion/react-grid';
|
|
4
|
+
import { useMemo, useRef } from 'react';
|
|
5
|
+
import { TrashIcon } from '@syncfusion/react-icons/src/icons/trash';
|
|
6
|
+
import { PlusIcon } from '@syncfusion/react-icons/src/icons/plus';
|
|
7
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
8
|
+
/**
|
|
9
|
+
* Data field selection tab within the property panel.
|
|
10
|
+
* Allows users to configure chart data binding:
|
|
11
|
+
* - Select the category (X-axis) field from available columns
|
|
12
|
+
* - Add and remove data series (Y-axis fields) with drag-and-drop reordering
|
|
13
|
+
* - For pie charts, configure the value axis field
|
|
14
|
+
*
|
|
15
|
+
* Updates GridChart context when selections change, triggering chart re-render.
|
|
16
|
+
* Internal component used by PropertyPanel in the Data tab.
|
|
17
|
+
*
|
|
18
|
+
* @private
|
|
19
|
+
* @returns {JSX.Element} Tab containing category dropdown and series management grid
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export const DataTab = () => {
|
|
24
|
+
const { settings, chartInfo, categoryAxis, setCategoryAxis, series, setSeries, valueAxis, setValueAxis } = useGridChartSettings();
|
|
25
|
+
const seriesHolder = useRef([]);
|
|
26
|
+
const categoryAxisRenderer = useMemo(() => {
|
|
27
|
+
return (_jsxs("div", { className: 'sf-chart-data-container', children: [_jsx("div", { className: 'sf-chart-header-text sf-chart-header-text-margin-bottom-10', children: "Category Axis" }), _jsx(DropDownList, { className: 'sf-category-dropdownlist sf-chart-data-format-component', dataSource: settings.current.category, value: categoryAxis, onChange: (args) => {
|
|
28
|
+
setCategoryAxis(args.value);
|
|
29
|
+
} })] }));
|
|
30
|
+
}, [categoryAxis]);
|
|
31
|
+
const seriesRenderer = useMemo(() => {
|
|
32
|
+
if (!chartInfo.isChart) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const data = series.map((data) => {
|
|
36
|
+
return { series: data };
|
|
37
|
+
});
|
|
38
|
+
const handleRowDrop = (args) => {
|
|
39
|
+
setSeries(() => {
|
|
40
|
+
const newSeries = [...series];
|
|
41
|
+
const [removed] = newSeries.splice(args.fromIndex, 1);
|
|
42
|
+
newSeries.splice(args.dropIndex, 0, removed);
|
|
43
|
+
return newSeries;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const handleDelete = (args) => {
|
|
47
|
+
setSeries(() => {
|
|
48
|
+
const newSeries = [...series];
|
|
49
|
+
const [removed] = newSeries.splice(args.target.closest('tr').rowIndex, 1);
|
|
50
|
+
seriesHolder.current.push(removed);
|
|
51
|
+
return newSeries;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const handleToolbarItemClick = () => {
|
|
55
|
+
setSeries(() => {
|
|
56
|
+
const newSeries = [...series];
|
|
57
|
+
const [removed] = seriesHolder.current.splice(0, 1);
|
|
58
|
+
newSeries.push(removed);
|
|
59
|
+
return newSeries;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return (_jsxs("div", { className: 'sf-chart-data-container', children: [_jsx("div", { className: 'sf-chart-header-text', children: "Series" }), _jsx(Grid, { dataSource: data, className: 'sf-series-grid', dragAndDropSettings: { enabled: series.length > 1 }, onRowDrop: handleRowDrop, toolbar: [{ id: 'add', text: 'Add', icon: _jsx(PlusIcon, {}), disabled: seriesHolder.current.length === 0 }], onToolbarItemClick: handleToolbarItemClick, modules: { CommandColumnModule, ReorderModule }, children: _jsxs(Columns, { children: [_jsx(Column, { field: 'series', headerText: 'Series', isPrimaryKey: true }), series.length > 1 && _jsx(Column, { getCommandItems: () => {
|
|
63
|
+
return [
|
|
64
|
+
_jsx(CommandItem, { children: _jsx(TrashIcon, { className: 'sf-series-delete-icon sf-cursor-pointer', onClick: handleDelete }) })
|
|
65
|
+
];
|
|
66
|
+
} })] }) })] }));
|
|
67
|
+
}, [chartInfo, series]);
|
|
68
|
+
const valueAxisRenderer = useMemo(() => {
|
|
69
|
+
if (!chartInfo.isPieChart) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return (_jsxs("div", { className: 'sf-chart-data-container', children: [_jsx("div", { className: 'sf-chart-header-text sf-chart-header-text-margin-bottom-10', children: "Value Axis" }), _jsx(DropDownList, { className: 'sf-value-dropdownlist sf-chart-data-format-component', dataSource: settings.current.series, value: valueAxis, onChange: (args) => {
|
|
73
|
+
setValueAxis(args.value);
|
|
74
|
+
} })] }));
|
|
75
|
+
}, [chartInfo, valueAxis]);
|
|
76
|
+
return (_jsxs(_Fragment, { children: [categoryAxisRenderer, seriesRenderer, valueAxisRenderer] }));
|
|
77
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Export options panel displayed in the chart header.
|
|
4
|
+
* Provides a dropdown menu for exporting the chart in multiple formats.
|
|
5
|
+
* Supported formats include Print, PNG, JPEG, SVG, PDF, XLSX, and CSV.
|
|
6
|
+
* Export options are configurable via GridChartSettings.chartExportItems.
|
|
7
|
+
*
|
|
8
|
+
* Internal component used by GridChartPanel in the header area.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
* @returns {JSX.Element} Dropdown button with export format options
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const ExportPanel: () => JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DropDownButton } from '@syncfusion/react-splitbuttons';
|
|
3
|
+
import { print, exportChart, excelExport } from '@syncfusion/react-charts';
|
|
4
|
+
import { ExportIcon } from '@syncfusion/react-icons/src/icons/export';
|
|
5
|
+
import { ExportPdfIcon } from '@syncfusion/react-icons/src/icons/export-pdf';
|
|
6
|
+
import { ExportPngIcon } from '@syncfusion/react-icons/src/icons/export-png';
|
|
7
|
+
import { ExportJpegIcon } from '@syncfusion/react-icons/src/icons/export-jpeg';
|
|
8
|
+
import { ExportSvgIcon } from '@syncfusion/react-icons/src/icons/export-svg';
|
|
9
|
+
import { ExportExcelIcon } from '@syncfusion/react-icons/src/icons/export-excel';
|
|
10
|
+
import { ExportCsvIcon } from '@syncfusion/react-icons/src/icons/export-csv';
|
|
11
|
+
import { PrintIcon } from '@syncfusion/react-icons/src/icons/print';
|
|
12
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
13
|
+
/**
|
|
14
|
+
* Export options panel displayed in the chart header.
|
|
15
|
+
* Provides a dropdown menu for exporting the chart in multiple formats.
|
|
16
|
+
* Supported formats include Print, PNG, JPEG, SVG, PDF, XLSX, and CSV.
|
|
17
|
+
* Export options are configurable via GridChartSettings.chartExportItems.
|
|
18
|
+
*
|
|
19
|
+
* Internal component used by GridChartPanel in the header area.
|
|
20
|
+
*
|
|
21
|
+
* @private
|
|
22
|
+
* @returns {JSX.Element} Dropdown button with export format options
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const ExportPanel = () => {
|
|
27
|
+
const { settings, chartRef, pieChartRef, chartInfo } = useGridChartSettings();
|
|
28
|
+
const items = settings.current.chartExportItems.map((data) => {
|
|
29
|
+
let item;
|
|
30
|
+
switch (data) {
|
|
31
|
+
case 'Print':
|
|
32
|
+
item = { text: 'Print', icon: _jsx(PrintIcon, {}) };
|
|
33
|
+
break;
|
|
34
|
+
case 'JPEG':
|
|
35
|
+
item = { text: 'JPEG', icon: _jsx(ExportJpegIcon, {}) };
|
|
36
|
+
break;
|
|
37
|
+
case 'PNG':
|
|
38
|
+
item = { text: 'PNG', icon: _jsx(ExportPngIcon, {}) };
|
|
39
|
+
break;
|
|
40
|
+
case 'SVG':
|
|
41
|
+
item = { text: 'SVG', icon: _jsx(ExportSvgIcon, {}) };
|
|
42
|
+
break;
|
|
43
|
+
case 'PDF':
|
|
44
|
+
item = { text: 'PDF', icon: _jsx(ExportPdfIcon, {}) };
|
|
45
|
+
break;
|
|
46
|
+
case 'XLSX':
|
|
47
|
+
item = { text: 'XLSX', icon: _jsx(ExportExcelIcon, {}) };
|
|
48
|
+
break;
|
|
49
|
+
case 'CSV':
|
|
50
|
+
item = { text: 'CSV', icon: _jsx(ExportCsvIcon, {}) };
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return item;
|
|
54
|
+
});
|
|
55
|
+
const handlButtonClick = (args) => {
|
|
56
|
+
const chart = chartInfo.isChart ? chartRef.current : pieChartRef.current;
|
|
57
|
+
const fileName = 'grid-chart';
|
|
58
|
+
switch (args.item.text) {
|
|
59
|
+
case 'Print':
|
|
60
|
+
print(chart);
|
|
61
|
+
break;
|
|
62
|
+
case 'PNG':
|
|
63
|
+
case 'SVG':
|
|
64
|
+
case 'JPEG':
|
|
65
|
+
case 'PDF':
|
|
66
|
+
exportChart(chart, args.item.text === 'JPEG' ? 'JPG' : args.item.text, fileName);
|
|
67
|
+
break;
|
|
68
|
+
case 'XLSX':
|
|
69
|
+
case 'CSV':
|
|
70
|
+
excelExport(chart, args.item.text, fileName);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return (_jsx(DropDownButton, { items: items, icon: _jsx(ExportIcon, {}), onSelect: handlButtonClick, className: 'sf-caret-hide sf-export-btn', children: "Export" }));
|
|
75
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Format and styling tab within the property panel.
|
|
4
|
+
* Provides comprehensive chart appearance customization through 5 accordion sections:
|
|
5
|
+
*
|
|
6
|
+
* **Chart Style**: Chart margins and background color
|
|
7
|
+
* **Title Style**: Main title and subtitle text, fonts, sizes, and colors
|
|
8
|
+
* **Legend Style**: Legend visibility, position, font, size, and color
|
|
9
|
+
* **Series Style**: Series-specific colors and data label visibility
|
|
10
|
+
* **Axes Style**: Axis titles, labels, fonts, sizes, rotations, and inversion options
|
|
11
|
+
*
|
|
12
|
+
* Updates GridChart context's Format object when any setting changes.
|
|
13
|
+
* Internal component used by PropertyPanel in the Format tab.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @returns {JSX.Element} Accordion with formatting controls for all visual aspects
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const FormatTab: () => JSX.Element;
|