Skip to content

Commit bb189e7

Browse files
committed
adjusting dashEnableCharts -> dashChartMode
1 parent f9e0b8d commit bb189e7

4 files changed

Lines changed: 37 additions & 37 deletions

File tree

‎src/lib/components/AgGrid.react.js‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,42 +66,35 @@ function DashAgGrid(props) {
6666

6767
const {
6868
enableEnterpriseModules,
69-
dashEnableCharts,
69+
dashChartMode,
7070
dashGridOptions = {},
7171
} = props;
72-
const normalizedDashEnableCharts =
73-
typeof dashEnableCharts === 'undefined' || dashEnableCharts === null
72+
const normalizedDashChartMode =
73+
typeof dashChartMode === 'undefined' || dashChartMode === null
7474
? false
75-
: dashEnableCharts;
75+
: dashChartMode;
7676
const hasConflictingEnableChartsSetting =
77-
normalizedDashEnableCharts && dashGridOptions.enableCharts === false;
78-
const gridDashOptions = normalizedDashEnableCharts
77+
normalizedDashChartMode && dashGridOptions.enableCharts === false;
78+
const gridDashOptions = normalizedDashChartMode
7979
? {...dashGridOptions, enableCharts: true}
8080
: dashGridOptions;
8181
const hasEnableCharts = gridDashOptions?.enableCharts;
8282

83-
if (normalizedDashEnableCharts && !enableEnterpriseModules) {
83+
if (normalizedDashChartMode && !enableEnterpriseModules) {
8484
throw new Error(
85-
'dashEnableCharts is only supported when enableEnterpriseModules is true.'
85+
'dashChartMode is only supported when enableEnterpriseModules is true.'
8686
);
8787
}
8888

89-
if (
90-
normalizedDashEnableCharts &&
91-
normalizedDashEnableCharts !== 'enterprise'
92-
) {
93-
throw new Error("dashEnableCharts must be set to 'enterprise'.");
94-
}
95-
9689
if (hasConflictingEnableChartsSetting) {
9790
throw new Error(
98-
'dashEnableCharts cannot be combined with dashGridOptions.enableCharts=false.'
91+
'dashChartMode cannot be combined with dashGridOptions.enableCharts=false.'
9992
);
10093
}
10194

102-
if (hasEnableCharts && !normalizedDashEnableCharts) {
95+
if (hasEnableCharts && !normalizedDashChartMode) {
10396
throw new Error(
104-
"enableCharts is set, but chart modules are not loaded. Set enableEnterpriseModules=true and dashEnableCharts='enterprise'."
97+
"enableCharts is set, but chart modules are not loaded. Set enableEnterpriseModules=true and dashChartMode='community' or 'enterprise'."
10598
);
10699
}
107100

@@ -540,7 +533,7 @@ DashAgGrid.propTypes = {
540533
licenseKey: PropTypes.string,
541534

542535
/**
543-
* License key for AG Charts Enterprise when dashEnableCharts is "enterprise".
536+
* License key for AG Charts Enterprise when dashChartMode is "enterprise".
544537
* If not provided, licenseKey is used.
545538
*/
546539
chartsLicenseKey: PropTypes.string,
@@ -552,9 +545,9 @@ DashAgGrid.propTypes = {
552545

553546
/**
554547
* Load enterprise AG Charts modules for integrated charts.
555-
* Set to "enterprise" to load enterprise chart modules and set dashGridOptions.enableCharts=true.
548+
* Set to "enterprise" to load enterprise chart modules or use "community" for community chart modules and set dashGridOptions.enableCharts=true.
556549
*/
557-
dashEnableCharts: PropTypes.oneOf(['enterprise']),
550+
dashChartMode: PropTypes.oneOf(['enterprise', 'community']),
558551

559552
/**
560553
* The rowData in the grid after inline filters are applied.

‎src/lib/fragments/AgGridEnterprise.react.js‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
LicenseManager,
77
SparklinesModule,
88
} from 'ag-grid-enterprise';
9+
import {AgChartsCommunityModule} from 'ag-charts-community';
910
import {
1011
AgChartsEnterpriseModule,
1112
LicenseManager as AgChartsLicenseManager,
@@ -19,18 +20,24 @@ ModuleRegistry.registerModules([
1920
]);
2021

2122
export default function DashAgGridEnterprise(props) {
22-
const {licenseKey, chartsLicenseKey, dashEnableCharts} = props;
23+
const {licenseKey, chartsLicenseKey, dashChartMode} = props;
2324
if (licenseKey) {
2425
LicenseManager.setLicenseKey(licenseKey);
2526
}
26-
if (dashEnableCharts) {
27-
const effectiveChartsLicenseKey = chartsLicenseKey || licenseKey;
28-
if (effectiveChartsLicenseKey) {
29-
AgChartsLicenseManager.setLicenseKey(effectiveChartsLicenseKey);
27+
if (dashChartMode) {
28+
if (dashChartMode === 'enterprise') {
29+
const effectiveChartsLicenseKey = chartsLicenseKey || licenseKey;
30+
if (effectiveChartsLicenseKey) {
31+
AgChartsLicenseManager.setLicenseKey(effectiveChartsLicenseKey);
32+
}
33+
ModuleRegistry.registerModules([
34+
IntegratedChartsModule.with(AgChartsEnterpriseModule),
35+
]);
36+
} else {
37+
ModuleRegistry.registerModules([
38+
IntegratedChartsModule.with(AgChartsCommunityModule),
39+
]);
3040
}
31-
ModuleRegistry.registerModules([
32-
IntegratedChartsModule.with(AgChartsEnterpriseModule),
33-
]);
3441
}
3542
return <MemoizedAgGrid {...props} />;
3643
}

‎src/lib/utils/propCategories.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ export const PROPS_NOT_FOR_AG_GRID = [
343343
'setProps',
344344
'loading_state',
345345
'enableEnterpriseModules',
346-
'dashEnableCharts',
346+
'dashChartMode',
347347
'parentState',
348348
'persistence',
349349
'persisted_props',

‎tests/test_charts.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _make_basic_grid(**extra_props):
3939
def test_charts001_enables_enterprise_charts_modules_with_true(dash_duo):
4040
app = Dash(__name__)
4141
app.layout = html.Div(
42-
_make_chart_grid(enableEnterpriseModules=True, dashEnableCharts="enterprise")
42+
_make_chart_grid(enableEnterpriseModules=True, dashChartMode="enterprise")
4343
)
4444

4545
dash_duo.start_server(app)
@@ -58,7 +58,7 @@ def test_charts002_enables_enterprise_charts_modules(dash_duo):
5858
app.layout = html.Div(
5959
_make_chart_grid(
6060
enableEnterpriseModules=True,
61-
dashEnableCharts="enterprise",
61+
dashChartMode="enterprise",
6262
)
6363
)
6464

@@ -85,13 +85,13 @@ def test_charts003_keeps_enterprise_grid_without_charts(dash_duo):
8585

8686
def test_charts004_rejects_charts_on_community_grid(dash_duo):
8787
app = Dash(__name__)
88-
app.layout = html.Div(_make_chart_grid(dashEnableCharts="enterprise"))
88+
app.layout = html.Div(_make_chart_grid(dashChartMode="enterprise"))
8989

9090
dash_duo.start_server(app)
9191
until(lambda: dash_duo.find_element('#loaded').text == 'true', 10)
9292

9393
assert any(
94-
"dashEnableCharts is only supported when enableEnterpriseModules is true."
94+
"dashChartMode is only supported when enableEnterpriseModules is true."
9595
in entry.get("message", "")
9696
for entry in dash_duo.get_logs()
9797
)
@@ -118,7 +118,7 @@ def test_charts006_rejects_conflicting_enablecharts_false(dash_duo):
118118
app.layout = html.Div(
119119
_make_chart_grid(
120120
enableEnterpriseModules=True,
121-
dashEnableCharts="enterprise",
121+
dashChartMode="enterprise",
122122
dashGridOptions={"enableCharts": False},
123123
)
124124
)
@@ -127,7 +127,7 @@ def test_charts006_rejects_conflicting_enablecharts_false(dash_duo):
127127
until(lambda: dash_duo.find_element('#loaded').text == 'true', 10)
128128

129129
assert any(
130-
"dashEnableCharts cannot be combined with dashGridOptions.enableCharts=false."
130+
"dashChartMode cannot be combined with dashGridOptions.enableCharts=false."
131131
in entry.get("message", "")
132132
for entry in dash_duo.get_logs()
133133
)
@@ -138,7 +138,7 @@ def test_charts007_accepts_charts_license_key_prop(dash_duo):
138138
app.layout = html.Div(
139139
_make_chart_grid(
140140
enableEnterpriseModules=True,
141-
dashEnableCharts="enterprise",
141+
dashChartMode="enterprise",
142142
licenseKey="grid-key",
143143
chartsLicenseKey="charts-key",
144144
)

0 commit comments

Comments
 (0)