@genesislcap/ai-assistant 15.69.0 → 15.71.0-FUI-2650.1
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/dist/ai-assistant.api.json +97 -0
- package/dist/ai-assistant.d.ts +65 -0
- package/dist/chat-driver.cjs +18031 -0
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +18024 -0
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +5524 -2684
- package/dist/dts/chat-driver-node.d.ts +2 -0
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/dts/code-review/code-review.types.d.ts +76 -0
- package/dist/dts/code-review/code-review.types.d.ts.map +1 -0
- package/dist/dts/code-review/code-reviewer.agent.d.ts +77 -0
- package/dist/dts/code-review/code-reviewer.agent.d.ts.map +1 -0
- package/dist/dts/code-review/code-reviewer.prompt.d.ts +23 -0
- package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +1 -0
- package/dist/dts/code-review/gate.d.ts +44 -0
- package/dist/dts/code-review/gate.d.ts.map +1 -0
- package/dist/dts/code-review/index.d.ts +27 -0
- package/dist/dts/code-review/index.d.ts.map +1 -0
- package/dist/dts/code-review/review-changes.d.ts +70 -0
- package/dist/dts/code-review/review-changes.d.ts.map +1 -0
- package/dist/dts/code-review/rules/context-trigger-map.d.ts +6 -0
- package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +1 -0
- package/dist/dts/code-review/rules/context.registry.d.ts +123 -0
- package/dist/dts/code-review/rules/context.registry.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +13 -0
- package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-blotter.d.ts +16 -0
- package/dist/dts/code-review/rules/fui-blotter.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-chart.d.ts +20 -0
- package/dist/dts/code-review/rules/fui-chart.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-column-defs.d.ts +21 -0
- package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-components.d.ts +9 -0
- package/dist/dts/code-review/rules/fui-components.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-criteria.d.ts +32 -0
- package/dist/dts/code-review/rules/fui-criteria.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +15 -0
- package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-dashboard.d.ts +19 -0
- package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-dialogs.d.ts +19 -0
- package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-entity-management.d.ts +19 -0
- package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-error-boundary.d.ts +9 -0
- package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-eventing.d.ts +8 -0
- package/dist/dts/code-review/rules/fui-eventing.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-flexlayout.d.ts +17 -0
- package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +10 -0
- package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-form-component.d.ts +9 -0
- package/dist/dts/code-review/rules/fui-form-component.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-formatters.d.ts +12 -0
- package/dist/dts/code-review/rules/fui-formatters.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +10 -0
- package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-global-filters.d.ts +33 -0
- package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-import-surface.d.ts +37 -0
- package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-inline-editing.d.ts +10 -0
- package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-layout.d.ts +7 -0
- package/dist/dts/code-review/rules/fui-layout.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-notifications.d.ts +12 -0
- package/dist/dts/code-review/rules/fui-notifications.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-primitives.d.ts +26 -0
- package/dist/dts/code-review/rules/fui-primitives.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +18 -0
- package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-redux-store.d.ts +8 -0
- package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-reporting.d.ts +19 -0
- package/dist/dts/code-review/rules/fui-reporting.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-styling.d.ts +15 -0
- package/dist/dts/code-review/rules/fui-styling.d.ts.map +1 -0
- package/dist/dts/code-review/rules/fui-trade-form.d.ts +13 -0
- package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +1 -0
- package/dist/dts/code-review/submit-code-review.tool.d.ts +12 -0
- package/dist/dts/code-review/submit-code-review.tool.d.ts.map +1 -0
- package/dist/dts/code-review/unified-diff.d.ts +7 -0
- package/dist/dts/code-review/unified-diff.d.ts.map +1 -0
- package/dist/dts/code-review/verdict.d.ts +23 -0
- package/dist/dts/code-review/verdict.d.ts.map +1 -0
- package/dist/dts/components/code-review-result/code-review-result.d.ts +26 -0
- package/dist/dts/components/code-review-result/code-review-result.d.ts.map +1 -0
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/react.d.ts +20 -10
- package/dist/esm/chat-driver-node.js +6 -0
- package/dist/esm/code-review/code-review.types.js +6 -0
- package/dist/esm/code-review/code-reviewer.agent.js +167 -0
- package/dist/esm/code-review/code-reviewer.prompt.js +103 -0
- package/dist/esm/code-review/gate.js +93 -0
- package/dist/esm/code-review/index.js +28 -0
- package/dist/esm/code-review/review-changes.js +123 -0
- package/dist/esm/code-review/rules/context-trigger-map.js +20 -0
- package/dist/esm/code-review/rules/context.registry.js +772 -0
- package/dist/esm/code-review/rules/fui-ai-extensions.js +306 -0
- package/dist/esm/code-review/rules/fui-blotter.js +596 -0
- package/dist/esm/code-review/rules/fui-chart.js +669 -0
- package/dist/esm/code-review/rules/fui-column-defs.js +862 -0
- package/dist/esm/code-review/rules/fui-components.js +245 -0
- package/dist/esm/code-review/rules/fui-criteria.js +538 -0
- package/dist/esm/code-review/rules/fui-custom-renderer.js +612 -0
- package/dist/esm/code-review/rules/fui-dashboard.js +604 -0
- package/dist/esm/code-review/rules/fui-dialogs.js +588 -0
- package/dist/esm/code-review/rules/fui-entity-management.js +1014 -0
- package/dist/esm/code-review/rules/fui-error-boundary.js +244 -0
- package/dist/esm/code-review/rules/fui-eventing.js +628 -0
- package/dist/esm/code-review/rules/fui-flexlayout.js +860 -0
- package/dist/esm/code-review/rules/fui-flyout-panel.js +432 -0
- package/dist/esm/code-review/rules/fui-form-component.js +898 -0
- package/dist/esm/code-review/rules/fui-formatters.js +415 -0
- package/dist/esm/code-review/rules/fui-foundation-comms.js +518 -0
- package/dist/esm/code-review/rules/fui-global-filters.js +778 -0
- package/dist/esm/code-review/rules/fui-import-surface.js +452 -0
- package/dist/esm/code-review/rules/fui-inline-editing.js +445 -0
- package/dist/esm/code-review/rules/fui-layout.js +431 -0
- package/dist/esm/code-review/rules/fui-notifications.js +439 -0
- package/dist/esm/code-review/rules/fui-primitives.js +1216 -0
- package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +650 -0
- package/dist/esm/code-review/rules/fui-redux-store.js +522 -0
- package/dist/esm/code-review/rules/fui-reporting.js +506 -0
- package/dist/esm/code-review/rules/fui-styling.js +1229 -0
- package/dist/esm/code-review/rules/fui-trade-form.js +618 -0
- package/dist/esm/code-review/submit-code-review.tool.js +43 -0
- package/dist/esm/code-review/unified-diff.js +96 -0
- package/dist/esm/code-review/verdict.js +24 -0
- package/dist/esm/components/code-review-result/code-review-result.js +89 -0
- package/dist/esm/index.js +3 -0
- package/dist/react.cjs +25 -18
- package/dist/react.mjs +23 -17
- package/docs/code-review.md +137 -0
- package/package.json +24 -17
- package/scripts/smoke-chat-driver-node.mjs +15 -0
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context: G2PlotChart — chart component from @genesislcap/g2plot-chart/react
|
|
3
|
+
*
|
|
4
|
+
* Sources verified against:
|
|
5
|
+
* - foundation-marketplace/charts/g2plot-chart/dist/dts/react.d.ts
|
|
6
|
+
* - foundation-marketplace/charts/g2plot-chart/dist/dts/chart.types.d.ts
|
|
7
|
+
* - foundation-marketplace/charts/g2plot-chart/src/chart.ts (initalizeConfiguration → legend behaviour)
|
|
8
|
+
* - foundation-marketplace/charts/g2plot-chart/src/chart-datasource/chart-datasource.ts
|
|
9
|
+
* - foundation-marketplace/charts/g2plot-chart/src/chart-datasource/chart-datasource.utils.ts
|
|
10
|
+
* (getReduced, getNormalizedFieldValue — BigDecimal string → number normalization)
|
|
11
|
+
* - foundation-marketplace/charts/g2plot-chart/src/models/*.ts (per-type Rapid styling defaults)
|
|
12
|
+
* - foundation-marketplace/charts/g2plot-chart/src/settings/colors.ts (chartsGradients palette)
|
|
13
|
+
* - node_modules/@antv/g2plot@2.4.35 typings (lib/types/common.d.ts Options, per-plot types.d.ts)
|
|
14
|
+
* - showcase react-client/src/pages/Charts (tabbed charts reference page)
|
|
15
|
+
* - blank-app-seed/.genx/templates/react/chart.hbs
|
|
16
|
+
*/
|
|
17
|
+
// fui-formatters is NOT a hard dependency — chart config objects do not use formatter functions
|
|
18
|
+
// directly (unlike grid ColDefs). Add it only when the user also needs label/tooltip formatters.
|
|
19
|
+
export const FUI_CHART_DEPS = [];
|
|
20
|
+
export const FUI_CHART_TAGS = [
|
|
21
|
+
// non-developer (intent phrases)
|
|
22
|
+
'chart',
|
|
23
|
+
'charts',
|
|
24
|
+
'graph',
|
|
25
|
+
'graphs',
|
|
26
|
+
'analytics',
|
|
27
|
+
'visualise',
|
|
28
|
+
'visualize',
|
|
29
|
+
'visualisation',
|
|
30
|
+
'visualization',
|
|
31
|
+
'data visualization',
|
|
32
|
+
'show a chart',
|
|
33
|
+
'add a chart',
|
|
34
|
+
'chart tile',
|
|
35
|
+
'chart panel',
|
|
36
|
+
'chart dashboard',
|
|
37
|
+
'pie chart',
|
|
38
|
+
'donut chart',
|
|
39
|
+
'line chart',
|
|
40
|
+
'bar chart',
|
|
41
|
+
'column chart',
|
|
42
|
+
'area chart',
|
|
43
|
+
'rose chart',
|
|
44
|
+
'scatter chart',
|
|
45
|
+
'stock chart',
|
|
46
|
+
'dual axes chart',
|
|
47
|
+
'mix chart',
|
|
48
|
+
'multi-series chart',
|
|
49
|
+
'grouped chart',
|
|
50
|
+
'stacked chart',
|
|
51
|
+
'plot data',
|
|
52
|
+
'display data graphically',
|
|
53
|
+
'data chart',
|
|
54
|
+
'market data chart',
|
|
55
|
+
'time series',
|
|
56
|
+
'timeseries chart',
|
|
57
|
+
'price chart',
|
|
58
|
+
'pnl chart',
|
|
59
|
+
'notional by counterparty',
|
|
60
|
+
'chart colors',
|
|
61
|
+
'chart legend',
|
|
62
|
+
'chart height',
|
|
63
|
+
'chart keeps growing',
|
|
64
|
+
'chart resize',
|
|
65
|
+
// technical
|
|
66
|
+
'G2PlotChart',
|
|
67
|
+
'ChartDatasource',
|
|
68
|
+
'ChartConfig',
|
|
69
|
+
'ChartTypes',
|
|
70
|
+
'g2plot',
|
|
71
|
+
'chartFields',
|
|
72
|
+
'serverFields',
|
|
73
|
+
'g2plot-chart',
|
|
74
|
+
'chartsGradients',
|
|
75
|
+
'autoFit',
|
|
76
|
+
'BIGDECIMAL',
|
|
77
|
+
'BigDecimal',
|
|
78
|
+
];
|
|
79
|
+
export const FUI_CHART_CONTEXT = `
|
|
80
|
+
## G2PlotChart — \`@genesislcap/g2plot-chart/react\`
|
|
81
|
+
|
|
82
|
+
Built on **AntV G2Plot v2** (\`@antv/g2plot\` 2.4.x). The wrapper is thin — the \`config\` object is
|
|
83
|
+
passed through to the underlying G2Plot plot, so all G2Plot v2 options (axes, labels, tooltips,
|
|
84
|
+
meta, animations, interactions, annotations) work as-is. Always prefer configuring the existing
|
|
85
|
+
wrapper over rebuilding charts from scratch.
|
|
86
|
+
|
|
87
|
+
The option tables in this document are verified against the installed \`@antv/g2plot@2.4.x\`
|
|
88
|
+
typings — when external G2Plot docs and this document disagree, this document wins.
|
|
89
|
+
|
|
90
|
+
### Imports
|
|
91
|
+
|
|
92
|
+
\`\`\`tsx
|
|
93
|
+
// React component wrappers — verified from react.d.ts
|
|
94
|
+
import { G2PlotChart, ChartDatasource } from '@genesislcap/g2plot-chart/react';
|
|
95
|
+
// Ref types (optional) — component instance types
|
|
96
|
+
import type { G2PlotChartRef, ChartDatasourceRef } from '@genesislcap/g2plot-chart/react';
|
|
97
|
+
// Data types + Rapid gradient palette — import from base package root, NOT from /react
|
|
98
|
+
import type { ChartConfig, ChartTypes } from '@genesislcap/g2plot-chart';
|
|
99
|
+
import { chartsGradients } from '@genesislcap/g2plot-chart';
|
|
100
|
+
\`\`\`
|
|
101
|
+
|
|
102
|
+
### G2PlotChart props (verified from react.d.ts + src/chart.ts)
|
|
103
|
+
|
|
104
|
+
| Prop | Type | Default | Notes |
|
|
105
|
+
|---|---|---|---|
|
|
106
|
+
| \`type\` | \`ChartTypes\` | \`'bar'\` | Required. One of the 11 chart types listed below |
|
|
107
|
+
| \`config\` | \`ChartConfig\` | — | **Required.** G2Plot config object; omit \`data\` field when using \`ChartDatasource\`. **Keep the object reference stable** — every new object identity destroys and recreates the whole chart |
|
|
108
|
+
| \`data\` | \`any[]\` | \`[]\` | Static / client-side data; do NOT mix with \`ChartDatasource\` child. Update immutably (pass a new array) — in-place mutation is not detected |
|
|
109
|
+
| \`style\` | \`React.CSSProperties\` | — | The chart fills its container (\`height: 100%\`); the container must have a **definite height** — see sizing rules |
|
|
110
|
+
| \`className\` | \`string\` | — | CSS class name |
|
|
111
|
+
| \`onChangeTitle\` | \`(event: CustomEvent) => void\` | — | Fired when legend visibility changes; payload \`{ title, mode: 'suffix' }\` |
|
|
112
|
+
|
|
113
|
+
### ChartDatasource props (verified from src/chart-datasource/chart-datasource.ts + react.d.ts)
|
|
114
|
+
|
|
115
|
+
| Prop | Type | Default | Notes |
|
|
116
|
+
|---|---|---|---|
|
|
117
|
+
| \`resourceName\` | \`string\` | — | **Required.** Backend DataServer / RequestServer resource name |
|
|
118
|
+
| \`serverFields\` | \`string\` | — | **Required.** Space-separated backend field names (2 or 3). Order matters — see field mapping below |
|
|
119
|
+
| \`chartFields\` | \`string\` | \`"groupBy value"\` | Override only when you need non-default chart field names |
|
|
120
|
+
| \`criteria\` | \`string\` | — | Groovy filter expression for server-side filtering; changing it refetches the subscription |
|
|
121
|
+
| \`isSnapshot\` | \`boolean\` | \`false\` | Request a snapshot instead of a live stream |
|
|
122
|
+
| \`maxRows\` | \`number\` | \`250\` | Max rows per batch from server |
|
|
123
|
+
| \`maxView\` | \`number\` | \`1000\` | Max rows tracked client-side |
|
|
124
|
+
| \`orderBy\` | \`string\` | — | Data Server index name for server-side sort |
|
|
125
|
+
| \`rowId\` | \`string\` | \`'ROW_REF'\` | Unique row identifier field for stream reconciliation |
|
|
126
|
+
| \`reverse\` | \`boolean\` | \`false\` | Reverse Data Server index iteration order |
|
|
127
|
+
| \`isStack\` | \`boolean\` | \`false\` | Stack segments (requires 3 server fields; mutually exclusive with \`isGroup\`; only applied for \`bar\`/\`column\` types) |
|
|
128
|
+
| \`isGroup\` | \`boolean\` | \`false\` | Group side-by-side (requires 3 server fields; mutually exclusive with \`isStack\`; only applied for \`bar\`/\`column\` types) |
|
|
129
|
+
| \`reduced\` | \`boolean\` | \`true\` | Aggregate (sum) rows sharing the same groupBy (+series) value. Rows with an empty/falsy groupBy are dropped. Set \`false\` for raw per-row plotting (e.g. scatter) or pre-aggregated backends |
|
|
130
|
+
| \`showFormattedTime\` | \`boolean\` | \`false\` | Include TIME portion in chart labels for DATETIME fields (only if \`withTimestampFormatting\` is true) |
|
|
131
|
+
| \`withTimestampFormatting\` | \`boolean\` | \`true\` | Date-formats the groupBy value **whenever it is a number** — regardless of field type. Set \`false\` when the x/groupBy field is numeric (price, quantity, …) or values become dates like '1970-01-01' |
|
|
132
|
+
| \`onDatasourceError\` | \`(event: CustomEvent) => void\` | — | Fired on fatal config or data loading failure (e.g. invalid field name — the error message lists the valid fields) |
|
|
133
|
+
|
|
134
|
+
### Supported chart types (\`ChartTypes\`) — verified from chart.types.ts
|
|
135
|
+
|
|
136
|
+
\`"line" | "area" | "column" | "bar" | "pie" | "donut" | "dualaxes" | "rose" | "scatter" | "stock" | "mix"\`
|
|
137
|
+
|
|
138
|
+
\`dualaxes\`, \`stock\` and \`mix\` are effectively **static-data types** — ChartDatasource cannot feed
|
|
139
|
+
two independent y-series (\`dualaxes\`), four OHLC fields (\`stock\`) or per-plot datasets (\`mix\`).
|
|
140
|
+
|
|
141
|
+
### How ChartDatasource field mapping works
|
|
142
|
+
|
|
143
|
+
The datasource maps **server fields** (raw backend names) to **chart fields** (names the config references) by position:
|
|
144
|
+
|
|
145
|
+
- **2 server fields** → field 1 = x / color axis (\`groupBy\`), field 2 = y / angle (\`value\`)
|
|
146
|
+
- **3 server fields** → same as above + field 3 auto-mapped as \`series\` (multi-series charts)
|
|
147
|
+
|
|
148
|
+
**You almost never need to override \`chartFields\`** — the default \`"groupBy value"\` works for all
|
|
149
|
+
single-series charts. When 3 server fields are provided the datasource automatically appends
|
|
150
|
+
\`"series"\` as the third chart field and injects \`seriesField: 'series'\` into the config.
|
|
151
|
+
|
|
152
|
+
The chart \`config\` must reference **chart field names** (\`groupBy\`, \`value\`, \`series\`), never raw backend field names.
|
|
153
|
+
|
|
154
|
+
**Numeric field types:** INT, LONG, DOUBLE and BIGDECIMAL all work as the value field. BIGDECIMAL
|
|
155
|
+
values arrive from the server as **strings** (precision-preserving wire format); the datasource
|
|
156
|
+
normalizes them to numbers automatically (g2plot-chart ≥ 14.479 — on older versions BIGDECIMAL
|
|
157
|
+
fields break aggregation via string concatenation, so prefer DOUBLE fields there). Fields whose
|
|
158
|
+
metadata type is STRING are never converted, even if the values look numeric.
|
|
159
|
+
|
|
160
|
+
### Config field names per chart type
|
|
161
|
+
|
|
162
|
+
| Chart type | x / category | y / value | series (multi) |
|
|
163
|
+
|---|---|---|---|
|
|
164
|
+
| \`line\`, \`area\`, \`column\` | \`xField: 'groupBy'\` | \`yField: 'value'\` | \`seriesField: 'series'\` |
|
|
165
|
+
| \`bar\` (horizontal) | \`yField: 'groupBy'\` | \`xField: 'value'\` | \`seriesField: 'series'\` |
|
|
166
|
+
| \`pie\`, \`donut\` | \`colorField: 'groupBy'\` | \`angleField: 'value'\` | — |
|
|
167
|
+
| \`rose\` | \`xField: 'groupBy'\` | \`yField: 'value'\` | \`seriesField: 'series'\` |
|
|
168
|
+
| \`scatter\` | \`xField: 'groupBy'\` (numeric) | \`yField: 'value'\` | — (set \`reduced={false}\` + \`withTimestampFormatting={false}\`) |
|
|
169
|
+
| \`dualaxes\` | \`xField\` (custom key) | \`yField: ['fieldA', 'fieldB']\` | — (two yField entries; use static \`data\` prop) |
|
|
170
|
+
| \`stock\` | \`xField\` (date key) | \`yField: ['open', 'close', 'high', 'low']\` | — (static data with 4 price fields) |
|
|
171
|
+
| \`mix\` | per sub-plot | per sub-plot | — (fully manual \`plots\` array in config) |
|
|
172
|
+
|
|
173
|
+
### Commonly used G2Plot config options (verified from @antv/g2plot 2.4.x Options type)
|
|
174
|
+
|
|
175
|
+
All chart types share these top-level options in addition to their field keys:
|
|
176
|
+
\`width\`, \`height\`, \`autoFit\` (default **true** — canvas tracks container size),
|
|
177
|
+
\`padding\` / \`appendPadding\`, \`meta\` (per-field value formatting/alias),
|
|
178
|
+
\`color\` (string | string[] | callback), \`label\`, \`tooltip\`, \`legend\`,
|
|
179
|
+
\`animation\`, \`interactions\`, \`annotations\`, \`theme\`.
|
|
180
|
+
|
|
181
|
+
\`xAxis\` / \`yAxis\`, \`slider\` and \`scrollbar\` are cartesian-plot options (\`line\`/\`area\`/\`column\`/
|
|
182
|
+
\`bar\`/\`scatter\`/\`dualaxes\`/\`stock\`); \`rose\` supports \`xAxis\`/\`yAxis\` for its polar axes but not
|
|
183
|
+
\`slider\`/\`scrollbar\`. \`pie\`/\`donut\` have no axes — G2Plot silently ignores all four keys there,
|
|
184
|
+
so do not add them to pie/donut configs.
|
|
185
|
+
|
|
186
|
+
### Value formatting — display hooks only (verified against @antv/g2plot 2.4.x)
|
|
187
|
+
|
|
188
|
+
Keep datasource values NUMERIC; format at the chart's display hooks, never by pre-formatting data:
|
|
189
|
+
|
|
190
|
+
- \`meta: { value: { formatter: (v) => string, alias: 'Notional' } }\` — formats that field
|
|
191
|
+
everywhere it is displayed (tooltips, axis labels). Keys are CHART field names (\`value\`/
|
|
192
|
+
\`groupBy\` with a datasource; your own data keys with static \`data\`). For notional axes use the
|
|
193
|
+
\`compact\` helper below: \`formatter: (v: number) => '$' + compact(v)\` → \`$49.3M\`.
|
|
194
|
+
- \`label: { formatter: (d) => string }\` for on-chart labels, or \`label: false\` to remove them.
|
|
195
|
+
Pie/donut outer labels showing raw values clutter fast — format compactly or disable.
|
|
196
|
+
- Pie/donut CENTRE: G2Plot renders a DEFAULT centre statistic (title + RAW sum, e.g. \`49168675\`).
|
|
197
|
+
Large values must override it:
|
|
198
|
+
|
|
199
|
+
\`\`\`ts
|
|
200
|
+
const compact = (n: number) =>
|
|
201
|
+
Math.abs(n) >= 1e9 ? \`\${(n / 1e9).toFixed(1)}B\`
|
|
202
|
+
: Math.abs(n) >= 1e6 ? \`\${(n / 1e6).toFixed(1)}M\`
|
|
203
|
+
: Math.abs(n) >= 1e3 ? \`\${(n / 1e3).toFixed(1)}K\`
|
|
204
|
+
: \`\${n}\`;
|
|
205
|
+
|
|
206
|
+
const donutConfig: ChartConfig = {
|
|
207
|
+
angleField: 'value',
|
|
208
|
+
colorField: 'groupBy',
|
|
209
|
+
statistic: {
|
|
210
|
+
title: { content: 'Total' },
|
|
211
|
+
// datum = hovered slice, or undefined for the whole-data total
|
|
212
|
+
content: { formatter: (datum, data) =>
|
|
213
|
+
compact(datum ? datum.value : (data ?? []).reduce((s, d) => s + (d.value ?? 0), 0)) },
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
218
|
+
### Built-in Rapid styling defaults (from src/models/*.ts)
|
|
219
|
+
|
|
220
|
+
Each chart type applies Genesis Rapid design-system defaults when the config does not set them:
|
|
221
|
+
|
|
222
|
+
- \`pie\`/\`donut\`/\`rose\`: full gradient palette (\`Object.values(chartsGradients)\`) — one gradient per category/series.
|
|
223
|
+
- \`bar\` — ⚠️ KNOWN PLATFORM ISSUE (g2plot-chart ≤ 14.481.0; FIXED in ≥ 14.481.1, PR #2364): the default was the palette array even WITHOUT a \`seriesField\`, so the color channel was unmapped and the Rapid custom shape got \`undefined\` → **bars render INVISIBLE** (tooltips still work, \`column\` is unaffected). Every \`bar\` config without \`seriesField\` MUST still set \`color: chartsGradients.rapidBlue\` explicitly (see DP-13) — on fixed versions this is byte-identical to the platform default, so it is safe everywhere. This is the one sanctioned exception to the color-override policy.
|
|
224
|
+
- \`column\`/\`line\`: single blue gradient without a series; full palette automatically when \`seriesField\` is present (≥ 14.479 — older versions rendered multi-series columns/lines black unless \`color\` was set explicitly).
|
|
225
|
+
- \`line\`: also defaults \`smooth: true\`, point markers and a soft area fill.
|
|
226
|
+
- \`area\`: purple→blue gradient fill; \`stock\`: green rising / red falling.
|
|
227
|
+
- \`dualaxes\`: two line geometries colored \`rapidBlue\` / \`rapidGreen\` (applied only when \`geometryOptions\` is omitted entirely).
|
|
228
|
+
- Interval charts use a custom \`rapid-shape\` (translucent fill + thick stroke).
|
|
229
|
+
|
|
230
|
+
**COLOR OVERRIDE POLICY — strict.** The defaults above are the Genesis-designed, theme-consistent
|
|
231
|
+
palette. NEVER set \`config.color\` on your own initiative — not for "variety", not to match the
|
|
232
|
+
app's CSS design tokens (charts deliberately use the chart palette, not UI tokens), not because a
|
|
233
|
+
chart "looks plain". The ONLY trigger for a color override is the user explicitly asking for
|
|
234
|
+
specific chart colors — and even then you pick the CLOSEST \`chartsGradients\` entries, never raw
|
|
235
|
+
hex/rgb and never CSS variables. Appearance map for choosing the closest entry
|
|
236
|
+
(gradient → rendered look, from foundation-zero hexes):
|
|
237
|
+
|
|
238
|
+
| \`chartsGradients.\` | Looks like |
|
|
239
|
+
|---|---|
|
|
240
|
+
| \`rapidBlue\` | purple → blue (the signature Rapid primary) |
|
|
241
|
+
| \`rapidDodgerBlue\` | sky / bright blue |
|
|
242
|
+
| \`rapidGreen\` | green |
|
|
243
|
+
| \`rapidRed\` | red → pink-red |
|
|
244
|
+
| \`rapidViolet\` | magenta / violet |
|
|
245
|
+
| \`rapidPortage\` | periwinkle / soft indigo |
|
|
246
|
+
| \`rapidIce\` | aqua / cyan |
|
|
247
|
+
| \`rapidSalomie\` | gold / yellow |
|
|
248
|
+
| \`rapidMelon\` | peach / salmon ("orange-ish") |
|
|
249
|
+
| \`rapidAlabaster\` | white → silver (neutral/grey) |
|
|
250
|
+
|
|
251
|
+
e.g. user asks "make the sell series red and the buy series green" — use the CALLBACK form so the
|
|
252
|
+
mapping does not depend on which series arrives first in the (live) data (a color ARRAY maps by
|
|
253
|
+
order of first appearance, which is non-deterministic with streaming datasources):
|
|
254
|
+
|
|
255
|
+
\`\`\`ts
|
|
256
|
+
// seriesField is 'series' with a 3-field datasource (e.g. serverFields="TRADE_DATE NOTIONAL SIDE")
|
|
257
|
+
color: ({ series }) => (series === 'BUY' ? chartsGradients.rapidGreen : chartsGradients.rapidRed),
|
|
258
|
+
\`\`\`
|
|
259
|
+
|
|
260
|
+
If no entry is close to the requested color (e.g. "brown"), use the nearest one and tell the user
|
|
261
|
+
which palette color you chose — do NOT invent a hex.
|
|
262
|
+
|
|
263
|
+
**Legend is OFF unless configured.** The wrapper replaces a missing \`legend\` config with
|
|
264
|
+
\`legend: false\` (src/chart.ts initalizeConfiguration). Every multi-series chart MUST set
|
|
265
|
+
\`legend\` explicitly, e.g. \`legend: { position: 'top-left' }\`, or users cannot tell series apart.
|
|
266
|
+
|
|
267
|
+
### Sizing rules (critical)
|
|
268
|
+
|
|
269
|
+
G2Plot \`autoFit\` is on by default: the canvas is sized from the chart's container, and the chart
|
|
270
|
+
host stretches to \`height: 100%\`. Therefore the chart's parent must have a **definite height**:
|
|
271
|
+
|
|
272
|
+
- Inside a FlexLayout tile / dashboard panel: the tile has a definite height → \`style={{ height: '100%' }}\` works.
|
|
273
|
+
- Inside a plain page section or card: give the wrapping element a **fixed height** (e.g. \`<div style={{ height: 400 }}>\`).
|
|
274
|
+
- NEVER place a chart in a box whose height derives from its own content (\`flex: 1\` inside a
|
|
275
|
+
content-sized card, stretched grid rows, no height anywhere up the chain). The canvas size feeds
|
|
276
|
+
back into the container measurement → the chart **grows a few px on every resize tick, forever**,
|
|
277
|
+
and the overflowing canvas paints over content below it.
|
|
278
|
+
|
|
279
|
+
### Examples
|
|
280
|
+
|
|
281
|
+
#### Static line chart (client-side data)
|
|
282
|
+
\`\`\`tsx
|
|
283
|
+
import { G2PlotChart } from '@genesislcap/g2plot-chart/react';
|
|
284
|
+
import type { ChartConfig } from '@genesislcap/g2plot-chart';
|
|
285
|
+
|
|
286
|
+
const lineData = [
|
|
287
|
+
{ groupBy: 'Jan', value: 120 },
|
|
288
|
+
{ groupBy: 'Feb', value: 85 },
|
|
289
|
+
{ groupBy: 'Mar', value: 140 },
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
// Module scope (or useMemo) — a new config identity per render recreates the chart
|
|
293
|
+
const lineConfig: ChartConfig = { xField: 'groupBy', yField: 'value', smooth: true };
|
|
294
|
+
|
|
295
|
+
const MyLineChart: React.FC = () => (
|
|
296
|
+
<G2PlotChart type="line" config={lineConfig} data={lineData} style={{ height: '100%' }} />
|
|
297
|
+
);
|
|
298
|
+
\`\`\`
|
|
299
|
+
|
|
300
|
+
#### Live datasource line chart (server streaming data)
|
|
301
|
+
\`\`\`tsx
|
|
302
|
+
import { G2PlotChart, ChartDatasource } from '@genesislcap/g2plot-chart/react';
|
|
303
|
+
import type { ChartConfig } from '@genesislcap/g2plot-chart';
|
|
304
|
+
|
|
305
|
+
const lineConfig: ChartConfig = { xField: 'groupBy', yField: 'value' };
|
|
306
|
+
|
|
307
|
+
const MyLineChart: React.FC = () => (
|
|
308
|
+
<G2PlotChart type="line" config={lineConfig} style={{ height: '100%' }}>
|
|
309
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
310
|
+
</G2PlotChart>
|
|
311
|
+
);
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
#### Pie chart (server data)
|
|
315
|
+
\`\`\`tsx
|
|
316
|
+
const pieConfig: ChartConfig = {
|
|
317
|
+
angleField: 'value',
|
|
318
|
+
colorField: 'groupBy',
|
|
319
|
+
radius: 0.75,
|
|
320
|
+
label: {
|
|
321
|
+
type: 'spider',
|
|
322
|
+
content: '{name}\\n{percentage}',
|
|
323
|
+
style: { fill: 'white' },
|
|
324
|
+
},
|
|
325
|
+
interactions: [{ type: 'element-selected' }, { type: 'element-active' }],
|
|
326
|
+
legend: { position: 'right' }, // omit → NO legend at all
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const MyPieChart: React.FC = () => (
|
|
330
|
+
<G2PlotChart type="pie" config={pieConfig} style={{ height: '100%' }}>
|
|
331
|
+
<ChartDatasource resourceName="ALL_POSITIONS" serverFields="INSTRUMENT_NAME NOTIONAL" />
|
|
332
|
+
</G2PlotChart>
|
|
333
|
+
);
|
|
334
|
+
\`\`\`
|
|
335
|
+
|
|
336
|
+
#### Multi-series grouped column chart (3 server fields)
|
|
337
|
+
\`\`\`tsx
|
|
338
|
+
const columnConfig: ChartConfig = {
|
|
339
|
+
xField: 'groupBy',
|
|
340
|
+
yField: 'value',
|
|
341
|
+
seriesField: 'series', // auto-injected by datasource when 3 server fields are given; explicit is fine
|
|
342
|
+
legend: { position: 'top-left' }, // REQUIRED for multi-series — legend is off by default
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const MyColumnChart: React.FC = () => (
|
|
346
|
+
<G2PlotChart type="column" config={columnConfig} style={{ height: '100%' }}>
|
|
347
|
+
{/* 3 server fields → datasource auto-maps field 3 to 'series' chart field */}
|
|
348
|
+
<ChartDatasource
|
|
349
|
+
resourceName="ALL_TRADES"
|
|
350
|
+
serverFields="TRADE_DATE NOTIONAL COUNTERPARTY"
|
|
351
|
+
isGroup
|
|
352
|
+
/>
|
|
353
|
+
</G2PlotChart>
|
|
354
|
+
);
|
|
355
|
+
\`\`\`
|
|
356
|
+
|
|
357
|
+
#### Criteria-filtered chart (server-side filter from state)
|
|
358
|
+
\`\`\`tsx
|
|
359
|
+
const FilteredChart: React.FC<{ criteria: string }> = ({ criteria }) => (
|
|
360
|
+
<G2PlotChart type="pie" config={pieConfig} style={{ height: '100%' }}>
|
|
361
|
+
<ChartDatasource
|
|
362
|
+
resourceName="ALL_POSITIONS"
|
|
363
|
+
serverFields="INSTRUMENT_NAME VALUE"
|
|
364
|
+
criteria={criteria}
|
|
365
|
+
/>
|
|
366
|
+
</G2PlotChart>
|
|
367
|
+
);
|
|
368
|
+
// criteria is a Groovy expression, e.g. \`INSTRUMENT_NAME == 'VOD'\`; '' means no filter
|
|
369
|
+
\`\`\`
|
|
370
|
+
|
|
371
|
+
#### Scatter chart — raw rows, numeric x axis
|
|
372
|
+
\`\`\`tsx
|
|
373
|
+
const scatterConfig: ChartConfig = {
|
|
374
|
+
xField: 'groupBy',
|
|
375
|
+
yField: 'value',
|
|
376
|
+
size: 6,
|
|
377
|
+
shape: 'circle',
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const MyScatter: React.FC = () => (
|
|
381
|
+
<G2PlotChart type="scatter" config={scatterConfig} style={{ height: '100%' }}>
|
|
382
|
+
{/* reduced={false}: plot every row; withTimestampFormatting={false}: numeric x
|
|
383
|
+
values would otherwise be date-formatted */}
|
|
384
|
+
<ChartDatasource
|
|
385
|
+
resourceName="ALL_TRADES"
|
|
386
|
+
serverFields="PRICE NOTIONAL"
|
|
387
|
+
reduced={false}
|
|
388
|
+
withTimestampFormatting={false}
|
|
389
|
+
/>
|
|
390
|
+
</G2PlotChart>
|
|
391
|
+
);
|
|
392
|
+
\`\`\`
|
|
393
|
+
|
|
394
|
+
#### Dual-axes chart (static data only — see DANGEROUS PATTERNS)
|
|
395
|
+
\`\`\`tsx
|
|
396
|
+
const dualData = [
|
|
397
|
+
{ type: '1991', value: 3, count: 10 },
|
|
398
|
+
{ type: '1992', value: 4, count: 4 },
|
|
399
|
+
{ type: '1993', value: 3.5, count: 5 },
|
|
400
|
+
];
|
|
401
|
+
|
|
402
|
+
// Omitting geometryOptions gives the Rapid default: two lines colored
|
|
403
|
+
// chartsGradients.rapidBlue / rapidGreen. Override it only to change geometry or
|
|
404
|
+
// palette — and then use chartsGradients values, not hand-rolled hex (Key rule 14):
|
|
405
|
+
const dualConfig: ChartConfig = {
|
|
406
|
+
xField: 'type',
|
|
407
|
+
yField: ['value', 'count'],
|
|
408
|
+
geometryOptions: [
|
|
409
|
+
{ geometry: 'column', color: chartsGradients.rapidBlue },
|
|
410
|
+
{ geometry: 'line', color: chartsGradients.rapidGreen },
|
|
411
|
+
],
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// dualaxes requires data as [primaryArray, secondaryArray] — two arrays, one per axis
|
|
415
|
+
const MyDualAxes: React.FC = () => (
|
|
416
|
+
<G2PlotChart
|
|
417
|
+
type="dualaxes"
|
|
418
|
+
config={dualConfig}
|
|
419
|
+
data={[dualData, dualData]}
|
|
420
|
+
style={{ height: '100%' }}
|
|
421
|
+
/>
|
|
422
|
+
);
|
|
423
|
+
\`\`\`
|
|
424
|
+
|
|
425
|
+
#### Datasource error UI (optional)
|
|
426
|
+
\`\`\`tsx
|
|
427
|
+
// A child with slot="chart-datasource-error" is shown when the datasource errors
|
|
428
|
+
// (invalid resource/field, disconnect). Dismiss by emitting 'datasource-error-close'.
|
|
429
|
+
<G2PlotChart type="pie" config={pieConfig} style={{ height: '100%' }}>
|
|
430
|
+
<div slot="chart-datasource-error">Chart data unavailable.</div>
|
|
431
|
+
<ChartDatasource
|
|
432
|
+
resourceName="ALL_POSITIONS"
|
|
433
|
+
serverFields="INSTRUMENT_NAME VALUE"
|
|
434
|
+
onDatasourceError={(e) => console.warn(e.detail.message)}
|
|
435
|
+
/>
|
|
436
|
+
</G2PlotChart>
|
|
437
|
+
\`\`\`
|
|
438
|
+
|
|
439
|
+
### Key rules
|
|
440
|
+
|
|
441
|
+
1. **Always import from \`@genesislcap/g2plot-chart/react\`**, not from \`@genesislcap/rapid-design-system/react\` or any other package. G2PlotChart is NOT in rapid-design-system.
|
|
442
|
+
2. **Data types (\`ChartConfig\`, \`ChartTypes\`) and \`chartsGradients\` import from the base root** (\`@genesislcap/g2plot-chart\`); the component wrappers and their \`*Ref\` instance types come from \`/react\`.
|
|
443
|
+
3. **The chart's container must have a definite height** — \`height: '100%'\` inside FlexLayout tiles, otherwise a fixed pixel height. A content-derived height causes an infinite grow loop (see sizing rules and DP-9).
|
|
444
|
+
4. **\`config\` is required** and must be **referentially stable** (module scope or \`useMemo\`) — each new identity destroys and re-renders the chart.
|
|
445
|
+
5. **Set \`legend\` explicitly in config** — without it the wrapper renders NO legend (\`legend: false\`). Mandatory for anything multi-series.
|
|
446
|
+
6. **ChartDatasource must be a direct child** of \`G2PlotChart\` (no intermediate wrappers). The datasource reads \`this.parentElement\` to locate the chart instance.
|
|
447
|
+
7. **Do not mix \`data\` prop and \`ChartDatasource\`** — pick exactly one source.
|
|
448
|
+
8. **\`dualaxes\` data must be \`[primaryData, secondaryData]\`**; \`dualaxes\`/\`stock\`/\`mix\` should use static \`data\`, not ChartDatasource.
|
|
449
|
+
9. **\`isStack\` and \`isGroup\` are mutually exclusive**, need 3 server fields, and are only applied for \`bar\`/\`column\` chart types.
|
|
450
|
+
10. **\`seriesField\` in config is auto-injected** when 3 server fields are provided — setting it explicitly too is harmless, just redundant (the datasource overwrites it with the same value). With static \`data\` you must set it yourself for multi-series.
|
|
451
|
+
11. **\`withTimestampFormatting\` defaults to \`true\` and date-formats any numeric groupBy value** — correct for DATE/DATETIME fields, wrong for numeric axes (price, quantity): set it to \`false\` there.
|
|
452
|
+
12. **\`reduced\` defaults to \`true\`** (sum per groupBy+series; falsy-groupBy rows dropped). Set \`reduced={false}\` for raw per-row plots (scatter) or pre-aggregated backends.
|
|
453
|
+
13. **All numeric field types work as the value field** — BIGDECIMAL strings are normalized to numbers by the datasource (≥ 14.479).
|
|
454
|
+
14. **Never set chart colors yourself** — the Rapid defaults ARE the design. \`config.color\` is allowed ONLY when the user explicitly requests specific colors, and then ONLY with \`chartsGradients\` entries (pick the closest per the appearance map above) — never raw hex/rgb, never CSS design tokens. ONE exception: \`bar\` without \`seriesField\` MUST set \`color: chartsGradients.rapidBlue\` (platform bug on g2plot-chart ≤ 14.481.0 renders it invisible otherwise; identical to the fixed ≥ 14.481.1 default, so always safe — see DP-13).
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
### DANGEROUS PATTERNS
|
|
459
|
+
|
|
460
|
+
#### DP-1: Wrong import package — chart is NOT in rapid-design-system
|
|
461
|
+
|
|
462
|
+
\`\`\`tsx
|
|
463
|
+
// WRONG — G2PlotChart won't be found and ChartConfiguration type does not exist:
|
|
464
|
+
import { G2PlotChart } from '@genesislcap/rapid-design-system/react';
|
|
465
|
+
import type { ChartConfiguration } from '@genesislcap/g2plot-chart';
|
|
466
|
+
|
|
467
|
+
// CORRECT:
|
|
468
|
+
import { G2PlotChart, ChartDatasource } from '@genesislcap/g2plot-chart/react';
|
|
469
|
+
import type { ChartConfig, ChartTypes } from '@genesislcap/g2plot-chart';
|
|
470
|
+
\`\`\`
|
|
471
|
+
|
|
472
|
+
#### DP-2: No definite height — chart renders at 0px or grows forever
|
|
473
|
+
|
|
474
|
+
\`\`\`tsx
|
|
475
|
+
// WRONG — chart collapses to 0 height inside a FlexLayout tile:
|
|
476
|
+
<G2PlotChart type="line" config={cfg}>
|
|
477
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
478
|
+
</G2PlotChart>
|
|
479
|
+
|
|
480
|
+
// CORRECT — height: '100%' works because the tile has a definite height:
|
|
481
|
+
<G2PlotChart type="line" config={cfg} style={{ height: '100%' }}>
|
|
482
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
483
|
+
</G2PlotChart>
|
|
484
|
+
\`\`\`
|
|
485
|
+
|
|
486
|
+
#### DP-3: Using raw server field names in config instead of chart field names
|
|
487
|
+
|
|
488
|
+
\`\`\`tsx
|
|
489
|
+
// WRONG — config must reference chart field names, not backend field names:
|
|
490
|
+
const config: ChartConfig = {
|
|
491
|
+
xField: 'TRADE_DATE', // raw server field name — will not match what datasource emits
|
|
492
|
+
yField: 'QUANTITY', // raw server field name
|
|
493
|
+
};
|
|
494
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
495
|
+
|
|
496
|
+
// CORRECT — config references chart field names ('groupBy', 'value') which datasource maps to:
|
|
497
|
+
const config: ChartConfig = {
|
|
498
|
+
xField: 'groupBy',
|
|
499
|
+
yField: 'value',
|
|
500
|
+
};
|
|
501
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
502
|
+
\`\`\`
|
|
503
|
+
|
|
504
|
+
#### DP-4: Setting both isStack and isGroup on ChartDatasource
|
|
505
|
+
|
|
506
|
+
\`\`\`tsx
|
|
507
|
+
// WRONG — mutually exclusive; triggers "will not load properly" error log, chart is broken:
|
|
508
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="DATE AMOUNT TYPE" isStack isGroup />
|
|
509
|
+
|
|
510
|
+
// CORRECT — pick one:
|
|
511
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="DATE AMOUNT TYPE" isGroup />
|
|
512
|
+
\`\`\`
|
|
513
|
+
|
|
514
|
+
#### DP-5: Bar chart xField/yField swapped (horizontal vs vertical)
|
|
515
|
+
|
|
516
|
+
\`\`\`tsx
|
|
517
|
+
// WRONG — 'bar' is horizontal; axis fields are the opposite of 'column':
|
|
518
|
+
const barConfig: ChartConfig = {
|
|
519
|
+
xField: 'groupBy', // this is correct for 'column', not 'bar'
|
|
520
|
+
yField: 'value',
|
|
521
|
+
};
|
|
522
|
+
<G2PlotChart type="bar" config={barConfig}>...</G2PlotChart>
|
|
523
|
+
|
|
524
|
+
// CORRECT — for 'bar' (horizontal), swap x and y:
|
|
525
|
+
const barConfig: ChartConfig = {
|
|
526
|
+
yField: 'groupBy', // category on the y-axis
|
|
527
|
+
xField: 'value', // numeric value on the x-axis
|
|
528
|
+
};
|
|
529
|
+
<G2PlotChart type="bar" config={barConfig}>...</G2PlotChart>
|
|
530
|
+
\`\`\`
|
|
531
|
+
|
|
532
|
+
#### DP-6: Using ChartDatasource with dualaxes / stock / mix
|
|
533
|
+
|
|
534
|
+
\`\`\`tsx
|
|
535
|
+
// WRONG — ChartDatasource duplicates one series as [data, data] for dualaxes; it cannot
|
|
536
|
+
// supply two independent y-series, OHLC fields, or per-plot datasets:
|
|
537
|
+
<G2PlotChart type="dualaxes" config={dualConfig}>
|
|
538
|
+
<ChartDatasource resourceName="ALL_POSITIONS" serverFields="DATE VALUE COUNT" />
|
|
539
|
+
</G2PlotChart>
|
|
540
|
+
|
|
541
|
+
// CORRECT — these types take static data:
|
|
542
|
+
<G2PlotChart
|
|
543
|
+
type="dualaxes"
|
|
544
|
+
config={dualConfig}
|
|
545
|
+
data={[primaryData, secondaryData]}
|
|
546
|
+
style={{ height: '100%' }}
|
|
547
|
+
/>
|
|
548
|
+
\`\`\`
|
|
549
|
+
|
|
550
|
+
#### DP-7: Placing ChartDatasource inside an intermediate wrapper element
|
|
551
|
+
|
|
552
|
+
\`\`\`tsx
|
|
553
|
+
// WRONG — datasource uses this.parentElement to find G2PlotChart; a wrapper breaks this:
|
|
554
|
+
<G2PlotChart type="pie" config={pieConfig}>
|
|
555
|
+
<div>
|
|
556
|
+
<ChartDatasource resourceName="ALL_POSITIONS" serverFields="NAME VALUE" />
|
|
557
|
+
</div>
|
|
558
|
+
</G2PlotChart>
|
|
559
|
+
|
|
560
|
+
// CORRECT — ChartDatasource must be a direct child of G2PlotChart:
|
|
561
|
+
<G2PlotChart type="pie" config={pieConfig} style={{ height: '100%' }}>
|
|
562
|
+
<ChartDatasource resourceName="ALL_POSITIONS" serverFields="NAME VALUE" />
|
|
563
|
+
</G2PlotChart>
|
|
564
|
+
\`\`\`
|
|
565
|
+
|
|
566
|
+
#### DP-8: Omitting config or passing undefined config
|
|
567
|
+
|
|
568
|
+
\`\`\`tsx
|
|
569
|
+
// WRONG — chart only renders when config is truthy at connectedCallback time:
|
|
570
|
+
<G2PlotChart type="line" style={{ height: '100%' }}>
|
|
571
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
572
|
+
</G2PlotChart>
|
|
573
|
+
|
|
574
|
+
// CORRECT — always pass a config object (even a minimal one):
|
|
575
|
+
const lineConfig: ChartConfig = { xField: 'groupBy', yField: 'value' };
|
|
576
|
+
<G2PlotChart type="line" config={lineConfig} style={{ height: '100%' }}>
|
|
577
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE QUANTITY" />
|
|
578
|
+
</G2PlotChart>
|
|
579
|
+
\`\`\`
|
|
580
|
+
|
|
581
|
+
#### DP-9: Chart inside a content-sized box — infinite grow loop
|
|
582
|
+
|
|
583
|
+
\`\`\`tsx
|
|
584
|
+
// WRONG — the card's height derives from its content, and G2Plot autoFit measures the
|
|
585
|
+
// container: canvas grows card → card growth re-triggers autoFit → chart grows forever
|
|
586
|
+
// and the oversized canvas paints over the content below it:
|
|
587
|
+
<div className="card"> {/* height: auto */}
|
|
588
|
+
<div style={{ flex: 1 }}> {/* height derived from the canvas itself */}
|
|
589
|
+
<G2PlotChart type="column" config={cfg} style={{ height: '100%' }}>...</G2PlotChart>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
// CORRECT — give the chart's box a fixed height (or ensure a definite height up the chain):
|
|
594
|
+
<div className="card">
|
|
595
|
+
<div style={{ height: 400, overflow: 'hidden' }}>
|
|
596
|
+
<G2PlotChart type="column" config={cfg} style={{ height: '100%' }}>...</G2PlotChart>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
\`\`\`
|
|
600
|
+
|
|
601
|
+
#### DP-10: Inline config literal — chart destroyed and recreated on every render
|
|
602
|
+
|
|
603
|
+
\`\`\`tsx
|
|
604
|
+
// WRONG — new object identity per render; each parent re-render tears the canvas down:
|
|
605
|
+
<G2PlotChart type="line" config={{ xField: 'groupBy', yField: 'value' }} ... >
|
|
606
|
+
|
|
607
|
+
// CORRECT — module-scope constant or useMemo:
|
|
608
|
+
const lineConfig: ChartConfig = { xField: 'groupBy', yField: 'value' };
|
|
609
|
+
<G2PlotChart type="line" config={lineConfig} ... >
|
|
610
|
+
\`\`\`
|
|
611
|
+
|
|
612
|
+
#### DP-11: Numeric x values silently turned into dates
|
|
613
|
+
|
|
614
|
+
\`\`\`tsx
|
|
615
|
+
// WRONG — withTimestampFormatting defaults to true and formats ANY numeric groupBy value,
|
|
616
|
+
// so PRICE values (105.5, 98.75, …) all become '1970-01-01':
|
|
617
|
+
<ChartDatasource resourceName="ALL_TRADES" serverFields="PRICE NOTIONAL" reduced={false} />
|
|
618
|
+
|
|
619
|
+
// CORRECT — disable timestamp formatting for numeric (non-date) x fields:
|
|
620
|
+
<ChartDatasource
|
|
621
|
+
resourceName="ALL_TRADES"
|
|
622
|
+
serverFields="PRICE NOTIONAL"
|
|
623
|
+
reduced={false}
|
|
624
|
+
withTimestampFormatting={false}
|
|
625
|
+
/>
|
|
626
|
+
\`\`\`
|
|
627
|
+
|
|
628
|
+
#### DP-12: Multi-series chart with no legend config
|
|
629
|
+
|
|
630
|
+
\`\`\`tsx
|
|
631
|
+
// WRONG — the wrapper turns a missing legend config into legend: false; users cannot
|
|
632
|
+
// tell the series apart:
|
|
633
|
+
const cfg: ChartConfig = { xField: 'groupBy', yField: 'value', seriesField: 'series' };
|
|
634
|
+
|
|
635
|
+
// CORRECT — configure the legend explicitly on every multi-series chart:
|
|
636
|
+
const cfg: ChartConfig = {
|
|
637
|
+
xField: 'groupBy',
|
|
638
|
+
yField: 'value',
|
|
639
|
+
seriesField: 'series',
|
|
640
|
+
legend: { position: 'top-left' },
|
|
641
|
+
};
|
|
642
|
+
\`\`\`
|
|
643
|
+
|
|
644
|
+
#### DP-13: Invisible \`bar\` chart — platform default colors break bars without a seriesField
|
|
645
|
+
|
|
646
|
+
\`\`\`tsx
|
|
647
|
+
// WRONG on g2plot-chart <= 14.481.0 — renders NO bars (tooltips work, axes draw, bars
|
|
648
|
+
// invisible). Those versions default bar to the gradient palette ARRAY; with no seriesField
|
|
649
|
+
// the color channel is unmapped and the Rapid custom shape receives undefined fill/stroke.
|
|
650
|
+
// Fixed in >= 14.481.1 (foundation-ui PR #2364), but ALWAYS apply the explicit color —
|
|
651
|
+
// it is identical to the fixed default and protects apps pinned to older versions:
|
|
652
|
+
const barConfig: ChartConfig = {
|
|
653
|
+
yField: 'groupBy',
|
|
654
|
+
xField: 'value',
|
|
655
|
+
};
|
|
656
|
+
<G2PlotChart type="bar" config={barConfig}>...</G2PlotChart>
|
|
657
|
+
|
|
658
|
+
// CORRECT — single-series bar charts MUST set one gradient explicitly
|
|
659
|
+
// (mirrors what the platform already does for 'column'):
|
|
660
|
+
import { chartsGradients } from '@genesislcap/g2plot-chart';
|
|
661
|
+
const barConfig: ChartConfig = {
|
|
662
|
+
yField: 'groupBy',
|
|
663
|
+
xField: 'value',
|
|
664
|
+
color: chartsGradients.rapidBlue,
|
|
665
|
+
};
|
|
666
|
+
<G2PlotChart type="bar" config={barConfig}>...</G2PlotChart>
|
|
667
|
+
// (With a seriesField the palette array maps correctly — no override needed there.)
|
|
668
|
+
\`\`\`
|
|
669
|
+
`.trim();
|