@funnest/charts-ui 0.6.18 → 0.6.20
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 +11 -12
- package/dist/context.d.ts +3 -1
- package/dist/index.js +25 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# @funnest/charts-ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Full trading chart widget (toolbar, symbol search, indicators, drawing tools). Framework-free.
|
|
3
|
+
The full trading chart widget: toolbar, symbol search, indicators and drawing tools. Framework-free.
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
6
|
npm i @funnest/charts-ui
|
|
@@ -13,18 +11,19 @@ import { createTradingChart } from '@funnest/charts-ui';
|
|
|
13
11
|
|
|
14
12
|
const widget = createTradingChart(document.getElementById('chart')!, {
|
|
15
13
|
datafeed: myDatafeed,
|
|
16
|
-
symbol: '
|
|
14
|
+
symbol: 'AAPL',
|
|
17
15
|
resolution: '1D',
|
|
18
|
-
colorScheme: 'system', // OS
|
|
16
|
+
colorScheme: 'system', // follows the OS light/dark setting
|
|
19
17
|
});
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- `save()` / `load()
|
|
20
|
+
- Works with any framework. In React, use `<FnChart />` from `@funnest/charts-react`.
|
|
21
|
+
- Put your own UI into slots: `toolbar`, `toolbarEnd`, `belowToolbar`, `footer`.
|
|
22
|
+
- `save()` / `load()` keep the layout (indicators, drawings, settings) as JSON.
|
|
23
|
+
- English by default, Korean for a Korean browser; replace any word with the `strings` option.
|
|
25
24
|
|
|
26
|
-
##
|
|
25
|
+
## Links
|
|
27
26
|
|
|
28
|
-
-
|
|
29
|
-
- GitHub: https://github.com/funnest-xyz/funnest-charts
|
|
30
|
-
-
|
|
27
|
+
- Docs: https://charts.funnest.xyz/docs/
|
|
28
|
+
- GitHub: https://github.com/funnest-xyz/funnest-charts ([한국어](https://github.com/funnest-xyz/funnest-charts/blob/main/README.ko.md))
|
|
29
|
+
- License: Apache-2.0
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Chart, ChartContextMenu, ChartLayout, ChartType, CompareInfo, Datafeed, Drawing, DrawingType, IndicatorConfig, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
|
|
1
|
+
import type { Chart, ChartContextMenu, ChartLayout, ChartType, CompareInfo, Datafeed, Drawing, DrawingType, IndicatorConfig, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
|
|
2
2
|
import type { LayoutId } from './layouts';
|
|
3
3
|
import type { WidgetStorage } from './storage';
|
|
4
4
|
import type { Strings } from './i18n';
|
|
@@ -40,6 +40,8 @@ export interface UiState {
|
|
|
40
40
|
canUndo: boolean;
|
|
41
41
|
canRedo: boolean;
|
|
42
42
|
compares: CompareInfo[];
|
|
43
|
+
/** The app's legend rows (chart.addLegendItem). */
|
|
44
|
+
legendItems: readonly LegendItem[];
|
|
43
45
|
replay: ReplayStatus;
|
|
44
46
|
}
|
|
45
47
|
/** A row in the chart's right-click menu, or a divider. */
|
package/dist/index.js
CHANGED
|
@@ -2624,6 +2624,27 @@ function IndicatorItem({ ctx, item }) {
|
|
|
2624
2624
|
}
|
|
2625
2625
|
);
|
|
2626
2626
|
}
|
|
2627
|
+
function AppItem({ ctx, item }) {
|
|
2628
|
+
const t3 = stringsOf(ctx.store.get());
|
|
2629
|
+
return /* @__PURE__ */ a3("div", { class: item.visible ? "fnc-ind" : "fnc-ind fnc-ind-hidden", children: [
|
|
2630
|
+
item.onToggle && /* @__PURE__ */ a3(
|
|
2631
|
+
"button",
|
|
2632
|
+
{
|
|
2633
|
+
class: "fnc-ind-btn fnc-ind-eye",
|
|
2634
|
+
"data-tip": item.visible ? t3.hide : t3.show,
|
|
2635
|
+
"aria-label": `${item.name} ${item.visible ? t3.hide : t3.show}`,
|
|
2636
|
+
"aria-pressed": !item.visible,
|
|
2637
|
+
onClick: () => ctx.chart.setLegendItemVisible(item.id, !item.visible),
|
|
2638
|
+
children: item.visible ? /* @__PURE__ */ a3(EyeIcon, {}) : /* @__PURE__ */ a3(EyeOffIcon, {})
|
|
2639
|
+
}
|
|
2640
|
+
),
|
|
2641
|
+
/* @__PURE__ */ a3("span", { class: "fnc-ind-title", children: item.name }),
|
|
2642
|
+
/* @__PURE__ */ a3("span", { class: "fnc-ind-actions", children: [
|
|
2643
|
+
item.onSettings && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.indicatorSettings, "aria-label": `${item.name} ${t3.indicatorSettings}`, onClick: () => item.onSettings?.(), children: /* @__PURE__ */ a3(GearIcon, {}) }),
|
|
2644
|
+
item.onRemove && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.removeIndicator, "aria-label": `${item.name} ${t3.removeIndicator}`, onClick: () => item.onRemove?.(), children: /* @__PURE__ */ a3(SmallCloseIcon, {}) })
|
|
2645
|
+
] })
|
|
2646
|
+
] });
|
|
2647
|
+
}
|
|
2627
2648
|
function Legend({ ctx }) {
|
|
2628
2649
|
const s3 = useStore(ctx.store);
|
|
2629
2650
|
const t3 = stringsOf(s3);
|
|
@@ -2729,7 +2750,8 @@ function Legend({ ctx }) {
|
|
|
2729
2750
|
)
|
|
2730
2751
|
] })),
|
|
2731
2752
|
!collapsed && overlayItems.map((item) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item })),
|
|
2732
|
-
|
|
2753
|
+
!collapsed && s3.legendItems.map((item) => /* @__PURE__ */ a3(AppItem, { ctx, item })),
|
|
2754
|
+
overlayItems.length + s3.legendItems.length > 0 && (collapsed ? /* @__PURE__ */ a3("button", { class: "fnc-ind-handle", "aria-expanded": "false", "aria-label": t3.expand, "data-tip": t3.expand, onClick: () => setCollapsed(false), children: /* @__PURE__ */ a3("span", {}) }) : /* @__PURE__ */ a3("button", { class: "fnc-ind-collapse", "aria-expanded": "true", "aria-label": t3.collapse, "data-tip": t3.collapse, onClick: () => setCollapsed(true), children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }))
|
|
2733
2755
|
] }),
|
|
2734
2756
|
paneLegends.map(
|
|
2735
2757
|
({ pane, item }) => item && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: /* @__PURE__ */ a3(IndicatorItem, { ctx, item }) })
|
|
@@ -4281,6 +4303,7 @@ function createPane(shell, config) {
|
|
|
4281
4303
|
canUndo: chart.canUndo,
|
|
4282
4304
|
canRedo: chart.canRedo,
|
|
4283
4305
|
compares: chart.getCompares(),
|
|
4306
|
+
legendItems: chart.legendItems,
|
|
4284
4307
|
replay: chart.replay,
|
|
4285
4308
|
chartType: config.chartType,
|
|
4286
4309
|
drawingTool: null,
|
|
@@ -4307,6 +4330,7 @@ function createPane(shell, config) {
|
|
|
4307
4330
|
chart.on("chartTypeChange", (chartType) => store.set({ chartType })),
|
|
4308
4331
|
chart.on("historyChange", ({ canUndo, canRedo }) => store.set({ canUndo, canRedo })),
|
|
4309
4332
|
chart.on("comparesChange", (compares) => store.set({ compares })),
|
|
4333
|
+
chart.on("legendItemsChange", (legendItems) => store.set({ legendItems })),
|
|
4310
4334
|
chart.on("replayChange", (replay) => store.set({ replay }))
|
|
4311
4335
|
];
|
|
4312
4336
|
const load = (sym, res) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"description": "Pro trading UI (toolbar, drawing tools, sheets) for Funnest Charts. Framework-agnostic.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"NOTICE"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@funnest/charts": "0.6.
|
|
45
|
+
"@funnest/charts": "0.6.20"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|