@oliasoft-open-source/charts-library 4.8.0-beta-2 → 4.8.0-beta-3

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/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { produce } from "immer";
9
9
  import { round as round$2, displayNumber, roundByMagnitude } from "@oliasoft-open-source/units";
10
10
  import cx from "classnames";
11
11
  import { Portal, Icon, Menu, Tooltip as Tooltip$2, Button, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Flex, Text } from "@oliasoft-open-source/react-ui-library";
12
- import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1, noop as noop$2 } from "lodash";
12
+ import { cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1, noop as noop$2 } from "lodash";
13
13
  /*!
14
14
  * @kurkle/color v0.3.2
15
15
  * https://github.com/kurkle/color#readme
@@ -25029,11 +25029,7 @@ const getDefaultProps$3 = (props) => {
25029
25029
  }
25030
25030
  };
25031
25031
  };
25032
- const DEFAULT_POINT_RADIUS = 2;
25033
- const DEFAULT_HOVER_RADIUS = 5;
25034
25032
  const DEFAULT_BORDER_WIDTH = 1;
25035
- const BORDER_JOIN_STYLE = "round";
25036
- const DEFAULT_BACKGROUND_COLOR = "transparent";
25037
25033
  const ZOOM_BOX_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.1)";
25038
25034
  const DOUBLE_CLICK = "dblclick";
25039
25035
  const INIT_KEYS = {
@@ -25042,130 +25038,6 @@ const INIT_KEYS = {
25042
25038
  };
25043
25039
  const LOWER_BOUND = 1e-4;
25044
25040
  const UPPER_BOUND = 1e7;
25045
- const checkCustomOption = (data, customOptions) => {
25046
- if (isEmpty(data) || isEmpty(customOptions)) return false;
25047
- const checkOption = (dataset) => {
25048
- if (typeof customOptions === "string") {
25049
- return dataset && has(dataset, customOptions);
25050
- } else if (isArray$2(customOptions)) {
25051
- return dataset && some(customOptions, (option) => dataset && has(dataset, option));
25052
- } else {
25053
- return dataset && some(
25054
- Object.values(customOptions),
25055
- (option) => dataset && has(dataset, option)
25056
- );
25057
- }
25058
- };
25059
- if (isArray$2(data)) {
25060
- return some(data, checkOption);
25061
- } else {
25062
- return checkOption(data);
25063
- }
25064
- };
25065
- var CUSTOM_OPTION = /* @__PURE__ */ ((CUSTOM_OPTION2) => {
25066
- CUSTOM_OPTION2["showLine"] = "showLine";
25067
- CUSTOM_OPTION2["showPoints"] = "showPoints";
25068
- return CUSTOM_OPTION2;
25069
- })(CUSTOM_OPTION || {});
25070
- const generateLineChartDatasets = (datasets, state, options, { label }) => {
25071
- const copyDataset = [...datasets ?? []];
25072
- const { annotations, graph } = options ?? {};
25073
- const {
25074
- controlAnnotation,
25075
- showAnnotations,
25076
- annotationsData = []
25077
- } = annotations ?? {};
25078
- if (controlAnnotation && showAnnotations) {
25079
- const annotationDatasets = annotationsData.map((ann, index2) => {
25080
- const { type, ...annotation2 } = ann;
25081
- const color2 = annotation2.color ?? COLORS[index2];
25082
- const borderDash = ANNOTATION_DASH;
25083
- const borderWidth = BORDER_WIDTH.INITIAL;
25084
- return {
25085
- ...annotation2,
25086
- isAnnotation: true,
25087
- annotationType: type,
25088
- label: annotation2.label,
25089
- annotationIndex: index2,
25090
- backgroundColor: color2,
25091
- pointBackgroundColor: color2,
25092
- borderColor: color2,
25093
- borderDash,
25094
- borderWidth,
25095
- data: [{}]
25096
- };
25097
- });
25098
- copyDataset.push(...annotationDatasets);
25099
- }
25100
- return copyDataset == null ? void 0 : copyDataset.map((line, i2) => {
25101
- var _a2, _b2;
25102
- const {
25103
- formation,
25104
- data = [],
25105
- pointRadius: pointRadiusProp,
25106
- pointHoverRadius,
25107
- borderWidth,
25108
- borderColor,
25109
- backgroundColor,
25110
- pointBackgroundColor,
25111
- borderDash,
25112
- showPoints: customShowPoints,
25113
- showLine: customShowLine
25114
- } = line ?? {};
25115
- const { lineEnabled, pointsEnabled, axes = [] } = state ?? {};
25116
- const { lineTension, spanGaps } = graph ?? {};
25117
- if (formation) {
25118
- const axesMin = (_a2 = axes[0]) == null ? void 0 : _a2.min;
25119
- const axesMax = (_b2 = axes[0]) == null ? void 0 : _b2.max;
25120
- const [startPoint, endPoint] = data;
25121
- if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
25122
- data[0].x = Math.max(axesMin, startPoint.x);
25123
- }
25124
- if (axesMax && (endPoint == null ? void 0 : endPoint.x)) {
25125
- data[2].x = Math.min(axesMax, endPoint.x);
25126
- }
25127
- }
25128
- const hasCustomOpt = checkCustomOption(line, CUSTOM_OPTION);
25129
- const filteredData = data.filter(Boolean) || [];
25130
- const isSinglePoint = (filteredData == null ? void 0 : filteredData.length) === 1;
25131
- let pointState, lineState;
25132
- if (customShowPoints !== void 0) {
25133
- pointState = customShowPoints;
25134
- } else if (customShowLine === false) {
25135
- pointState = true;
25136
- } else {
25137
- pointState = pointsEnabled || isSinglePoint;
25138
- }
25139
- if (customShowLine !== void 0) {
25140
- lineState = customShowLine;
25141
- } else if (customShowPoints === false) {
25142
- lineState = true;
25143
- } else {
25144
- lineState = lineEnabled;
25145
- }
25146
- const linePointRadius = parseFloat(pointRadiusProp) || DEFAULT_POINT_RADIUS;
25147
- const hoverRadius = parseFloat(pointHoverRadius) || DEFAULT_HOVER_RADIUS;
25148
- const indexedColor = COLORS[i2];
25149
- return {
25150
- ...line,
25151
- label: (line == null ? void 0 : line.label) ?? `${label} ${i2 + 1}`,
25152
- data: filteredData,
25153
- showLine: lineState,
25154
- lineTension: (line == null ? void 0 : line.lineTension) ?? lineTension,
25155
- spanGaps,
25156
- borderWidth: parseFloat(borderWidth) || DEFAULT_BORDER_WIDTH,
25157
- borderDash: borderDash || [],
25158
- borderJoinStyle: BORDER_JOIN_STYLE,
25159
- borderColor: borderColor ?? indexedColor ?? generateRandomColor(COLORS),
25160
- backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
25161
- pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
25162
- pointRadius: pointState ? linePointRadius : 0,
25163
- pointHoverRadius: hoverRadius,
25164
- pointHitRadius: (line == null ? void 0 : line.pointHitRadius) ?? hoverRadius,
25165
- ...hasCustomOpt ? { hasCustomOpt } : {}
25166
- };
25167
- });
25168
- };
25169
25041
  const calculateDelta$1 = (tickValue, ticks) => {
25170
25042
  let delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;
25171
25043
  if (Math.abs(delta) >= 1 && tickValue !== Math.floor(Number(tickValue))) {
@@ -27147,7 +27019,7 @@ const LineChart = (props) => {
27147
27019
  const { translations, languageKey } = getConfig();
27148
27020
  const chart2 = getDefaultProps$3(props);
27149
27021
  const {
27150
- data: { datasets } = { datasets: [] },
27022
+ // data: { datasets } = { datasets: [] },
27151
27023
  options,
27152
27024
  testId,
27153
27025
  persistenceId,
@@ -27155,6 +27027,7 @@ const LineChart = (props) => {
27155
27027
  } = chart2;
27156
27028
  const { annotations, axes, chartStyling, graph } = options ?? {};
27157
27029
  const showCustomLegend = !((_b2 = (_a2 = options == null ? void 0 : options.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendContainerID);
27030
+ console.time("useReducer");
27158
27031
  const [state, dispatch] = useReducer(
27159
27032
  reducer$1,
27160
27033
  {
@@ -27163,9 +27036,13 @@ const LineChart = (props) => {
27163
27036
  },
27164
27037
  initialState
27165
27038
  );
27039
+ console.timeEnd("useReducer");
27040
+ console.time("generatedDatasets");
27166
27041
  const generatedDatasets = useMemo(() => {
27167
- return generateLineChartDatasets(datasets, state, options, translations);
27042
+ return [];
27168
27043
  }, [state.lineEnabled, state.pointsEnabled, axes, annotations, graph]);
27044
+ console.timeEnd("generatedDatasets");
27045
+ console.time("useChartState");
27169
27046
  useChartState({
27170
27047
  chartRef,
27171
27048
  options,
@@ -27174,6 +27051,8 @@ const LineChart = (props) => {
27174
27051
  persistenceId,
27175
27052
  generatedDatasets
27176
27053
  });
27054
+ console.timeEnd("useChartState");
27055
+ console.time("useChartFunctions");
27177
27056
  const { resetZoom: resetZoom2, handleKeyDown, handleKeyUp } = useChartFunctions({
27178
27057
  chartRef,
27179
27058
  state,
@@ -27181,6 +27060,8 @@ const LineChart = (props) => {
27181
27060
  dispatch,
27182
27061
  generatedDatasets
27183
27062
  });
27063
+ console.timeEnd("useChartFunctions");
27064
+ console.time("useChartOptions");
27184
27065
  const useOptions = useChartOptions({
27185
27066
  chartRef,
27186
27067
  state,
@@ -27188,7 +27069,10 @@ const LineChart = (props) => {
27188
27069
  dispatch,
27189
27070
  generatedDatasets
27190
27071
  });
27072
+ console.timeEnd("useChartOptions");
27073
+ console.time("useChartPlugins");
27191
27074
  const usePlugins = useChartPlugins({ options, resetZoom: resetZoom2 });
27075
+ console.timeEnd("useChartPlugins");
27192
27076
  return /* @__PURE__ */ jsxs(
27193
27077
  "div",
27194
27078
  {