cordova-plugin-ra-chart 1.0.4 → 1.0.5

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 CHANGED
@@ -499,6 +499,54 @@ Force a mode per chart with a class:
499
499
 
500
500
  The default 8-colour palette is ordered so adjacent series stay distinguishable for colourblind viewers. If you pass your own `colors`, keep that in mind. Charts also carry non-colour cues — legends, direct labels, tooltips.
501
501
 
502
+ ### Changing the colours of every chart
503
+
504
+ Three ways, highest precedence first.
505
+
506
+ **Per chart** — `colors` wins over everything:
507
+
508
+ ```html
509
+ <ra-chart [colors]="['#534ab7', '#2196f3']" ...></ra-chart>
510
+ ```
511
+
512
+ **Globally in CSS** — the recommended way for Ionic. Set `--ra-chart-series-N`
513
+ from 1 upward; the engine reads until the first one you leave unset. Because it
514
+ is plain CSS, it is theme-scoped and switches automatically in dark mode:
515
+
516
+ ```css
517
+ /* src/global.scss — applies to every chart in the app */
518
+ .ra-chart {
519
+ --ra-chart-series-1: #534ab7;
520
+ --ra-chart-series-2: #2196f3;
521
+ --ra-chart-series-3: #f0334b;
522
+ --ra-chart-series-4: #eda100;
523
+ }
524
+
525
+ /* different steps for dark mode */
526
+ .ion-palette-dark .ra-chart {
527
+ --ra-chart-series-1: #9085e9;
528
+ --ra-chart-series-2: #3987e5;
529
+ --ra-chart-series-3: #e66767;
530
+ --ra-chart-series-4: #c98500;
531
+ }
532
+ ```
533
+
534
+ Scope it to recolour one section only — `.reports-page .ra-chart { … }`.
535
+
536
+ **Globally in JS** — one call before any chart is created, e.g. in `main.ts`:
537
+
538
+ ```ts
539
+ declare const RaChart: any;
540
+
541
+ RaChart.setPalette(['#534ab7', '#2196f3', '#f0334b', '#eda100']);
542
+ RaChart.setPalette(lightHexes, darkHexes); // separate dark steps
543
+ RaChart.resetPalette(); // back to the built-in palette
544
+ ```
545
+
546
+ Colours cycle when a chart has more series than you supply. Charts that already
547
+ exist keep their palette until they rebuild — call `replay()` on them, or set the
548
+ palette before creating any chart.
549
+
502
550
  ---
503
551
 
504
552
  ## Recipes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-ra-chart",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Dependency-free SVG chart engine for Cordova and Ionic — 21 chart types with touch gestures, pinch-to-zoom, haptics and dark-mode theming. No native code, no build step.",
5
5
  "main": "www/ra-chart.js",
6
6
  "types": "types/index.d.ts",
package/plugin.xml CHANGED
@@ -15,7 +15,7 @@
15
15
  -->
16
16
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
17
17
  id="cordova-plugin-ra-chart"
18
- version="1.0.3">
18
+ version="1.0.4">
19
19
 
20
20
  <name>raChart</name>
21
21
  <description>
package/types/index.d.ts CHANGED
@@ -200,6 +200,25 @@ export declare class RaChart {
200
200
  static paletteDark: string[];
201
201
  static types: RaChartType[];
202
202
  static create(host: HTMLElement | string, options?: RaChartOptions): RaChart;
203
+
204
+ /** Silence the "nothing to plot" console diagnostics. */
205
+ static warnings: boolean;
206
+
207
+ /**
208
+ * Recolour every chart created from now on. Pass one array to use it in
209
+ * both light and dark mode, or two for separate dark steps. Overridden per
210
+ * chart by `colors`, and by `--ra-chart-series-N` CSS variables.
211
+ */
212
+ static setPalette(light: string[], dark?: string[]): typeof RaChart;
213
+
214
+ /** Restore the built-in colourblind-safe palette. */
215
+ static resetPalette(): typeof RaChart;
216
+
217
+ /** Register `<ra-chart>` as a custom element (done automatically). */
218
+ static defineElement(tag?: string): boolean;
219
+
220
+ /** Inject the built-in structural stylesheet (done automatically). */
221
+ static injectStyles(): void;
203
222
  }
204
223
 
205
224
  export default RaChart;
package/www/ra-chart.css CHANGED
@@ -37,6 +37,20 @@ ra-chart {
37
37
 
38
38
  --ra-chart-radius: 12px;
39
39
 
40
+ /* ---- series palette ----
41
+ Uncomment and set these to recolour every chart. The engine reads
42
+ --ra-chart-series-1 upward and stops at the first one you leave unset,
43
+ so define as many as your busiest chart needs. Overridden per chart by
44
+ the `colors` option; overrides RaChart.setPalette().
45
+
46
+ --ra-chart-series-1: #534ab7;
47
+ --ra-chart-series-2: #2196f3;
48
+ --ra-chart-series-3: #f0334b;
49
+ --ra-chart-series-4: #eda100;
50
+ --ra-chart-series-5: #1baf7a;
51
+ --ra-chart-series-6: #eb6834;
52
+ */
53
+
40
54
  position: relative;
41
55
  display: block;
42
56
  width: 100%;
package/www/ra-chart.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * raChart Cordova v1.0.3 — mobile SVG chart engine
2
+ * raChart Cordova v1.0.4 — mobile SVG chart engine
3
3
  * RemoteApps UI Components
4
4
  *
5
5
  * Zero dependencies. No jQuery, no chart library, no build step.
@@ -20,14 +20,17 @@
20
20
  "use strict";
21
21
 
22
22
  var NS = "http://www.w3.org/2000/svg";
23
- var VERSION = "1.0.3";
23
+ var VERSION = "1.0.4";
24
24
 
25
25
  /* ============================================================
26
26
  Palettes — CVD-validated order, do not shuffle
27
27
  ============================================================ */
28
28
 
29
- var PALETTE_LIGHT = ["#2a78d6", "#008300", "#e87ba4", "#eda100", "#1baf7a", "#eb6834", "#4a3aa7", "#e34948"];
30
- var PALETTE_DARK = ["#3987e5", "#008300", "#d55181", "#c98500", "#199e70", "#d95926", "#9085e9", "#e66767"];
29
+ var DEFAULT_LIGHT = ["#2a78d6", "#008300", "#e87ba4", "#eda100", "#1baf7a", "#eb6834", "#4a3aa7", "#e34948"];
30
+ var DEFAULT_DARK = ["#3987e5", "#008300", "#d55181", "#c98500", "#199e70", "#d95926", "#9085e9", "#e66767"];
31
+ // live palettes — swapped by RaChart.setPalette()
32
+ var PALETTE_LIGHT = DEFAULT_LIGHT.slice();
33
+ var PALETTE_DARK = DEFAULT_DARK.slice();
31
34
  var SEQ_LIGHT = ["#cde2fb", "#9ec5f4", "#6da7ec", "#3987e5", "#256abf", "#184f95", "#0d366b"];
32
35
  var SEQ_DARK = ["#0d366b", "#184f95", "#256abf", "#3987e5", "#6da7ec", "#9ec5f4", "#cde2fb"];
33
36
 
@@ -445,6 +448,16 @@
445
448
  }
446
449
  var dark = v("--ra-chart-scheme", "light").indexOf("dark") >= 0;
447
450
  this.dark = dark;
451
+
452
+ // Palette from CSS custom properties: --ra-chart-series-1 .. -N, read until
453
+ // the first gap. Lets a theme file recolour every chart (and switch palettes
454
+ // in dark mode) with no JavaScript.
455
+ var cssSeries = [];
456
+ for (var i = 1; i <= 16; i++) {
457
+ var c = v("--ra-chart-series-" + i, "");
458
+ if (!c) break;
459
+ cssSeries.push(c);
460
+ }
448
461
  this.theme = {
449
462
  dark: dark,
450
463
  surface: v("--ra-chart-surface", dark ? "#1a1a19" : "#ffffff"),
@@ -455,7 +468,9 @@
455
468
  baseline: v("--ra-chart-baseline", dark ? "#383835" : "#c3c2b7"),
456
469
  body: v("--ra-chart-body", dark ? "#c3c2b7" : "#4b5563")
457
470
  };
458
- this.palette = this.opts.colors || (dark ? PALETTE_DARK : PALETTE_LIGHT);
471
+ // precedence: per-chart colors > CSS variables > global palette
472
+ this.palette = this.opts.colors ||
473
+ (cssSeries.length ? cssSeries : (dark ? PALETTE_DARK : PALETTE_LIGHT));
459
474
  this.seq = dark ? SEQ_DARK : SEQ_LIGHT;
460
475
  };
461
476
 
@@ -2907,6 +2922,42 @@
2907
2922
  RaChart.defaults = DEFAULTS;
2908
2923
  RaChart.palette = PALETTE_LIGHT;
2909
2924
  RaChart.paletteDark = PALETTE_DARK;
2925
+
2926
+ /**
2927
+ * Recolour every chart created from now on.
2928
+ *
2929
+ * RaChart.setPalette(['#534ab7', '#2196f3', '#f0334b']);
2930
+ * RaChart.setPalette(lightHexes, darkHexes); // separate dark steps
2931
+ *
2932
+ * Pass one array to use it in both modes. Colours cycle if a chart has more
2933
+ * series than you supply. Existing charts keep their palette until they
2934
+ * rebuild — call replay() on them, or set this before creating any chart.
2935
+ * Overridden per chart by `colors`, and by --ra-chart-series-N in CSS.
2936
+ */
2937
+ RaChart.setPalette = function (light, dark) {
2938
+ if (light && light.length) {
2939
+ PALETTE_LIGHT = light.slice();
2940
+ RaChart.palette = PALETTE_LIGHT;
2941
+ if (!dark || !dark.length) {
2942
+ PALETTE_DARK = light.slice();
2943
+ RaChart.paletteDark = PALETTE_DARK;
2944
+ }
2945
+ }
2946
+ if (dark && dark.length) {
2947
+ PALETTE_DARK = dark.slice();
2948
+ RaChart.paletteDark = PALETTE_DARK;
2949
+ }
2950
+ return RaChart;
2951
+ };
2952
+
2953
+ /** Restore the built-in colourblind-safe palette. */
2954
+ RaChart.resetPalette = function () {
2955
+ PALETTE_LIGHT = DEFAULT_LIGHT.slice();
2956
+ PALETTE_DARK = DEFAULT_DARK.slice();
2957
+ RaChart.palette = PALETTE_LIGHT;
2958
+ RaChart.paletteDark = PALETTE_DARK;
2959
+ return RaChart;
2960
+ };
2910
2961
  RaChart.types = Object.keys(KINDS);
2911
2962
  RaChart.create = function (host, options) { return new RaChart(host, options); };
2912
2963