zengeld-canvas 0.1.8 → 0.1.9
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 +49 -28
- package/package.json +1 -1
- package/zengeld_canvas_wasm.d.ts +160 -0
- package/zengeld_canvas_wasm.js +937 -127
- package/zengeld_canvas_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ WebAssembly bindings for the zengeld-canvas chart rendering engine. Built in Rus
|
|
|
13
13
|
- **12 Series Types** - Candlestick, HeikinAshi, Line, Area, Histogram, Baseline, and more
|
|
14
14
|
- **14 Multi-Chart Layouts** - Grid, split, and custom layouts for dashboards
|
|
15
15
|
- **High Performance** - Native Rust speed via WebAssembly
|
|
16
|
+
- **Theme System** - 4 built-in presets (dark, light, high_contrast, cyberpunk) + runtime customization
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -23,45 +24,65 @@ npm install zengeld-canvas
|
|
|
23
24
|
## Quick Start
|
|
24
25
|
|
|
25
26
|
```javascript
|
|
26
|
-
import init, { Chart, JsBar } from 'zengeld-canvas';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
import init, { Chart, JsBar, JsUITheme, JsRuntimeTheme } from 'zengeld-canvas';
|
|
28
|
+
|
|
29
|
+
await init();
|
|
30
|
+
|
|
31
|
+
// Create chart
|
|
32
|
+
const chart = new Chart(800, 600);
|
|
33
|
+
chart.setBars(bars);
|
|
34
|
+
chart.candlesticks();
|
|
35
|
+
chart.sma(20, "#2196F3");
|
|
36
|
+
const svg = chart.renderSvg();
|
|
37
|
+
|
|
38
|
+
// With theme preset
|
|
39
|
+
const theme = JsUITheme.cyberpunk();
|
|
40
|
+
const chart2 = new Chart(800, 600);
|
|
41
|
+
chart2.setBars(bars);
|
|
42
|
+
chart2.candlesticks();
|
|
43
|
+
chart2.background(theme.background);
|
|
44
|
+
chart2.colors(theme.candle_up_body, theme.candle_down_body);
|
|
45
|
+
|
|
46
|
+
// Runtime theme (modifiable)
|
|
47
|
+
const runtime = JsRuntimeTheme.fromPreset("dark");
|
|
48
|
+
runtime.background = "#1a0a2e"; // Custom background
|
|
49
|
+
runtime.candle_up_body = "#00ffff"; // Cyan
|
|
50
|
+
const json = runtime.toJson();
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
## Examples
|
|
53
54
|
|
|
54
55
|
<table>
|
|
55
56
|
<tr>
|
|
56
|
-
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/
|
|
57
|
-
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/
|
|
57
|
+
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/09_light_theme.svg" width="400"/><br/><b>Light Theme</b></td>
|
|
58
|
+
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/09b_high_contrast_theme.svg" width="400"/><br/><b>High Contrast Theme</b></td>
|
|
58
59
|
</tr>
|
|
59
60
|
<tr>
|
|
60
|
-
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/
|
|
61
|
-
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/
|
|
61
|
+
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/09c_cyberpunk_theme.svg" width="400"/><br/><b>Cyberpunk Theme</b></td>
|
|
62
|
+
<td align="center"><img src="https://raw.githubusercontent.com/zengeld/zengeld-canvas/main/crates/canvas/chart_output/09d_runtime_theme.svg" width="400"/><br/><b>Runtime Custom Theme</b></td>
|
|
62
63
|
</tr>
|
|
63
64
|
</table>
|
|
64
65
|
|
|
66
|
+
## Theme System
|
|
67
|
+
|
|
68
|
+
Built-in presets: `dark()`, `light()`, `highContrast()`, `cyberpunk()`
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { JsUITheme, JsRuntimeTheme } from 'zengeld-canvas';
|
|
72
|
+
|
|
73
|
+
// Static themes
|
|
74
|
+
const dark = JsUITheme.dark();
|
|
75
|
+
const light = JsUITheme.light();
|
|
76
|
+
|
|
77
|
+
// Runtime themes (modifiable, JSON support)
|
|
78
|
+
const runtime = JsRuntimeTheme.fromPreset("dark");
|
|
79
|
+
runtime.background = "#1a0a2e";
|
|
80
|
+
const json = runtime.toJson();
|
|
81
|
+
|
|
82
|
+
// Available presets
|
|
83
|
+
const presets = JsRuntimeTheme.presets(); // ["dark", "light", "high_contrast", "cyberpunk"]
|
|
84
|
+
```
|
|
85
|
+
|
|
65
86
|
## Drawing Primitives
|
|
66
87
|
|
|
67
88
|
| Category | Count | Examples |
|
package/package.json
CHANGED
package/zengeld_canvas_wasm.d.ts
CHANGED
|
@@ -744,6 +744,64 @@ export class JsChartConfig {
|
|
|
744
744
|
constructor();
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
+
export class JsRuntimeTheme {
|
|
748
|
+
private constructor();
|
|
749
|
+
free(): void;
|
|
750
|
+
[Symbol.dispose](): void;
|
|
751
|
+
/**
|
|
752
|
+
* Create from preset name: "dark", "light", "high_contrast", "cyberpunk"
|
|
753
|
+
*/
|
|
754
|
+
static fromPreset(name: string): JsRuntimeTheme;
|
|
755
|
+
/**
|
|
756
|
+
* Create high contrast theme
|
|
757
|
+
*/
|
|
758
|
+
static highContrast(): JsRuntimeTheme;
|
|
759
|
+
/**
|
|
760
|
+
* Serialize to pretty JSON string
|
|
761
|
+
*/
|
|
762
|
+
toJsonPretty(): string;
|
|
763
|
+
/**
|
|
764
|
+
* Create dark theme
|
|
765
|
+
*/
|
|
766
|
+
static dark(): JsRuntimeTheme;
|
|
767
|
+
/**
|
|
768
|
+
* Create light theme
|
|
769
|
+
*/
|
|
770
|
+
static light(): JsRuntimeTheme;
|
|
771
|
+
/**
|
|
772
|
+
* Get available preset names
|
|
773
|
+
*/
|
|
774
|
+
static presets(): string[];
|
|
775
|
+
/**
|
|
776
|
+
* Serialize to JSON string
|
|
777
|
+
*/
|
|
778
|
+
toJson(): string;
|
|
779
|
+
/**
|
|
780
|
+
* Create cyberpunk theme
|
|
781
|
+
*/
|
|
782
|
+
static cyberpunk(): JsRuntimeTheme;
|
|
783
|
+
/**
|
|
784
|
+
* Deserialize from JSON string
|
|
785
|
+
*/
|
|
786
|
+
static fromJson(json: string): JsRuntimeTheme | undefined;
|
|
787
|
+
background: string;
|
|
788
|
+
lineColor: string;
|
|
789
|
+
scaleText: string;
|
|
790
|
+
accent: string;
|
|
791
|
+
danger: string;
|
|
792
|
+
toolbarBg: string;
|
|
793
|
+
maFast: string;
|
|
794
|
+
maSlow: string;
|
|
795
|
+
success: string;
|
|
796
|
+
scaleBg: string;
|
|
797
|
+
textPrimary: string;
|
|
798
|
+
gridLine: string;
|
|
799
|
+
candleUpBody: string;
|
|
800
|
+
crosshairLine: string;
|
|
801
|
+
candleDownBody: string;
|
|
802
|
+
name: string;
|
|
803
|
+
}
|
|
804
|
+
|
|
747
805
|
export class JsTheme {
|
|
748
806
|
private constructor();
|
|
749
807
|
free(): void;
|
|
@@ -757,6 +815,44 @@ export class JsTheme {
|
|
|
757
815
|
readonly candleUp: string;
|
|
758
816
|
}
|
|
759
817
|
|
|
818
|
+
export class JsUITheme {
|
|
819
|
+
private constructor();
|
|
820
|
+
free(): void;
|
|
821
|
+
[Symbol.dispose](): void;
|
|
822
|
+
/**
|
|
823
|
+
* Create high contrast theme (accessibility)
|
|
824
|
+
*/
|
|
825
|
+
static highContrast(): JsUITheme;
|
|
826
|
+
/**
|
|
827
|
+
* Create dark theme (TradingView-like)
|
|
828
|
+
*/
|
|
829
|
+
static dark(): JsUITheme;
|
|
830
|
+
/**
|
|
831
|
+
* Create light theme
|
|
832
|
+
*/
|
|
833
|
+
static light(): JsUITheme;
|
|
834
|
+
/**
|
|
835
|
+
* Create cyberpunk/neon theme
|
|
836
|
+
*/
|
|
837
|
+
static cyberpunk(): JsUITheme;
|
|
838
|
+
readonly background: string;
|
|
839
|
+
readonly lineColor: string;
|
|
840
|
+
readonly scaleText: string;
|
|
841
|
+
readonly toolbarBg: string;
|
|
842
|
+
readonly textPrimary: string;
|
|
843
|
+
readonly candleUpBody: string;
|
|
844
|
+
readonly crosshairLine: string;
|
|
845
|
+
readonly candleDownBody: string;
|
|
846
|
+
readonly name: string;
|
|
847
|
+
readonly accent: string;
|
|
848
|
+
readonly danger: string;
|
|
849
|
+
readonly maFast: string;
|
|
850
|
+
readonly maSlow: string;
|
|
851
|
+
readonly success: string;
|
|
852
|
+
readonly scaleBg: string;
|
|
853
|
+
readonly gridLine: string;
|
|
854
|
+
}
|
|
855
|
+
|
|
760
856
|
export class JsViewport {
|
|
761
857
|
free(): void;
|
|
762
858
|
[Symbol.dispose](): void;
|
|
@@ -782,7 +878,9 @@ export interface InitOutput {
|
|
|
782
878
|
readonly __wbg_chart_free: (a: number, b: number) => void;
|
|
783
879
|
readonly __wbg_jsbar_free: (a: number, b: number) => void;
|
|
784
880
|
readonly __wbg_jschartconfig_free: (a: number, b: number) => void;
|
|
881
|
+
readonly __wbg_jsruntimetheme_free: (a: number, b: number) => void;
|
|
785
882
|
readonly __wbg_jstheme_free: (a: number, b: number) => void;
|
|
883
|
+
readonly __wbg_jsuitheme_free: (a: number, b: number) => void;
|
|
786
884
|
readonly __wbg_jsviewport_free: (a: number, b: number) => void;
|
|
787
885
|
readonly chart_abcdPattern: (a: number, b: number, c: number) => void;
|
|
788
886
|
readonly chart_acceleratorOscillator: (a: number) => void;
|
|
@@ -972,6 +1070,47 @@ export interface InitOutput {
|
|
|
972
1070
|
readonly jsbar_timestamp: (a: number) => bigint;
|
|
973
1071
|
readonly jsbar_volume: (a: number) => number;
|
|
974
1072
|
readonly jschartconfig_new: () => number;
|
|
1073
|
+
readonly jsruntimetheme_accent: (a: number) => [number, number];
|
|
1074
|
+
readonly jsruntimetheme_background: (a: number) => [number, number];
|
|
1075
|
+
readonly jsruntimetheme_candleDownBody: (a: number) => [number, number];
|
|
1076
|
+
readonly jsruntimetheme_candleUpBody: (a: number) => [number, number];
|
|
1077
|
+
readonly jsruntimetheme_crosshairLine: (a: number) => [number, number];
|
|
1078
|
+
readonly jsruntimetheme_cyberpunk: () => number;
|
|
1079
|
+
readonly jsruntimetheme_danger: (a: number) => [number, number];
|
|
1080
|
+
readonly jsruntimetheme_dark: () => number;
|
|
1081
|
+
readonly jsruntimetheme_fromJson: (a: number, b: number) => number;
|
|
1082
|
+
readonly jsruntimetheme_fromPreset: (a: number, b: number) => number;
|
|
1083
|
+
readonly jsruntimetheme_gridLine: (a: number) => [number, number];
|
|
1084
|
+
readonly jsruntimetheme_highContrast: () => number;
|
|
1085
|
+
readonly jsruntimetheme_light: () => number;
|
|
1086
|
+
readonly jsruntimetheme_lineColor: (a: number) => [number, number];
|
|
1087
|
+
readonly jsruntimetheme_maFast: (a: number) => [number, number];
|
|
1088
|
+
readonly jsruntimetheme_maSlow: (a: number) => [number, number];
|
|
1089
|
+
readonly jsruntimetheme_name: (a: number) => [number, number];
|
|
1090
|
+
readonly jsruntimetheme_presets: () => [number, number];
|
|
1091
|
+
readonly jsruntimetheme_scaleBg: (a: number) => [number, number];
|
|
1092
|
+
readonly jsruntimetheme_scaleText: (a: number) => [number, number];
|
|
1093
|
+
readonly jsruntimetheme_set_accent: (a: number, b: number, c: number) => void;
|
|
1094
|
+
readonly jsruntimetheme_set_background: (a: number, b: number, c: number) => void;
|
|
1095
|
+
readonly jsruntimetheme_set_candleDownBody: (a: number, b: number, c: number) => void;
|
|
1096
|
+
readonly jsruntimetheme_set_candleUpBody: (a: number, b: number, c: number) => void;
|
|
1097
|
+
readonly jsruntimetheme_set_crosshairLine: (a: number, b: number, c: number) => void;
|
|
1098
|
+
readonly jsruntimetheme_set_danger: (a: number, b: number, c: number) => void;
|
|
1099
|
+
readonly jsruntimetheme_set_gridLine: (a: number, b: number, c: number) => void;
|
|
1100
|
+
readonly jsruntimetheme_set_lineColor: (a: number, b: number, c: number) => void;
|
|
1101
|
+
readonly jsruntimetheme_set_maFast: (a: number, b: number, c: number) => void;
|
|
1102
|
+
readonly jsruntimetheme_set_maSlow: (a: number, b: number, c: number) => void;
|
|
1103
|
+
readonly jsruntimetheme_set_name: (a: number, b: number, c: number) => void;
|
|
1104
|
+
readonly jsruntimetheme_set_scaleBg: (a: number, b: number, c: number) => void;
|
|
1105
|
+
readonly jsruntimetheme_set_scaleText: (a: number, b: number, c: number) => void;
|
|
1106
|
+
readonly jsruntimetheme_set_success: (a: number, b: number, c: number) => void;
|
|
1107
|
+
readonly jsruntimetheme_set_textPrimary: (a: number, b: number, c: number) => void;
|
|
1108
|
+
readonly jsruntimetheme_set_toolbarBg: (a: number, b: number, c: number) => void;
|
|
1109
|
+
readonly jsruntimetheme_success: (a: number) => [number, number];
|
|
1110
|
+
readonly jsruntimetheme_textPrimary: (a: number) => [number, number];
|
|
1111
|
+
readonly jsruntimetheme_toJson: (a: number) => [number, number];
|
|
1112
|
+
readonly jsruntimetheme_toJsonPretty: (a: number) => [number, number];
|
|
1113
|
+
readonly jsruntimetheme_toolbarBg: (a: number) => [number, number];
|
|
975
1114
|
readonly jstheme_bgColor: (a: number) => [number, number];
|
|
976
1115
|
readonly jstheme_candleDown: (a: number) => [number, number];
|
|
977
1116
|
readonly jstheme_candleUp: (a: number) => [number, number];
|
|
@@ -979,6 +1118,26 @@ export interface InitOutput {
|
|
|
979
1118
|
readonly jstheme_gridColor: (a: number) => [number, number];
|
|
980
1119
|
readonly jstheme_light: () => number;
|
|
981
1120
|
readonly jstheme_textColor: (a: number) => [number, number];
|
|
1121
|
+
readonly jsuitheme_accent: (a: number) => [number, number];
|
|
1122
|
+
readonly jsuitheme_background: (a: number) => [number, number];
|
|
1123
|
+
readonly jsuitheme_candleDownBody: (a: number) => [number, number];
|
|
1124
|
+
readonly jsuitheme_candleUpBody: (a: number) => [number, number];
|
|
1125
|
+
readonly jsuitheme_crosshairLine: (a: number) => [number, number];
|
|
1126
|
+
readonly jsuitheme_cyberpunk: () => number;
|
|
1127
|
+
readonly jsuitheme_danger: (a: number) => [number, number];
|
|
1128
|
+
readonly jsuitheme_dark: () => number;
|
|
1129
|
+
readonly jsuitheme_gridLine: (a: number) => [number, number];
|
|
1130
|
+
readonly jsuitheme_highContrast: () => number;
|
|
1131
|
+
readonly jsuitheme_light: () => number;
|
|
1132
|
+
readonly jsuitheme_lineColor: (a: number) => [number, number];
|
|
1133
|
+
readonly jsuitheme_maFast: (a: number) => [number, number];
|
|
1134
|
+
readonly jsuitheme_maSlow: (a: number) => [number, number];
|
|
1135
|
+
readonly jsuitheme_name: (a: number) => [number, number];
|
|
1136
|
+
readonly jsuitheme_scaleBg: (a: number) => [number, number];
|
|
1137
|
+
readonly jsuitheme_scaleText: (a: number) => [number, number];
|
|
1138
|
+
readonly jsuitheme_success: (a: number) => [number, number];
|
|
1139
|
+
readonly jsuitheme_textPrimary: (a: number) => [number, number];
|
|
1140
|
+
readonly jsuitheme_toolbarBg: (a: number) => [number, number];
|
|
982
1141
|
readonly jsviewport_barWidth: (a: number) => number;
|
|
983
1142
|
readonly jsviewport_chartHeight: (a: number) => number;
|
|
984
1143
|
readonly jsviewport_chartWidth: (a: number) => number;
|
|
@@ -992,6 +1151,7 @@ export interface InitOutput {
|
|
|
992
1151
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
993
1152
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
994
1153
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
1154
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
995
1155
|
readonly __externref_table_alloc: () => number;
|
|
996
1156
|
readonly __wbindgen_start: () => void;
|
|
997
1157
|
}
|