remoraid 3.6.0 → 3.7.0

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.
@@ -5914,6 +5914,7 @@ function RingSummary({
5914
5914
  // src/data-visualization/components/Chart/index.tsx
5915
5915
  var import_lodash2 = __toESM(require_lodash());
5916
5916
  var import_d3_array = require("d3-array");
5917
+ var import_colors = require("@nivo/colors");
5917
5918
  var jsx_runtime5 = require("react/jsx-runtime");
5918
5919
  function Chart({
5919
5920
  type,
@@ -5934,11 +5935,13 @@ function Chart({
5934
5935
  let includeEntityChips = true;
5935
5936
  let includeLegend = false;
5936
5937
  let entities = [];
5938
+ let chartColors = [];
5937
5939
  let chart;
5938
5940
  const controls = [];
5939
5941
  if (type === "timeSeriesStackedAreas" /* TimeSeriesStackedAreas */) {
5940
5942
  includeEntityChips = options.includeEntityChips ?? true;
5941
5943
  includeLegend = options?.includeLegend ?? includeLegend;
5944
+ chartColors = componentsProps?.chart?.colors ?? options?.colors ?? nivoConfiguration.colors;
5942
5945
  data.values.sort((a, b) => a.date.getTime() - b.date.getTime());
5943
5946
  const guideValue = data.values.length > 0 ? data.values[data.values.length - 1 - windowOffset] : null;
5944
5947
  const chartData = [];
@@ -5968,7 +5971,6 @@ function Chart({
5968
5971
  } : undefined;
5969
5972
  const unit = data.units[options.dimension];
5970
5973
  chart = /* @__PURE__ */ jsx_runtime5.jsx(import_stream.ResponsiveStream, {
5971
- colors: options.colors ?? nivoConfiguration.colors,
5972
5974
  theme: nivoConfiguration.theme,
5973
5975
  data: chartData,
5974
5976
  keys: entities,
@@ -6027,7 +6029,8 @@ function Chart({
6027
6029
  }),
6028
6030
  curve: "linear",
6029
6031
  offsetType: "diverging",
6030
- ...componentsProps?.chart
6032
+ ...componentsProps?.chart,
6033
+ colors: chartColors
6031
6034
  }, entities.join(","));
6032
6035
  const increaseWindowOffsetButton = /* @__PURE__ */ jsx_runtime5.jsx(import_core10.RemoraidButton, {
6033
6036
  mounted: window !== null,
@@ -6148,6 +6151,7 @@ function Chart({
6148
6151
  }
6149
6152
  const includeControls = controls.length > 0;
6150
6153
  const numCols = Number(includeEntityChips) + Number(includeControls);
6154
+ const getEntityColor = import_colors.useOrdinalColorScale(chartColors, "id");
6151
6155
  return /* @__PURE__ */ jsx_runtime5.jsx(import_core9.Transition, {
6152
6156
  mounted,
6153
6157
  children: (transitionStyle) => /* @__PURE__ */ jsx_runtime5.jsxs(import_core9.Paper, {
@@ -6174,13 +6178,13 @@ function Chart({
6174
6178
  onChange: (newValue) => {
6175
6179
  setHiddenEntities(entities.filter((e) => !newValue.includes(e)));
6176
6180
  },
6177
- children: entities.map((entitiy, i) => /* @__PURE__ */ jsx_runtime5.jsx(import_core9.Chip, {
6178
- value: entitiy,
6181
+ children: entities.map((entity, i) => /* @__PURE__ */ jsx_runtime5.jsx(import_core9.Chip, {
6182
+ value: entity,
6179
6183
  icon: /* @__PURE__ */ jsx_runtime5.jsx(import_icons_react2.IconCheck, {
6180
6184
  ...theme.componentsProps.icons.tiny
6181
6185
  }),
6182
- color: chartsUserExperience.colors[i % chartsUserExperience.colors.length],
6183
- children: entitiy
6186
+ color: getEntityColor({ id: entity, path: "" }),
6187
+ children: entity
6184
6188
  }, i))
6185
6189
  })
6186
6190
  }),
@@ -6416,21 +6420,25 @@ var import_modals = require("@mantine/modals");
6416
6420
  var import_icons_react4 = require("@tabler/icons-react");
6417
6421
  var import_react5 = require("react");
6418
6422
  var import_core18 = require("remoraid/core");
6423
+ var import_colors2 = require("@nivo/colors");
6419
6424
  var jsx_runtime11 = require("react/jsx-runtime");
6420
6425
  var defaultTimeseriesExplorerWidgetId = "timeseries-explorer";
6421
6426
  function TimeSeriesExplorerWidget({
6422
6427
  data,
6423
6428
  isLoadingData,
6429
+ hideZeroOnlyEntities = true,
6424
6430
  widgetProps,
6425
6431
  componentsProps
6426
6432
  }) {
6427
- const { userExperience: chartsUserExperience } = useChartsUserExperience();
6433
+ const nivoConfiguration = useNivoConfiguration();
6428
6434
  const [selectedDimension, setSelectedDimension] = import_react5.useState(null);
6429
6435
  const dimensions = data ? Object.keys(data.units) : [];
6436
+ const chartColors = componentsProps?.primaryChart?.options?.colors ?? nivoConfiguration.colors;
6430
6437
  const entities = data && data.values.length > 0 ? Object.keys(data.values[0].entities) : [];
6431
- const entityColors = entities.reduce((t, entity, i) => ({
6438
+ const getEntityColor = import_colors2.useOrdinalColorScale(chartColors, "id");
6439
+ const entityColors = entities.reduce((t, entity) => ({
6432
6440
  ...t,
6433
- [entity]: chartsUserExperience.colors[i % chartsUserExperience.colors.length]
6441
+ [entity]: getEntityColor({ id: entity, path: "" })
6434
6442
  }), {});
6435
6443
  const axisLegends = data ? dimensions.reduce((t, d) => {
6436
6444
  const unit = data.units[d];
@@ -6516,15 +6524,17 @@ function TimeSeriesExplorerWidget({
6516
6524
  },
6517
6525
  ...componentsProps?.entitiesGrid,
6518
6526
  children: entities.map((entity) => {
6527
+ const entityChartData = reduceTimeSeriesEntities(data, (t, [e, value]) => e === entity ? { [entity]: value } : t, {
6528
+ [entity]: {
6529
+ [selectedDimension]: 0
6530
+ }
6531
+ });
6532
+ const hasNonZeroValue = entityChartData.values.some((v) => [v.entities[entity][selectedDimension]].flat(2)[0] !== 0);
6519
6533
  const entityChartProps = {
6520
6534
  type: "timeSeriesStackedAreas" /* TimeSeriesStackedAreas */,
6521
6535
  ...componentsProps?.chart,
6522
6536
  ...componentsProps?.entityChart,
6523
- data: reduceTimeSeriesEntities(data, (t, [e, value]) => e === entity ? { [entity]: value } : t, {
6524
- [entity]: {
6525
- [selectedDimension]: 0
6526
- }
6527
- }),
6537
+ data: entityChartData,
6528
6538
  options: {
6529
6539
  dimension: selectedDimension,
6530
6540
  axisBottomLegend: "Time",
@@ -6537,6 +6547,7 @@ function TimeSeriesExplorerWidget({
6537
6547
  };
6538
6548
  return /* @__PURE__ */ jsx_runtime11.jsx(Chart, {
6539
6549
  h: 275,
6550
+ mounted: !(hideZeroOnlyEntities && !hasNonZeroValue),
6540
6551
  ...entityChartProps,
6541
6552
  additionalControls: [
6542
6553
  /* @__PURE__ */ jsx_runtime11.jsx(import_core18.RemoraidButton, {
@@ -327,8 +327,8 @@ interface ChartsUserExperience {
327
327
  colors: string[];
328
328
  }
329
329
  interface NivoConfiguration {
330
+ colors: OrdinalColorScaleConfig;
330
331
  theme?: PartialNivoTheme;
331
- colors?: OrdinalColorScaleConfig;
332
332
  }
333
333
  interface NivoConfigurationDependencies {
334
334
  remoraidTheme: RemoraidTheme;
@@ -491,6 +491,7 @@ type PartialChartProps = Omit<Partial<ChartPropsGeneric<ChartType.TimeSeriesStac
491
491
  interface TimeSeriesExplorerWidgetProps {
492
492
  data?: TimeSeriesData<string, string>;
493
493
  isLoadingData?: boolean;
494
+ hideZeroOnlyEntities?: boolean;
494
495
  widgetProps?: Partial<WidgetProps>;
495
496
  componentsProps?: {
496
497
  contentContainer?: Partial<StackProps6>
@@ -501,7 +502,7 @@ interface TimeSeriesExplorerWidgetProps {
501
502
  missingDataAlert?: Partial<AlertMinimalProps>
502
503
  };
503
504
  }
504
- declare function TimeSeriesExplorerWidget({ data, isLoadingData, widgetProps, componentsProps }: TimeSeriesExplorerWidgetProps): ReactNode52;
505
+ declare function TimeSeriesExplorerWidget({ data, isLoadingData, hideZeroOnlyEntities, widgetProps, componentsProps }: TimeSeriesExplorerWidgetProps): ReactNode52;
505
506
  import { ReactNode as ReactNode53 } from "react";
506
507
  declare const defaultVerticalChartsWidgetId = "vertical-charts";
507
508
  interface VerticalChartsWidgetProps {
@@ -5612,10 +5612,7 @@ function ChartsUserExperienceProvider({
5612
5612
  }
5613
5613
 
5614
5614
  // src/data-visualization/components/RemoraidDataVisualizationProvider/NivoConfigurationProvider/index.tsx
5615
- import {
5616
- useHydratedMantineColorScheme,
5617
- useRemoraidTheme as useRemoraidTheme2
5618
- } from "remoraid/core";
5615
+ import { useHydratedMantineColorScheme, useRemoraidTheme as useRemoraidTheme2 } from "remoraid/core";
5619
5616
  import { jsx as jsx3 } from "react/jsx-runtime";
5620
5617
  var createNivoConfiguration = (customTheme, dependencies) => {
5621
5618
  const userExperience = dependencies?.userExperience ?? defaultUserExperience;
@@ -5898,6 +5895,7 @@ function RingSummary({
5898
5895
  // src/data-visualization/components/Chart/index.tsx
5899
5896
  var import_lodash2 = __toESM(require_lodash(), 1);
5900
5897
  import { quantileSorted } from "d3-array";
5898
+ import { useOrdinalColorScale } from "@nivo/colors";
5901
5899
  import { jsx as jsx5, jsxs as jsxs3, Fragment as Fragment2 } from "react/jsx-runtime";
5902
5900
  function Chart({
5903
5901
  type,
@@ -5918,11 +5916,13 @@ function Chart({
5918
5916
  let includeEntityChips = true;
5919
5917
  let includeLegend = false;
5920
5918
  let entities = [];
5919
+ let chartColors = [];
5921
5920
  let chart;
5922
5921
  const controls = [];
5923
5922
  if (type === "timeSeriesStackedAreas" /* TimeSeriesStackedAreas */) {
5924
5923
  includeEntityChips = options.includeEntityChips ?? true;
5925
5924
  includeLegend = options?.includeLegend ?? includeLegend;
5925
+ chartColors = componentsProps?.chart?.colors ?? options?.colors ?? nivoConfiguration.colors;
5926
5926
  data.values.sort((a, b) => a.date.getTime() - b.date.getTime());
5927
5927
  const guideValue = data.values.length > 0 ? data.values[data.values.length - 1 - windowOffset] : null;
5928
5928
  const chartData = [];
@@ -5952,7 +5952,6 @@ function Chart({
5952
5952
  } : undefined;
5953
5953
  const unit = data.units[options.dimension];
5954
5954
  chart = /* @__PURE__ */ jsx5(ResponsiveStream, {
5955
- colors: options.colors ?? nivoConfiguration.colors,
5956
5955
  theme: nivoConfiguration.theme,
5957
5956
  data: chartData,
5958
5957
  keys: entities,
@@ -6011,7 +6010,8 @@ function Chart({
6011
6010
  }),
6012
6011
  curve: "linear",
6013
6012
  offsetType: "diverging",
6014
- ...componentsProps?.chart
6013
+ ...componentsProps?.chart,
6014
+ colors: chartColors
6015
6015
  }, entities.join(","));
6016
6016
  const increaseWindowOffsetButton = /* @__PURE__ */ jsx5(RemoraidButton, {
6017
6017
  mounted: window !== null,
@@ -6132,6 +6132,7 @@ function Chart({
6132
6132
  }
6133
6133
  const includeControls = controls.length > 0;
6134
6134
  const numCols = Number(includeEntityChips) + Number(includeControls);
6135
+ const getEntityColor = useOrdinalColorScale(chartColors, "id");
6135
6136
  return /* @__PURE__ */ jsx5(Transition, {
6136
6137
  mounted,
6137
6138
  children: (transitionStyle) => /* @__PURE__ */ jsxs3(Paper2, {
@@ -6158,13 +6159,13 @@ function Chart({
6158
6159
  onChange: (newValue) => {
6159
6160
  setHiddenEntities(entities.filter((e) => !newValue.includes(e)));
6160
6161
  },
6161
- children: entities.map((entitiy, i) => /* @__PURE__ */ jsx5(Chip, {
6162
- value: entitiy,
6162
+ children: entities.map((entity, i) => /* @__PURE__ */ jsx5(Chip, {
6163
+ value: entity,
6163
6164
  icon: /* @__PURE__ */ jsx5(IconCheck, {
6164
6165
  ...theme.componentsProps.icons.tiny
6165
6166
  }),
6166
- color: chartsUserExperience.colors[i % chartsUserExperience.colors.length],
6167
- children: entitiy
6167
+ color: getEntityColor({ id: entity, path: "" }),
6168
+ children: entity
6168
6169
  }, i))
6169
6170
  })
6170
6171
  }),
@@ -6424,21 +6425,25 @@ import {
6424
6425
  RemoraidButton as RemoraidButton2,
6425
6426
  Widget as Widget3
6426
6427
  } from "remoraid/core";
6428
+ import { useOrdinalColorScale as useOrdinalColorScale2 } from "@nivo/colors";
6427
6429
  import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
6428
6430
  var defaultTimeseriesExplorerWidgetId = "timeseries-explorer";
6429
6431
  function TimeSeriesExplorerWidget({
6430
6432
  data,
6431
6433
  isLoadingData,
6434
+ hideZeroOnlyEntities = true,
6432
6435
  widgetProps,
6433
6436
  componentsProps
6434
6437
  }) {
6435
- const { userExperience: chartsUserExperience } = useChartsUserExperience();
6438
+ const nivoConfiguration = useNivoConfiguration();
6436
6439
  const [selectedDimension, setSelectedDimension] = useState3(null);
6437
6440
  const dimensions = data ? Object.keys(data.units) : [];
6441
+ const chartColors = componentsProps?.primaryChart?.options?.colors ?? nivoConfiguration.colors;
6438
6442
  const entities = data && data.values.length > 0 ? Object.keys(data.values[0].entities) : [];
6439
- const entityColors = entities.reduce((t, entity, i) => ({
6443
+ const getEntityColor = useOrdinalColorScale2(chartColors, "id");
6444
+ const entityColors = entities.reduce((t, entity) => ({
6440
6445
  ...t,
6441
- [entity]: chartsUserExperience.colors[i % chartsUserExperience.colors.length]
6446
+ [entity]: getEntityColor({ id: entity, path: "" })
6442
6447
  }), {});
6443
6448
  const axisLegends = data ? dimensions.reduce((t, d) => {
6444
6449
  const unit = data.units[d];
@@ -6524,15 +6529,17 @@ function TimeSeriesExplorerWidget({
6524
6529
  },
6525
6530
  ...componentsProps?.entitiesGrid,
6526
6531
  children: entities.map((entity) => {
6532
+ const entityChartData = reduceTimeSeriesEntities(data, (t, [e, value]) => e === entity ? { [entity]: value } : t, {
6533
+ [entity]: {
6534
+ [selectedDimension]: 0
6535
+ }
6536
+ });
6537
+ const hasNonZeroValue = entityChartData.values.some((v) => [v.entities[entity][selectedDimension]].flat(2)[0] !== 0);
6527
6538
  const entityChartProps = {
6528
6539
  type: "timeSeriesStackedAreas" /* TimeSeriesStackedAreas */,
6529
6540
  ...componentsProps?.chart,
6530
6541
  ...componentsProps?.entityChart,
6531
- data: reduceTimeSeriesEntities(data, (t, [e, value]) => e === entity ? { [entity]: value } : t, {
6532
- [entity]: {
6533
- [selectedDimension]: 0
6534
- }
6535
- }),
6542
+ data: entityChartData,
6536
6543
  options: {
6537
6544
  dimension: selectedDimension,
6538
6545
  axisBottomLegend: "Time",
@@ -6545,6 +6552,7 @@ function TimeSeriesExplorerWidget({
6545
6552
  };
6546
6553
  return /* @__PURE__ */ jsx10(Chart, {
6547
6554
  h: 275,
6555
+ mounted: !(hideZeroOnlyEntities && !hasNonZeroValue),
6548
6556
  ...entityChartProps,
6549
6557
  additionalControls: [
6550
6558
  /* @__PURE__ */ jsx10(RemoraidButton2, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remoraid",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "author": "Konrad Goldammer",
5
5
  "repository": {
6
6
  "type": "git",