@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
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Syncfusion React Data Grid Component
|
|
2
|
+
|
|
3
|
+
The **Syncfusion React Data Grid** is a high-performance, feature-rich component designed for building scalable, responsive, and data-intensive web applications. Engineered to meet the requirements of enterprise-grade solutions, it provides a robust architecture that supports dynamic data handling, seamless integration with modern react frameworks, and a highly customizable interface.
|
|
4
|
+
|
|
5
|
+
Ideal for react applications requiring structured data presentation, real-time interaction, and flexible configuration, the grid supports essential functionalities such as sorting, filtering, paging, and editing. Extensibility is achieved through custom templates and a comprehensive API surface, enabling integration with complex business logic and external systems.
|
|
6
|
+
|
|
7
|
+
**Key Features**
|
|
8
|
+
|
|
9
|
+
- **[Sorting](https://react.syncfusion.com/react-ui/data-grid/sorting):**
|
|
10
|
+
Enables column-based sorting with support for single and multi-column configurations. Sorting operations are optimized for performance and consistency, allowing structured data to be organized efficiently across large datasets.
|
|
11
|
+
|
|
12
|
+
- **[Filtering](https://react.syncfusion.com/react-ui/data-grid/filtering/configuration):**
|
|
13
|
+
Provides a built-in filter bar with customizable filter types per column. Supports text, number, date, and dropdown filters, enabling precise data segmentation and contextual filtering based on business logic.
|
|
14
|
+
|
|
15
|
+
- **[Editing](https://react.syncfusion.com/react-ui/data-grid/editing/configuration):**
|
|
16
|
+
Facilitates inline CRUD operations including add, edit, and delete actions. Editing is integrated with toolbar controls and supports validation, making it suitable for transactional data entry and real-time updates.
|
|
17
|
+
|
|
18
|
+
- **[Toolbar](https://react.syncfusion.com/react-ui/data-grid/editing/configuration#adding-a-toolbar-for-editing):**
|
|
19
|
+
Offers a configurable toolbar with built-in actions such as Add, Edit, Delete, and Search. Toolbar elements can be extended or replaced with custom components to align with specific operational workflows.
|
|
20
|
+
|
|
21
|
+
- **[Searching](https://react.syncfusion.com/react-ui/data-grid/searching):**
|
|
22
|
+
Includes a responsive search box within the toolbar for quick data lookup. Supports keyword-based filtering across multiple columns, improving accessibility to relevant records in large datasets.
|
|
23
|
+
|
|
24
|
+
- **[Paging](https://react.syncfusion.com/react-ui/data-grid/paging):**
|
|
25
|
+
Manages large volumes of data using built-in pagination. Supports both client-side and server-side paging strategies to ensure scalable performance and efficient data navigation in distributed environments.
|
|
26
|
+
|
|
27
|
+
- **[Grouping](https://react.syncfusion.com/react-ui/data-grid/grouping/configuration):** Organizes data into hierarchical groups for better analysis.
|
|
28
|
+
|
|
29
|
+
- **[Stacked Headers](https://react.syncfusion.com/react-ui/data-grid/columns/configuration#stacked-headers):** Organizes related columns under multiple levels of headers for clearer data presentation and improved column structure.
|
|
30
|
+
|
|
31
|
+
- **[Clipboard](https://react.syncfusion.com/react-ui/data-grid/clipboard):** Supports copying and pasting cell and row selections through the Grid clipboard API for efficient data transfer and editing.
|
|
32
|
+
|
|
33
|
+
- **[Row & Column Spanning](https://react.syncfusion.com/react-ui/data-grid/row/row-spanning):** Supports merging cells across rows and columns for advanced layouts.
|
|
34
|
+
|
|
35
|
+
- **[Master-Detail](https://react.syncfusion.com/react-ui/data-grid/master-detail/detail-grid):** Displays hierarchical data using expandable detail rows.
|
|
36
|
+
|
|
37
|
+
- **[DOM Virtualization & Virtual Scrolling](https://react.syncfusion.com/react-ui/data-grid/scrolling/virtual-scroll/):**
|
|
38
|
+
Enables efficient rendering of large datasets with improved performance and responsiveness through intelligent DOM virtualization and virtual scrolling techniques.
|
|
39
|
+
|
|
40
|
+
- **[Infinite Scrolling](https://react.syncfusion.com/react-ui/data-grid/scrolling/infinite-scroll/):**
|
|
41
|
+
Enables continuous data loading during scroll actions without pagination. Designed for scenarios where the total record count is unknown, it dynamically retrieves additional data from the server data source as the user scrolls, ensuring a seamless and uninterrupted browsing experience.
|
|
42
|
+
|
|
43
|
+
- **[Excel Mode & CheckBox Filtering](https://react.syncfusion.com/react-ui/data-grid/filtering/checkbox-filtering/):**
|
|
44
|
+
Provides advanced filtering options with intuitive, checkbox-based selection for precise data segmentation. Includes Excel-mode filtering for enhanced user experience.
|
|
45
|
+
|
|
46
|
+
- **[PDF Export](https://react.syncfusion.com/react-ui/data-grid/pdf-export):** Exports Grid data to PDF while preserving layout and styling.
|
|
47
|
+
|
|
48
|
+
- **[Print](https://react.syncfusion.com/react-ui/data-grid/print):** Supports direct printing of Grid content with structured formatting.
|
|
49
|
+
|
|
50
|
+
- **[Checkbox Selection](https://react.syncfusion.com/react-ui/data-grid/selection/checkbox-selection/):**
|
|
51
|
+
Supports multi-row selection, allowing users to select multiple rows efficiently using checkboxes integrated within the grid interface.
|
|
52
|
+
|
|
53
|
+
- **[Column Chooser](https://react.syncfusion.com/react-ui/data-grid/columns/column-chooser/):** Allows users to dynamically show or hide columns.
|
|
54
|
+
|
|
55
|
+
- **[Context Menu](https://react.syncfusion.com/react-ui/data-grid/context-menu):** Provides customizable right-click actions for enhanced interaction.
|
|
56
|
+
|
|
57
|
+
- **[Customization](https://react.syncfusion.com/react-ui/data-grid/columns/cell-customization):**
|
|
58
|
+
Allows custom cell rendering, conditional styling, and layout adjustments. Enables integration with design systems and branding guidelines, supporting tailored visual experiences and functional enhancements.
|
|
59
|
+
|
|
60
|
+
- **[Template Extensibility](https://react.syncfusion.com/react-ui/data-grid/columns/templates):**
|
|
61
|
+
Supports column and row templates for embedding custom components, applying conditional formatting, and creating rich, interactive visual layouts. Template logic can be used to integrate charts, buttons, or nested views within grid cells.
|
|
62
|
+
|
|
63
|
+
- **[Aggregates](https://react.syncfusion.com/react-ui/data-grid/aggregates):**
|
|
64
|
+
Displays summary values such as totals, averages, minimums, and maximums using built-in aggregate functions. Aggregation logic can be customized to support analytical dashboards and reporting interfaces.
|
|
65
|
+
|
|
66
|
+
- **[Interactivity](https://react.syncfusion.com/react-ui/data-grid/accessibility#keyboard-shortcuts):**
|
|
67
|
+
Supports clickable headers, row & cell selection, and keyboard navigation. Enhances engagement through responsive UI behavior and intuitive controls, suitable for complex data exploration scenarios.
|
|
68
|
+
|
|
69
|
+
- **[Accessibility](https://react.syncfusion.com/react-ui/data-grid/accessibility):**
|
|
70
|
+
Compliant with WCAG 2.1 standards, ensuring compatibility with screen readers, keyboard navigation, and assistive technologies. Designed to meet accessibility requirements for public sector and regulated environments.
|
|
71
|
+
|
|
72
|
+
- **[Globalization](https://react.syncfusion.com/react-ui/data-grid/globalization):**
|
|
73
|
+
Adapts dates, numbers, currencies, and text formats for international audiences. Includes built-in support for localization and internationalization (i18n), enabling deployment across multilingual and multicultural platforms.
|
|
74
|
+
|
|
75
|
+
- **[Robust API](https://react.syncfusion.com/api/data-grid/overview):**
|
|
76
|
+
Provides a comprehensive and extensible API for programmatic control over grid behavior, data updates, and event handling. Supports integration with external systems, custom business logic, and advanced workflow automation.
|
|
77
|
+
|
|
78
|
+
**Setup**
|
|
79
|
+
|
|
80
|
+
To install `grid` and its dependent packages, use the following command,
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm install @syncfusion/react-grid
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Usage**
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Grid, Columns, Column } from '@syncfusion/react-grid';
|
|
90
|
+
|
|
91
|
+
export default function App() {
|
|
92
|
+
return (
|
|
93
|
+
<Grid dataSource={data} pageSettings={{ enabled: true }}>
|
|
94
|
+
<Columns>
|
|
95
|
+
<Column field="OrderID" headerText="Order ID" width="120" textAlign="Right"/>
|
|
96
|
+
<Column field="CustomerName" headerText="Customer Name" width="120"/>
|
|
97
|
+
<Column field="Freight" format="C2" width="120" textAlign="Right"/>
|
|
98
|
+
<Column field="OrderDate" headerText="Order Date" format="yMd" width="120" textAlign="Right"/>
|
|
99
|
+
<Column field="ShipCountry" headerText="Ship Country" width="140"/>
|
|
100
|
+
</Columns>
|
|
101
|
+
</Grid>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Resources**
|
|
107
|
+
|
|
108
|
+
- [Data Grid Demo/Docs](https://react.syncfusion.com/react-ui/data-grid/overview)
|
|
109
|
+
- [Data Grid API](https://react.syncfusion.com/api/data-grid/overview)
|
|
110
|
+
|
|
111
|
+
<p align="center">
|
|
112
|
+
Trusted by the world's leading companies
|
|
113
|
+
<a href="https://www.syncfusion.com/">
|
|
114
|
+
<img src="https://raw.githubusercontent.com/SyncfusionExamples/nuget-img/master/syncfusion/syncfusion-trusted-companies.webp" alt="Syncfusion logo">
|
|
115
|
+
</a>
|
|
116
|
+
</p>
|
|
117
|
+
|
|
118
|
+
## Support
|
|
119
|
+
|
|
120
|
+
Product support is available through following mediums.
|
|
121
|
+
|
|
122
|
+
* [Support ticket](https://support.syncfusion.com/support/tickets/create) - Guaranteed Response in 24 hours | Unlimited tickets | Holiday support
|
|
123
|
+
* Live chat
|
|
124
|
+
|
|
125
|
+
## Changelog
|
|
126
|
+
Check the changelog [here](https://github.com/syncfusion/react-ui-components/blob/master/components/grid/CHANGELOG.md). Get minor improvements and bug fixes every week to stay up to date with frequent updates.
|
|
127
|
+
|
|
128
|
+
## License and copyright
|
|
129
|
+
|
|
130
|
+
> This is a commercial product and requires a paid license for possession or use. Syncfusion’s licensed software, including this component, is subject to the terms and conditions of Syncfusion's [EULA](https://www.syncfusion.com/eula/es/). To acquire a license for [React UI components](https://www.syncfusion.com/react-components), you can [purchase](https://www.syncfusion.com/sales/products) or [start a free 30-day trial](https://www.syncfusion.com/account/manage-trials/start-trials).
|
|
131
|
+
|
|
132
|
+
> A [free community license](https://www.syncfusion.com/products/communitylicense) is also available for companies and individuals whose organizations have less than $1 million USD in annual gross revenue and five or fewer developers.
|
|
133
|
+
|
|
134
|
+
See [LICENSE FILE](https://github.com/syncfusion/react-ui-components/blob/master/license?utm_source=npm&utm_campaign=notification) for more info.
|
|
135
|
+
|
|
136
|
+
© Copyright 2026 Syncfusion®, Inc. All Rights Reserved. The Syncfusion® Essential Studio® license and copyright applies to this distribution.
|
package/grid-chart.d.ts
ADDED
package/grid-chart.js
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
package/license
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Syncfusion® License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Syncfusion®, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Essential® JS 2 library is available through the Syncfusion® Essential Studio® program and can be licensed under either the Syncfusion® Community License Program or the Syncfusion® Commercial License.
|
|
6
|
+
|
|
7
|
+
To qualify for the Syncfusion® Community License Program, your organization must have annual gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and fewer than five (5) developers. Additionally, you must agree to Syncfusion®’s terms and conditions.
|
|
8
|
+
|
|
9
|
+
If you do not meet the requirements for the community license, please reach out to sales@syncfusion.com for commercial licensing options.
|
|
10
|
+
|
|
11
|
+
You are required to obtain either a Community License or a Commercial License before using this product and must agree to comply with Syncfusion®'s terms and conditions.
|
|
12
|
+
|
|
13
|
+
The full Syncfusion® license, including terms and conditions, can be found at: https://www.syncfusion.com/content/downloads/syncfusion_license.pdf
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@syncfusion/react-grid-chart",
|
|
3
|
+
"version": "35.1.37",
|
|
4
|
+
"description": "Syncfusion React Data Grid Chart, a high-performance component designed for modern web applications.",
|
|
5
|
+
"author": "Syncfusion Inc.",
|
|
6
|
+
"license": "SEE LICENSE IN license",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"web-components",
|
|
9
|
+
"react",
|
|
10
|
+
"syncfusion-react",
|
|
11
|
+
"react-grid-chart",
|
|
12
|
+
"grid-chart",
|
|
13
|
+
"grid-chart-component",
|
|
14
|
+
"react-grid-chart-component",
|
|
15
|
+
"react-grid-chart-layout"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/syncfusion/react-ui-components.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://www.syncfusion.com/react-ui-components",
|
|
22
|
+
"module": "./index.js",
|
|
23
|
+
"readme": "README.md",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@syncfusion/react-buttons": "~35.1.37",
|
|
26
|
+
"@syncfusion/react-charts": "~35.1.37",
|
|
27
|
+
"@syncfusion/react-dropdowns": "~35.1.37",
|
|
28
|
+
"@syncfusion/react-grid": "~35.1.37",
|
|
29
|
+
"@syncfusion/react-inputs": "~35.1.37",
|
|
30
|
+
"@syncfusion/react-navigations": "~35.1.37",
|
|
31
|
+
"@syncfusion/react-popups": "~35.1.37",
|
|
32
|
+
"@syncfusion/react-splitbuttons": "~35.1.37"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {},
|
|
35
|
+
"typings": "index.d.ts",
|
|
36
|
+
"sideEffects": false
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
interface ColorPickerProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange?: (color: string) => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Color picker component providing both visual and text-based color selection.
|
|
9
|
+
* Displays a native HTML color input alongside a text field for hex code entry.
|
|
10
|
+
* Used in the Format tab for selecting colors for titles, axes, legends, and series.
|
|
11
|
+
*
|
|
12
|
+
* @param {ColorPickerProps} props - Component props
|
|
13
|
+
* @param {string} [props.value] - Current hex color value (e.g., '#FF6B6B')
|
|
14
|
+
* @param {Function} [props.onChange] - Callback fired when color changes, receives new hex value
|
|
15
|
+
* @param {string} [props.className] - CSS class name for styling the container
|
|
16
|
+
* @returns {JSX.Element} Color picker component with visual and text input
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const [color, setColor] = useState('#FF6B6B');
|
|
21
|
+
*
|
|
22
|
+
* <ColorPicker
|
|
23
|
+
* value={color}
|
|
24
|
+
* onChange={(newColor) => setColor(newColor)}
|
|
25
|
+
* className="sf-color-picker"
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const ColorPicker: ({ value, onChange, className }: ColorPickerProps) => JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Color picker component providing both visual and text-based color selection.
|
|
4
|
+
* Displays a native HTML color input alongside a text field for hex code entry.
|
|
5
|
+
* Used in the Format tab for selecting colors for titles, axes, legends, and series.
|
|
6
|
+
*
|
|
7
|
+
* @param {ColorPickerProps} props - Component props
|
|
8
|
+
* @param {string} [props.value] - Current hex color value (e.g., '#FF6B6B')
|
|
9
|
+
* @param {Function} [props.onChange] - Callback fired when color changes, receives new hex value
|
|
10
|
+
* @param {string} [props.className] - CSS class name for styling the container
|
|
11
|
+
* @returns {JSX.Element} Color picker component with visual and text input
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const [color, setColor] = useState('#FF6B6B');
|
|
16
|
+
*
|
|
17
|
+
* <ColorPicker
|
|
18
|
+
* value={color}
|
|
19
|
+
* onChange={(newColor) => setColor(newColor)}
|
|
20
|
+
* className="sf-color-picker"
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const ColorPicker = ({ value, onChange, className }) => {
|
|
25
|
+
return (_jsxs("div", { className: className, style: { display: 'flex', gap: '8px', alignItems: 'center' }, children: [_jsx("input", { type: "color", value: value, onChange: (e) => onChange?.(e.target.value), style: {
|
|
26
|
+
width: '50px',
|
|
27
|
+
height: '40px',
|
|
28
|
+
border: '1px solid #ccc',
|
|
29
|
+
borderRadius: '4px',
|
|
30
|
+
cursor: 'pointer'
|
|
31
|
+
} }), _jsx("input", { type: "text", value: value, onChange: (e) => onChange?.(e.target.value), style: {
|
|
32
|
+
padding: '8px',
|
|
33
|
+
border: '1px solid #ccc',
|
|
34
|
+
borderRadius: '4px',
|
|
35
|
+
width: '100px',
|
|
36
|
+
fontFamily: 'monospace',
|
|
37
|
+
fontSize: '12px'
|
|
38
|
+
} })] }));
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ColorPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ColorPicker';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { GridChartContextType, GridChartProviderProps } from '../types/grid-chart.interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Provider component that wraps children with GridChart context.
|
|
5
|
+
* Initializes and manages centralized state for chart configuration, formatting, and UI state.
|
|
6
|
+
* Must wrap any component using the useGridChartSettings hook.
|
|
7
|
+
*
|
|
8
|
+
* @param {GridChartProviderProps} props - Component props
|
|
9
|
+
* @param {ReactElement} props.children - Child components to wrap with context
|
|
10
|
+
* @param {RefObject<GridChartSettings>} props.settings - Reference to GridChart settings
|
|
11
|
+
* @returns {JSX.Element} The provider component wrapping children with context
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const settingsRef = useRef<GridChartSettings>({
|
|
16
|
+
* chart: 'Column',
|
|
17
|
+
* dataSource: data,
|
|
18
|
+
* category: ['Date'],
|
|
19
|
+
* series: ['Sales']
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* <GridChartProvider settings={settingsRef}>
|
|
23
|
+
* <GridChartPanel />
|
|
24
|
+
* </GridChartProvider>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const GridChartProvider: ({ children, settings }: GridChartProviderProps) => JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* Hook to access GridChart context from any child component.
|
|
30
|
+
* Must be called within a component tree wrapped by GridChartProvider.
|
|
31
|
+
* Provides access to chart state, formatting, and axis configuration.
|
|
32
|
+
*
|
|
33
|
+
* @returns {GridChartContextType} The GridChart context object containing:
|
|
34
|
+
* - settings: Current chart settings reference
|
|
35
|
+
* - chartInfo, setChartInfo: Chart type and classification
|
|
36
|
+
* - categoryAxis, setCategoryAxis: Category field selection
|
|
37
|
+
* - series, setSeries: Series field selection
|
|
38
|
+
* - valueAxis, setValueAxis: Value field selection
|
|
39
|
+
* - chartRef, pieChartRef: References to chart components
|
|
40
|
+
* - showSidePanel, setShowSidePanel: Property panel visibility
|
|
41
|
+
* - format, setFormat: Chart formatting configuration
|
|
42
|
+
* @throws {Error} If called outside of GridChartProvider
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* function MyChartComponent() {
|
|
47
|
+
* const { chartInfo, setChartInfo, format, setFormat } = useGridChartSettings();
|
|
48
|
+
*
|
|
49
|
+
* const handleChartChange = (newChart: ChartType) => {
|
|
50
|
+
* setChartInfo(getChartInfo(newChart));
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* return (
|
|
54
|
+
* <div>
|
|
55
|
+
* <p>Current Chart: {chartInfo.chart}</p>
|
|
56
|
+
* <button onClick={() => handleChartChange('Pie')}>
|
|
57
|
+
* Switch to Pie Chart
|
|
58
|
+
* </button>
|
|
59
|
+
* </div>
|
|
60
|
+
* );
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const useGridChartSettings: () => GridChartContextType;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState, useRef } from 'react';
|
|
3
|
+
import { getChartInfo } from '../utils/utils';
|
|
4
|
+
const GridChartContext = createContext(undefined);
|
|
5
|
+
/* eslint-disable jsdoc/no-undefined-types */
|
|
6
|
+
/**
|
|
7
|
+
* Provider component that wraps children with GridChart context.
|
|
8
|
+
* Initializes and manages centralized state for chart configuration, formatting, and UI state.
|
|
9
|
+
* Must wrap any component using the useGridChartSettings hook.
|
|
10
|
+
*
|
|
11
|
+
* @param {GridChartProviderProps} props - Component props
|
|
12
|
+
* @param {ReactElement} props.children - Child components to wrap with context
|
|
13
|
+
* @param {RefObject<GridChartSettings>} props.settings - Reference to GridChart settings
|
|
14
|
+
* @returns {JSX.Element} The provider component wrapping children with context
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const settingsRef = useRef<GridChartSettings>({
|
|
19
|
+
* chart: 'Column',
|
|
20
|
+
* dataSource: data,
|
|
21
|
+
* category: ['Date'],
|
|
22
|
+
* series: ['Sales']
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* <GridChartProvider settings={settingsRef}>
|
|
26
|
+
* <GridChartPanel />
|
|
27
|
+
* </GridChartProvider>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
/* eslint-enable jsdoc/no-undefined-types */
|
|
31
|
+
export const GridChartProvider = ({ children, settings }) => {
|
|
32
|
+
const [chartInfo, setChartInfo] = useState(getChartInfo(settings.current.chart));
|
|
33
|
+
const [categoryAxis, setCategoryAxis] = useState(settings.current.category[0]);
|
|
34
|
+
const [series, setSeries] = useState(settings.current.series);
|
|
35
|
+
const [valueAxis, setValueAxis] = useState(settings.current.series[0]);
|
|
36
|
+
const [showSidePanel, setShowSidePanel] = useState(true);
|
|
37
|
+
const chartRef = useRef(null);
|
|
38
|
+
const pieChartRef = useRef(null);
|
|
39
|
+
const [format, setFormat] = useState(() => {
|
|
40
|
+
const chartSeriesStyle = settings.current.series.map((data) => {
|
|
41
|
+
return { series: data, fill: '', enableDataLabel: false };
|
|
42
|
+
});
|
|
43
|
+
chartSeriesStyle.push({ series: 'All', fill: '', enableDataLabel: false });
|
|
44
|
+
return {
|
|
45
|
+
marginLeft: 10,
|
|
46
|
+
marginRight: 10,
|
|
47
|
+
marginTop: 10,
|
|
48
|
+
marginBottom: 10,
|
|
49
|
+
background: '#FFFFFF',
|
|
50
|
+
// Title Style defaults
|
|
51
|
+
titleText: '',
|
|
52
|
+
titleFontFamily: 'Default',
|
|
53
|
+
titleFontSize: '15',
|
|
54
|
+
titleColor: '#000000',
|
|
55
|
+
// Subtitle Style defaults
|
|
56
|
+
subtitleText: '',
|
|
57
|
+
subtitleFontFamily: 'Default',
|
|
58
|
+
subtitleFontSize: '12',
|
|
59
|
+
subtitleColor: '#333333',
|
|
60
|
+
// Legend Style defaults
|
|
61
|
+
enableLegend: true,
|
|
62
|
+
legendPosition: 'Auto',
|
|
63
|
+
legendFontFamily: 'Default',
|
|
64
|
+
legendFontSize: '12',
|
|
65
|
+
legendColor: '#000000',
|
|
66
|
+
// Series
|
|
67
|
+
enableTooltip: true,
|
|
68
|
+
enablePieChartDataLabel: true,
|
|
69
|
+
chartSeriesStyle,
|
|
70
|
+
categoryInverted: false,
|
|
71
|
+
valueInverted: false,
|
|
72
|
+
categoryTitleText: '',
|
|
73
|
+
categoryTitleFontFamily: 'Default',
|
|
74
|
+
categoryTitleFontSize: '16',
|
|
75
|
+
categoryTitleColor: '#000000',
|
|
76
|
+
valueTitleText: '',
|
|
77
|
+
valueTitleFontFamily: 'Default',
|
|
78
|
+
valueTitleFontSize: '11',
|
|
79
|
+
valueTitleColor: '#000000',
|
|
80
|
+
categoryLabelFontFamily: 'Default',
|
|
81
|
+
categoryLabelFontSize: '12',
|
|
82
|
+
categoryLabelColor: '#000000',
|
|
83
|
+
categoryLabelRotation: 315,
|
|
84
|
+
valueLabelFontFamily: 'Default',
|
|
85
|
+
valueLabelFontSize: '12',
|
|
86
|
+
valueLabelColor: '#000000',
|
|
87
|
+
valueLabelRotation: 0
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
return (_jsx(GridChartContext.Provider, { value: {
|
|
91
|
+
settings,
|
|
92
|
+
chartInfo, setChartInfo,
|
|
93
|
+
categoryAxis, setCategoryAxis,
|
|
94
|
+
series, setSeries,
|
|
95
|
+
valueAxis, setValueAxis,
|
|
96
|
+
chartRef, pieChartRef,
|
|
97
|
+
showSidePanel, setShowSidePanel,
|
|
98
|
+
format, setFormat
|
|
99
|
+
}, children: children }));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Hook to access GridChart context from any child component.
|
|
103
|
+
* Must be called within a component tree wrapped by GridChartProvider.
|
|
104
|
+
* Provides access to chart state, formatting, and axis configuration.
|
|
105
|
+
*
|
|
106
|
+
* @returns {GridChartContextType} The GridChart context object containing:
|
|
107
|
+
* - settings: Current chart settings reference
|
|
108
|
+
* - chartInfo, setChartInfo: Chart type and classification
|
|
109
|
+
* - categoryAxis, setCategoryAxis: Category field selection
|
|
110
|
+
* - series, setSeries: Series field selection
|
|
111
|
+
* - valueAxis, setValueAxis: Value field selection
|
|
112
|
+
* - chartRef, pieChartRef: References to chart components
|
|
113
|
+
* - showSidePanel, setShowSidePanel: Property panel visibility
|
|
114
|
+
* - format, setFormat: Chart formatting configuration
|
|
115
|
+
* @throws {Error} If called outside of GridChartProvider
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```tsx
|
|
119
|
+
* function MyChartComponent() {
|
|
120
|
+
* const { chartInfo, setChartInfo, format, setFormat } = useGridChartSettings();
|
|
121
|
+
*
|
|
122
|
+
* const handleChartChange = (newChart: ChartType) => {
|
|
123
|
+
* setChartInfo(getChartInfo(newChart));
|
|
124
|
+
* };
|
|
125
|
+
*
|
|
126
|
+
* return (
|
|
127
|
+
* <div>
|
|
128
|
+
* <p>Current Chart: {chartInfo.chart}</p>
|
|
129
|
+
* <button onClick={() => handleChartChange('Pie')}>
|
|
130
|
+
* Switch to Pie Chart
|
|
131
|
+
* </button>
|
|
132
|
+
* </div>
|
|
133
|
+
* );
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export const useGridChartSettings = () => {
|
|
138
|
+
const context = useContext(GridChartContext);
|
|
139
|
+
return context;
|
|
140
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GridChartContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GridChartContext';
|