@servicetitan/anvil2-ext-charts 0.1.3 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @servicetitan/anvil2-ext-common
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2060](https://github.com/servicetitan/hammer/pull/2060) [`8e4cea6`](https://github.com/servicetitan/hammer/commit/8e4cea6a5fdc178edae27518450f1204464831eb) Thanks [@rgdelato](https://github.com/rgdelato)! - [Illustrations] Add new `@servicetitan/anvil2-illustrations` package
8
+
9
+ ## 0.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1909](https://github.com/servicetitan/hammer/pull/1909) [`8547db6`](https://github.com/servicetitan/hammer/commit/8547db6b951d84f2f3dc677d2e46b61ec78ab5e1) Thanks [@rgdelato](https://github.com/rgdelato)! - Bump `peerDependencies` versions of React to `^18 || ^19`
14
+
3
15
  ## 0.1.3
4
16
 
5
17
  ### Patch Changes
@@ -13153,7 +13153,8 @@ if (once) {
13153
13153
  const createTheme = ({
13154
13154
  fills: fillValues,
13155
13155
  strokes: strokeValues,
13156
- fillPatterns: fillPatternTypes
13156
+ fillPatterns: fillPatternTypes,
13157
+ colorOrder
13157
13158
  }) => {
13158
13159
  class ThemeCustom extends am5.Theme {
13159
13160
  constructor(root, isReal) {
@@ -13178,8 +13179,20 @@ const createTheme = ({
13178
13179
  // this mutates the array if we don't clone it o.o
13179
13180
  reuse: true
13180
13181
  });
13182
+ const tempEl = document.createElement("div");
13183
+ tempEl.style.color = "var(--foreground-color, #141414)";
13184
+ this._root.dom.appendChild(tempEl);
13185
+ const computedColor = getComputedStyle(tempEl).color;
13186
+ tempEl.remove();
13187
+ const rgbMatch = computedColor.match(/\d+/g);
13188
+ const foregroundColor = rgbMatch && rgbMatch.length >= 3 ? "#" + rgbMatch.slice(0, 3).map((n) => parseInt(n).toString(16).padStart(2, "0")).join("") : "#141414";
13181
13189
  this.rule("Label").setAll({
13182
- fontFamily: "Nunito Sans"
13190
+ fontFamily: "Nunito Sans",
13191
+ fill: am5.color(foregroundColor)
13192
+ });
13193
+ this.rule("Grid").setAll({
13194
+ stroke: am5.color(foregroundColor),
13195
+ strokeOpacity: 0.15
13183
13196
  });
13184
13197
  this.rule("Legend").setAll({
13185
13198
  clickTarget: "none"
@@ -13205,6 +13218,7 @@ const createTheme = ({
13205
13218
  target.ticks.template.set("visible", false);
13206
13219
  };
13207
13220
  this.rule("RadialLabel", ["pie", "series"]).setup = (target) => {
13221
+ target.set("fill", am5.color("#141414"));
13208
13222
  target.set("fontWeight", "600");
13209
13223
  target.set("baseRadius", am5.percent(65));
13210
13224
  target.set("x", am5.p50);
@@ -13249,7 +13263,56 @@ const createTheme = ({
13249
13263
  }
13250
13264
  });
13251
13265
  });
13266
+ if (colorOrder) {
13267
+ const getReorderedColorIndex = (idx) => colorOrder[idx % colorOrder.length];
13268
+ const getSliceReorderIndex = (target) => {
13269
+ const series = target.dataItem?.component;
13270
+ if (!series || series.dataItems.length < 4) return void 0;
13271
+ const idx = series.dataItems.indexOf(target.dataItem);
13272
+ return idx >= 0 ? getReorderedColorIndex(idx) : void 0;
13273
+ };
13274
+ this.rule("Slice").adapters.add("fill", (fill, target) => {
13275
+ const ci = getSliceReorderIndex(target);
13276
+ return ci != null ? fills[ci] : fill;
13277
+ });
13278
+ this.rule("Slice").adapters.add("stroke", (stroke, target) => {
13279
+ const ci = getSliceReorderIndex(target);
13280
+ return ci != null ? strokes[ci] ?? fills[ci] : stroke;
13281
+ });
13282
+ this.rule("Slice").adapters.add("fillPattern", (pattern, target) => {
13283
+ const ci = getSliceReorderIndex(target);
13284
+ return ci != null ? fillPatterns[ci] : pattern;
13285
+ });
13286
+ const getSeriesReorderIndex = (target) => {
13287
+ const chart = target.chart;
13288
+ if (!chart) return void 0;
13289
+ const allColumnSeries = chart.series.values.filter(
13290
+ (s) => s instanceof ColumnSeries
13291
+ );
13292
+ if (allColumnSeries.length < 4) return void 0;
13293
+ const idx = allColumnSeries.indexOf(target);
13294
+ return idx >= 0 ? getReorderedColorIndex(idx) : void 0;
13295
+ };
13296
+ this.rule("ColumnSeries").adapters.add("fill", (fill, target) => {
13297
+ const ci = getSeriesReorderIndex(target);
13298
+ return ci != null ? fills[ci] : fill;
13299
+ });
13300
+ this.rule("ColumnSeries").adapters.add("stroke", (stroke, target) => {
13301
+ const ci = getSeriesReorderIndex(target);
13302
+ return ci != null ? strokes[ci] ?? fills[ci] : stroke;
13303
+ });
13304
+ this.rule("ColumnSeries").adapters.add(
13305
+ "fillPattern",
13306
+ (pattern, target) => {
13307
+ const ci = getSeriesReorderIndex(target);
13308
+ return ci != null ? fillPatterns[ci] : pattern;
13309
+ }
13310
+ );
13311
+ }
13252
13312
  this.rule("AxisRendererX").setup = (target) => {
13313
+ target.setAll({
13314
+ stroke: am5.color(foregroundColor)
13315
+ });
13253
13316
  target.labels.template.setAll({
13254
13317
  centerY: am5.p100,
13255
13318
  centerX: am5.p50,
@@ -13258,6 +13321,9 @@ const createTheme = ({
13258
13321
  });
13259
13322
  };
13260
13323
  this.rule("AxisRendererY").setup = (target) => {
13324
+ target.setAll({
13325
+ stroke: am5.color(foregroundColor)
13326
+ });
13261
13327
  target.labels.template.setAll({
13262
13328
  centerY: am5.p50,
13263
13329
  centerX: am5.p100,
@@ -13328,6 +13394,40 @@ const createTheme = ({
13328
13394
  fontWeight: "600"
13329
13395
  });
13330
13396
  target.set("tooltip", customTooltip);
13397
+ target.columns.template.events.on(
13398
+ "pointerover",
13399
+ ({ target: column }) => {
13400
+ const series = column.dataItem?.component;
13401
+ const chart = series?.chart;
13402
+ if (!chart) return;
13403
+ chart.series.each((s) => {
13404
+ if (s instanceof ColumnSeries) {
13405
+ s.columns.each((col) => {
13406
+ if (col !== column) {
13407
+ col.set("opacity", 0.2);
13408
+ }
13409
+ });
13410
+ }
13411
+ });
13412
+ }
13413
+ );
13414
+ target.columns.template.events.on(
13415
+ "pointerout",
13416
+ ({ target: column }) => {
13417
+ const series = column.dataItem?.component;
13418
+ const chart = series?.chart;
13419
+ if (!chart) return;
13420
+ chart.series.each((s) => {
13421
+ if (s instanceof ColumnSeries) {
13422
+ s.columns.each((col) => {
13423
+ if (col !== column) {
13424
+ col.set("opacity", 1);
13425
+ }
13426
+ });
13427
+ }
13428
+ });
13429
+ }
13430
+ );
13331
13431
  j += 1;
13332
13432
  if (j == fills.length) j = 0;
13333
13433
  };
@@ -13345,7 +13445,8 @@ const patterns$2 = allMonochromeChartTokens.filter((key) => key.indexOf("Pattern
13345
13445
  const ThemeMonochrome = createTheme({
13346
13446
  fills: colors$2,
13347
13447
  strokes: strokes$2,
13348
- fillPatterns: patterns$2
13448
+ fillPatterns: patterns$2,
13449
+ colorOrder: [3, 0, 1, 2]
13349
13450
  });
13350
13451
 
13351
13452
  const allCategoricalChartTokens = Object.keys(core.semantic).filter(
@@ -13394,4 +13495,4 @@ const ThemeSemantic = createTheme({
13394
13495
  });
13395
13496
 
13396
13497
  export { ThemeMonochrome as T, ThemeCategorical as a, ThemeSemantic as b };
13397
- //# sourceMappingURL=ThemeSemantic-CNjZwPLr.js.map
13498
+ //# sourceMappingURL=ThemeSemantic-CaFj4ckO.js.map