@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,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion, AccordionContent, AccordionHeader, AccordionIndicator, AccordionPanel, AccordionTrigger } from '@syncfusion/react-navigations';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { NumericTextBox, TextBox } from '@syncfusion/react-inputs';
|
|
5
|
+
import { DropDownList } from '@syncfusion/react-dropdowns';
|
|
6
|
+
import { Button, Variant, Checkbox } from '@syncfusion/react-buttons';
|
|
7
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
8
|
+
import { ColorPicker } from '../components/ColorPicker';
|
|
9
|
+
/**
|
|
10
|
+
* Format and styling tab within the property panel.
|
|
11
|
+
* Provides comprehensive chart appearance customization through 5 accordion sections:
|
|
12
|
+
*
|
|
13
|
+
* **Chart Style**: Chart margins and background color
|
|
14
|
+
* **Title Style**: Main title and subtitle text, fonts, sizes, and colors
|
|
15
|
+
* **Legend Style**: Legend visibility, position, font, size, and color
|
|
16
|
+
* **Series Style**: Series-specific colors and data label visibility
|
|
17
|
+
* **Axes Style**: Axis titles, labels, fonts, sizes, rotations, and inversion options
|
|
18
|
+
*
|
|
19
|
+
* Updates GridChart context's Format object when any setting changes.
|
|
20
|
+
* Internal component used by PropertyPanel in the Format tab.
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
* @returns {JSX.Element} Accordion with formatting controls for all visual aspects
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export const FormatTab = () => {
|
|
28
|
+
const { format, setFormat, chartInfo, settings } = useGridChartSettings();
|
|
29
|
+
const [titleSection, setTitleSection] = useState('title');
|
|
30
|
+
const [seriesSection, setSeriesSection] = useState('All');
|
|
31
|
+
const [axesSection, setAxesSection] = useState('category');
|
|
32
|
+
const fontOptions = ['Default', 'Lucida Console', 'Trebuchet MS', 'Times New Roman', 'Courier New', 'Georgia'];
|
|
33
|
+
const fontSizeOptions = ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20'];
|
|
34
|
+
const legendPositionOptions = ['Auto', 'Top', 'Left', 'Bottom', 'Right'];
|
|
35
|
+
const seriesOptions = ['All', ...settings.current.series];
|
|
36
|
+
const rotationOptions = [0, 45, 90, 135, 180, 225, 270, 315];
|
|
37
|
+
const currentSeriesFormat = format.chartSeriesStyle.find((data) => data.series === seriesSection);
|
|
38
|
+
const getTitleKey = (titleKey, subtitleKey) => titleSection === 'title' ? titleKey : subtitleKey;
|
|
39
|
+
const getAxesKey = (categoryKey, valueKey) => axesSection === 'category' ? categoryKey : valueKey;
|
|
40
|
+
return (_jsxs(Accordion, { multiple: true, defaultValue: ['chart-style', 'title-style', 'legend-style', 'series-style', 'axes-style'], children: [_jsxs(AccordionPanel, { value: 'chart-style', children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: ["Chart Style ", _jsx(AccordionIndicator, {})] }) }), _jsxs(AccordionContent, { children: [_jsx("div", { className: 'sf-chart-header-text', children: "Margin" }), _jsxs("div", { className: 'sf-chart-format-components', children: [_jsxs("div", { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Top" }), _jsx(NumericTextBox, { className: 'sf-margin-top-numeric sf-chart-data-format-component', value: format.marginTop, onChange: (args) => {
|
|
41
|
+
setFormat((prev) => { return { ...prev, marginTop: args.value }; });
|
|
42
|
+
} })] }), _jsxs("div", { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Bottom" }), _jsx(NumericTextBox, { className: 'sf-margin-bottom-numeric sf-chart-data-format-component', value: format.marginBottom, onChange: (args) => {
|
|
43
|
+
setFormat((prev) => { return { ...prev, marginBottom: args.value }; });
|
|
44
|
+
} })] })] }), _jsxs("div", { className: 'sf-chart-format-components', children: [_jsxs("div", { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Right" }), _jsx(NumericTextBox, { className: 'sf-margin-right-numeric sf-chart-data-format-component', value: format.marginRight, onChange: (args) => {
|
|
45
|
+
setFormat((prev) => { return { ...prev, marginRight: args.value }; });
|
|
46
|
+
} })] }), _jsxs("div", { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Left" }), _jsx(NumericTextBox, { className: 'sf-margin-left-numeric sf-chart-data-format-component', value: format.marginLeft, onChange: (args) => {
|
|
47
|
+
setFormat((prev) => { return { ...prev, marginLeft: args.value }; });
|
|
48
|
+
} })] })] }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-background-color-picker sf-chart-data-format-component', value: format.background, onChange: (color) => {
|
|
49
|
+
setFormat((prev) => { return { ...prev, background: color }; });
|
|
50
|
+
} })] })] }), _jsxs(AccordionPanel, { value: 'title-style', children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: ["Title Style ", _jsx(AccordionIndicator, {})] }) }), _jsxs(AccordionContent, { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Apply To" }), _jsxs("div", { className: 'sf-display-flex', children: [_jsx(Button, { className: 'sf-title-button sf-chart-data-format-component sf-flex-one sf-chart-border-end-radius', variant: titleSection === 'title' ? Variant.Filled : Variant.Outlined, onClick: () => setTitleSection('title'), children: "Title" }), _jsx(Button, { className: 'sf-subtitle-button sf-chart-data-format-component sf-flex-one sf-chart-border-start-radius', variant: titleSection === 'subtitle' ? Variant.Filled : Variant.Outlined, onClick: () => setTitleSection('subtitle'), children: "Subtitle" })] }), _jsx("div", { className: 'sf-chart-normal-text', children: "Title" }), _jsx(TextBox, { className: 'sf-title-textbox sf-chart-data-format-component', value: titleSection === 'title' ? format.titleText : format.subtitleText, onChange: (args) => setFormat((prev) => ({
|
|
51
|
+
...prev,
|
|
52
|
+
[getTitleKey('titleText', 'subtitleText')]: args.value
|
|
53
|
+
})), placeholder: "Enter title text" }), _jsx("div", { className: 'sf-chart-normal-text', children: "Font" }), _jsx(DropDownList, { className: 'sf-title-font-dropdown sf-chart-data-format-component', dataSource: fontOptions, value: titleSection === 'title' ? format.titleFontFamily : format.subtitleFontFamily, onChange: (args) => setFormat((prev) => ({
|
|
54
|
+
...prev,
|
|
55
|
+
[getTitleKey('titleFontFamily', 'subtitleFontFamily')]: args.value
|
|
56
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Size" }), _jsx(DropDownList, { className: 'sf-title-size-dropdown sf-chart-data-format-component', dataSource: fontSizeOptions, value: titleSection === 'title' ? format.titleFontSize : format.subtitleFontSize, onChange: (args) => setFormat((prev) => ({
|
|
57
|
+
...prev,
|
|
58
|
+
[getTitleKey('titleFontSize', 'subtitleFontSize')]: args.value
|
|
59
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-title-color-picker sf-chart-data-format-component', value: titleSection === 'title' ? format.titleColor : format.subtitleColor, onChange: (color) => setFormat((prev) => ({
|
|
60
|
+
...prev,
|
|
61
|
+
[getTitleKey('titleColor', 'subtitleColor')]: color
|
|
62
|
+
})) })] })] }), _jsxs(AccordionPanel, { value: 'legend-style', children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: ["Legend Style ", _jsx(AccordionIndicator, {})] }) }), _jsxs(AccordionContent, { children: [_jsx(Checkbox, { className: 'sf-legend-checkbox sf-chart-data-format-component', label: 'Show Legend', checked: format.enableLegend, onChange: (args) => setFormat((prev) => ({
|
|
63
|
+
...prev,
|
|
64
|
+
enableLegend: args.value
|
|
65
|
+
})) }), _jsx("div", { className: 'sf-chart-normal-text', children: "Font" }), _jsx(DropDownList, { className: 'sf-legend-font-dropdown sf-chart-data-format-component', dataSource: fontOptions, value: format.legendFontFamily, onChange: (args) => setFormat((prev) => ({
|
|
66
|
+
...prev,
|
|
67
|
+
legendFontFamily: args.value
|
|
68
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Size" }), _jsx(DropDownList, { className: 'sf-legend-size-dropdown sf-chart-data-format-component', dataSource: fontSizeOptions, value: format.legendFontSize, onChange: (args) => setFormat((prev) => ({
|
|
69
|
+
...prev,
|
|
70
|
+
legendFontSize: args.value
|
|
71
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-legend-color-picker sf-chart-data-format-component', value: format.legendColor, onChange: (color) => setFormat((prev) => ({
|
|
72
|
+
...prev,
|
|
73
|
+
legendColor: color
|
|
74
|
+
})) }), _jsx("div", { className: 'sf-chart-normal-text', children: "Position" }), _jsx(DropDownList, { className: 'sf-legend-position-dropdown sf-chart-data-format-component', dataSource: legendPositionOptions, value: format.legendPosition, onChange: (args) => setFormat((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
legendPosition: args.value
|
|
77
|
+
})), fields: { text: 'text', value: 'text' } })] })] }), _jsxs(AccordionPanel, { value: 'series-style', children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: ["Series Style ", _jsx(AccordionIndicator, {})] }) }), _jsxs(AccordionContent, { children: [_jsx(Checkbox, { className: 'sf-series-tooltip-checkbox sf-chart-data-format-component', label: 'Show Tooltip', checked: format.enableTooltip, onChange: (args) => setFormat((prev) => ({
|
|
78
|
+
...prev,
|
|
79
|
+
enableTooltip: args.value
|
|
80
|
+
})) }), chartInfo.isPieChart && (_jsx(Checkbox, { className: 'sf-series-pie-data-label-checkbox sf-chart-data-format-component', label: 'Show Data Label', checked: format.enablePieChartDataLabel, onChange: (args) => setFormat((prev) => ({
|
|
81
|
+
...prev,
|
|
82
|
+
enablePieChartDataLabel: args.value
|
|
83
|
+
})) })), chartInfo.isChart && (_jsxs(_Fragment, { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Apply To" }), _jsx(DropDownList, { className: 'sf-series-apply-dropdown sf-chart-data-format-component', dataSource: seriesOptions, value: seriesSection, onChange: (args) => setSeriesSection(args.value) }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-series-color-picker sf-chart-data-format-component', value: currentSeriesFormat.fill, onChange: (color) => setFormat((prev) => {
|
|
84
|
+
const chartSeriesStyle = [...prev.chartSeriesStyle]
|
|
85
|
+
.map((data) => {
|
|
86
|
+
if (seriesSection === 'All' || seriesSection === data.series) {
|
|
87
|
+
data.fill = color;
|
|
88
|
+
}
|
|
89
|
+
return data;
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
...prev,
|
|
93
|
+
chartSeriesStyle
|
|
94
|
+
};
|
|
95
|
+
}) }), _jsx(Checkbox, { className: 'sf-series-chart-data-label-checkbox sf-chart-data-format-component', label: 'Show Data Label', checked: currentSeriesFormat.enableDataLabel, onChange: (args) => setFormat((prev) => {
|
|
96
|
+
const chartSeriesStyle = [...prev.chartSeriesStyle]
|
|
97
|
+
.map((data) => {
|
|
98
|
+
if (seriesSection === 'All' || seriesSection === data.series) {
|
|
99
|
+
data.enableDataLabel = args.value;
|
|
100
|
+
}
|
|
101
|
+
return data;
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
...prev,
|
|
105
|
+
chartSeriesStyle
|
|
106
|
+
};
|
|
107
|
+
}) })] }))] })] }), chartInfo.isChart && _jsxs(AccordionPanel, { value: 'axes-style', children: [_jsx(AccordionHeader, { children: _jsxs(AccordionTrigger, { children: ["Axes Style ", _jsx(AccordionIndicator, {})] }) }), _jsxs(AccordionContent, { children: [_jsx("div", { className: 'sf-chart-normal-text', children: "Apply To Axis" }), _jsxs("div", { className: 'sf-display-flex', children: [_jsx(Button, { className: 'sf-axes-category-button sf-chart-data-format-component sf-flex-one sf-chart-border-end-radius', variant: axesSection === 'category' ? Variant.Filled : Variant.Outlined, onClick: () => setAxesSection('category'), children: "Category" }), _jsx(Button, { className: 'sf-axes-value-button sf-chart-data-format-component sf-flex-one sf-chart-border-start-radius', variant: axesSection === 'value' ? Variant.Filled : Variant.Outlined, onClick: () => setAxesSection('value'), children: "Value" })] }), _jsx(Checkbox, { className: 'sf-axes-reverse-checkbox sf-chart-data-format-component', label: 'Reverse Order', checked: axesSection === 'category' ? format.categoryInverted : format.valueInverted, onChange: (args) => setFormat((prev) => ({
|
|
108
|
+
...prev,
|
|
109
|
+
[getAxesKey('categoryInverted', 'valueInverted')]: args.value
|
|
110
|
+
})) }), _jsx("div", { className: 'sf-chart-header-text', children: "Title" }), _jsx("div", { className: 'sf-chart-normal-text', children: "Text" }), _jsx(TextBox, { className: 'sf-axes-title-textbox sf-chart-data-format-component', value: axesSection === 'category' ? format.categoryTitleText : format.valueTitleText, onChange: (args) => setFormat((prev) => ({
|
|
111
|
+
...prev,
|
|
112
|
+
[getAxesKey('categoryTitleText', 'valueTitleText')]: args.value
|
|
113
|
+
})), placeholder: "Enter title text" }), _jsx("div", { className: 'sf-chart-normal-text', children: "Font" }), _jsx(DropDownList, { className: 'sf-axes-title-font-dropdown sf-chart-data-format-component', dataSource: fontOptions, value: axesSection === 'category' ? format.categoryTitleFontFamily : format.valueTitleFontFamily, onChange: (args) => setFormat((prev) => ({
|
|
114
|
+
...prev,
|
|
115
|
+
[getAxesKey('categoryTitleFontFamily', 'valueTitleFontFamily')]: args.value
|
|
116
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Size" }), _jsx(DropDownList, { className: 'sf-axes-title-size-dropdown sf-chart-data-format-component', dataSource: fontSizeOptions, value: axesSection === 'category' ? format.categoryTitleFontSize : format.valueTitleFontSize, onChange: (args) => setFormat((prev) => ({
|
|
117
|
+
...prev,
|
|
118
|
+
[getAxesKey('categoryTitleFontSize', 'valueTitleFontSize')]: args.value
|
|
119
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-axes-title-color-picker sf-chart-data-format-component', value: axesSection === 'category' ? format.categoryTitleColor : format.valueTitleColor, onChange: (color) => setFormat((prev) => ({
|
|
120
|
+
...prev,
|
|
121
|
+
[getAxesKey('categoryTitleColor', 'valueTitleColor')]: color
|
|
122
|
+
})) }), _jsx("div", { className: 'sf-chart-header-text', children: "Label" }), _jsx("div", { className: 'sf-chart-normal-text', children: "Font" }), _jsx(DropDownList, { className: 'sf-axes-label-font-dropdown sf-chart-data-format-component', dataSource: fontOptions, value: axesSection === 'category' ? format.categoryLabelFontFamily : format.valueLabelFontFamily, onChange: (args) => setFormat((prev) => ({
|
|
123
|
+
...prev,
|
|
124
|
+
[getAxesKey('categoryLabelFontFamily', 'valueLabelFontFamily')]: args.value
|
|
125
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Size" }), _jsx(DropDownList, { className: 'sf-axes-label-size-dropdown sf-chart-data-format-component', dataSource: fontSizeOptions, value: axesSection === 'category' ? format.categoryLabelFontSize : format.valueLabelFontSize, onChange: (args) => setFormat((prev) => ({
|
|
126
|
+
...prev,
|
|
127
|
+
[getAxesKey('categoryLabelFontSize', 'valueLabelFontSize')]: args.value
|
|
128
|
+
})), fields: { text: 'text', value: 'text' } }), _jsx("div", { className: 'sf-chart-normal-text', children: "Color" }), _jsx(ColorPicker, { className: 'sf-axes-label-color-picker sf-chart-data-format-component', value: axesSection === 'category' ? format.categoryLabelColor : format.valueLabelColor, onChange: (color) => setFormat((prev) => ({
|
|
129
|
+
...prev,
|
|
130
|
+
[getAxesKey('categoryLabelColor', 'valueLabelColor')]: color
|
|
131
|
+
})) }), _jsx("div", { className: 'sf-chart-normal-text', children: "Rotation" }), _jsx(DropDownList, { className: 'sf-axes-label-rotation-dropdown sf-chart-data-format-component', dataSource: rotationOptions, value: axesSection === 'category' ? format.categoryLabelRotation : format.valueLabelRotation, onChange: (args) => setFormat((prev) => ({
|
|
132
|
+
...prev,
|
|
133
|
+
[getAxesKey('categoryLabelRotation', 'valueLabelRotation')]: parseInt(args.value.toString(), 10)
|
|
134
|
+
})), fields: { text: 'text', value: 'text' } })] })] })] }));
|
|
135
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RefAttributes, JSX } from 'react';
|
|
2
|
+
import { GridChartProps, GridChartRef } from '../types/grid-chart.interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Main GridChart component for displaying interactive charts with a data grid.
|
|
5
|
+
* Renders a modal dialog containing the chart visualization, data tab, formatting options, and export functionality.
|
|
6
|
+
* Use the ref to programmatically show the chart dialog and configure settings.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @param {GridChartProps} props - Component props
|
|
10
|
+
* @param {Ref<GridChartRef>} ref - Reference to imperative handle for controlling the component
|
|
11
|
+
* @returns {JSX.Element} Dialog component containing the grid chart interface
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { GridChart } from '@syncfusion/react-grid-chart';
|
|
16
|
+
* import { useRef } from 'react';
|
|
17
|
+
*
|
|
18
|
+
* export function MyApp() {
|
|
19
|
+
* const gridChartRef = useRef<GridChartRef>(null);
|
|
20
|
+
*
|
|
21
|
+
* const handleShowChart = () => {
|
|
22
|
+
* gridChartRef.current?.show({
|
|
23
|
+
* chart: 'Column',
|
|
24
|
+
* dataSource: salesData,
|
|
25
|
+
* category: ['OrderDate'],
|
|
26
|
+
* series: ['Sales', 'Quantity'],
|
|
27
|
+
* enablePropertyPanel: true,
|
|
28
|
+
* enableExport: true,
|
|
29
|
+
* chartExportItems: ['PNG', 'PDF', 'XLSX']
|
|
30
|
+
* });
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <>
|
|
35
|
+
* <GridChart ref={gridChartRef} />
|
|
36
|
+
* <button onClick={handleShowChart}>Open Chart</button>
|
|
37
|
+
* </>
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const GridChart: (props: GridChartProps & RefAttributes<GridChartRef>) => JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
+
import { Dialog } from '@syncfusion/react-popups';
|
|
4
|
+
import { GridChartPanel } from './GridChartPanel';
|
|
5
|
+
import { GridChartProvider } from '../contexts/GridChartContext';
|
|
6
|
+
/**
|
|
7
|
+
* Main GridChart component for displaying interactive charts with a data grid.
|
|
8
|
+
* Renders a modal dialog containing the chart visualization, data tab, formatting options, and export functionality.
|
|
9
|
+
* Use the ref to programmatically show the chart dialog and configure settings.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @param {GridChartProps} props - Component props
|
|
13
|
+
* @param {Ref<GridChartRef>} ref - Reference to imperative handle for controlling the component
|
|
14
|
+
* @returns {JSX.Element} Dialog component containing the grid chart interface
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { GridChart } from '@syncfusion/react-grid-chart';
|
|
19
|
+
* import { useRef } from 'react';
|
|
20
|
+
*
|
|
21
|
+
* export function MyApp() {
|
|
22
|
+
* const gridChartRef = useRef<GridChartRef>(null);
|
|
23
|
+
*
|
|
24
|
+
* const handleShowChart = () => {
|
|
25
|
+
* gridChartRef.current?.show({
|
|
26
|
+
* chart: 'Column',
|
|
27
|
+
* dataSource: salesData,
|
|
28
|
+
* category: ['OrderDate'],
|
|
29
|
+
* series: ['Sales', 'Quantity'],
|
|
30
|
+
* enablePropertyPanel: true,
|
|
31
|
+
* enableExport: true,
|
|
32
|
+
* chartExportItems: ['PNG', 'PDF', 'XLSX']
|
|
33
|
+
* });
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* return (
|
|
37
|
+
* <>
|
|
38
|
+
* <GridChart ref={gridChartRef} />
|
|
39
|
+
* <button onClick={handleShowChart}>Open Chart</button>
|
|
40
|
+
* </>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const GridChart = forwardRef((_props, ref) => {
|
|
46
|
+
const gridChartSettings = useRef(null);
|
|
47
|
+
const [open, setOpen] = useState(false);
|
|
48
|
+
let dialogclass = 'sf-grid-chart-dialog';
|
|
49
|
+
if (gridChartSettings.current?.dialogSettings?.className) {
|
|
50
|
+
dialogclass += ` ${gridChartSettings.current.dialogSettings.className}`;
|
|
51
|
+
}
|
|
52
|
+
const show = useCallback((settings) => {
|
|
53
|
+
gridChartSettings.current = {
|
|
54
|
+
enablePropertyPanel: false,
|
|
55
|
+
enableExport: false,
|
|
56
|
+
chartExportItems: ['Print', 'PNG', 'JPEG', 'SVG', 'PDF', 'XLSX', 'CSV'],
|
|
57
|
+
...settings
|
|
58
|
+
};
|
|
59
|
+
setOpen(true);
|
|
60
|
+
}, []);
|
|
61
|
+
useImperativeHandle(ref, () => ({
|
|
62
|
+
show
|
|
63
|
+
}), [show]);
|
|
64
|
+
return (_jsx(Dialog, { draggable: true, style: { width: '90%', height: '90%' }, modal: true, ...gridChartSettings.current?.dialogSettings, open: open, onClose: () => setOpen(false), className: dialogclass, children: _jsx(GridChartProvider, { settings: gridChartSettings, children: _jsx(GridChartPanel, {}) }) }));
|
|
65
|
+
});
|
|
66
|
+
GridChart.displayName = 'GridChart';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Main layout panel orchestrating the GridChart interface.
|
|
4
|
+
* Manages the layout of chart visualization, export options, and property panel.
|
|
5
|
+
* Conditionally displays the property panel based on settings and user preferences.
|
|
6
|
+
* Internal component used by GridChart.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @returns {JSX.Element} Layout container with ChartPanel, ExportPanel, and PropertyPanel
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const GridChartPanel: () => JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ChartPanel } from './ChartPanel';
|
|
4
|
+
import { PropertyPanel } from './PropertyPanel';
|
|
5
|
+
import { ExportPanel } from './ExportPanel';
|
|
6
|
+
import { Button } from '@syncfusion/react-buttons';
|
|
7
|
+
import { ShowSidePanelIcon } from '@syncfusion/react-icons/src/icons/show-side-panel';
|
|
8
|
+
import { ViewSideIcon } from '@syncfusion/react-icons/src/icons/view-side';
|
|
9
|
+
import { useGridChartSettings } from '../contexts/GridChartContext';
|
|
10
|
+
/**
|
|
11
|
+
* Main layout panel orchestrating the GridChart interface.
|
|
12
|
+
* Manages the layout of chart visualization, export options, and property panel.
|
|
13
|
+
* Conditionally displays the property panel based on settings and user preferences.
|
|
14
|
+
* Internal component used by GridChart.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
* @returns {JSX.Element} Layout container with ChartPanel, ExportPanel, and PropertyPanel
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export const GridChartPanel = () => {
|
|
22
|
+
const { settings, showSidePanel, setShowSidePanel } = useGridChartSettings();
|
|
23
|
+
const enableExport = settings.current.enableExport;
|
|
24
|
+
const enablePropertyPanel = settings.current.enablePropertyPanel;
|
|
25
|
+
const [renderChart, setRenderChart] = useState(false);
|
|
26
|
+
requestAnimationFrame(() => {
|
|
27
|
+
setRenderChart(true);
|
|
28
|
+
});
|
|
29
|
+
return (_jsxs("div", { className: 'sf-grid-chart-panel', children: [_jsxs("div", { className: `sf-export-chart-panel${enablePropertyPanel && showSidePanel ? ' sf-chart-property-panel' : ''}`, children: [(enableExport || enablePropertyPanel) && (_jsxs("div", { className: 'sf-export-panel', children: [enableExport && _jsx(ExportPanel, {}), _jsx("div", { className: 'sf-flex-one' }), enablePropertyPanel &&
|
|
30
|
+
_jsx(Button, { className: 'sf-show-hide-property-panel', icon: showSidePanel ? _jsx(ViewSideIcon, {}) : _jsx(ShowSidePanelIcon, {}), onClick: () => {
|
|
31
|
+
setShowSidePanel(!showSidePanel);
|
|
32
|
+
setRenderChart(false);
|
|
33
|
+
} })] })), _jsx("div", { className: 'sf-chart-panel sf-flex-one', children: renderChart && _jsx(ChartPanel, {}) })] }), enablePropertyPanel && showSidePanel &&
|
|
34
|
+
_jsx("div", { className: 'sf-property-panel', children: _jsx(PropertyPanel, {}) })] }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Tabbed property panel for chart configuration and formatting.
|
|
4
|
+
* Provides three main tabs:
|
|
5
|
+
* - **Chart Tab**: Select chart type and configure basic options
|
|
6
|
+
* - **Data Tab**: Choose category and series fields from data source
|
|
7
|
+
* - **Format Tab**: Customize visual appearance (colors, fonts, margins, axes)
|
|
8
|
+
*
|
|
9
|
+
* Internal component used by GridChartPanel on the right side panel.
|
|
10
|
+
*
|
|
11
|
+
* @private
|
|
12
|
+
* @returns {JSX.Element} Tabbed panel containing Chart, Data, and Format configuration tabs
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const PropertyPanel: () => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@syncfusion/react-navigations';
|
|
3
|
+
import { ChartTab } from './ChartTab';
|
|
4
|
+
import { DataTab } from './DataTab';
|
|
5
|
+
import { FormatTab } from './FormatTab';
|
|
6
|
+
/**
|
|
7
|
+
* Tabbed property panel for chart configuration and formatting.
|
|
8
|
+
* Provides three main tabs:
|
|
9
|
+
* - **Chart Tab**: Select chart type and configure basic options
|
|
10
|
+
* - **Data Tab**: Choose category and series fields from data source
|
|
11
|
+
* - **Format Tab**: Customize visual appearance (colors, fonts, margins, axes)
|
|
12
|
+
*
|
|
13
|
+
* Internal component used by GridChartPanel on the right side panel.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @returns {JSX.Element} Tabbed panel containing Chart, Data, and Format configuration tabs
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export const PropertyPanel = () => {
|
|
21
|
+
return (_jsxs(Tabs, { style: { width: '100%', height: '100%' }, children: [_jsxs(TabList, { children: [_jsx(Tab, { value: 'chart', children: "Chart" }), _jsx(Tab, { value: 'data', children: "Data" }), _jsx(Tab, { value: 'format', children: "Format" })] }), _jsxs(TabPanels, { children: [_jsx(TabPanel, { value: 'chart', children: _jsx(ChartTab, {}) }), _jsx(TabPanel, { value: 'data', children: _jsx(DataTab, {}) }), _jsx(TabPanel, { value: 'format', children: _jsx(FormatTab, {}) })] })] }));
|
|
22
|
+
};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './grid-chart';
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './grid-chart';
|
|
File without changes
|
|
File without changes
|