@sentio/ui-dashboard 0.2.9 → 0.3.1
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.css +102 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +128 -2
- package/dist/index.d.ts +128 -2
- package/dist/index.js +1677 -505
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1691 -497
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -3913,14 +3913,1503 @@ var QueryValueChart = forwardRef4(
|
|
|
3913
3913
|
);
|
|
3914
3914
|
QueryValueChart.displayName = "QueryValueChart";
|
|
3915
3915
|
|
|
3916
|
+
// src/charts/TimeSeriesChart.tsx
|
|
3917
|
+
import {
|
|
3918
|
+
forwardRef as forwardRef5,
|
|
3919
|
+
useCallback as useCallback4,
|
|
3920
|
+
useEffect as useEffect8,
|
|
3921
|
+
useMemo as useMemo9,
|
|
3922
|
+
useRef as useRef4,
|
|
3923
|
+
useState as useState10
|
|
3924
|
+
} from "react";
|
|
3925
|
+
import dayjs5 from "dayjs";
|
|
3926
|
+
|
|
3927
|
+
// src/charts/series-utils.ts
|
|
3928
|
+
import dayjs3 from "dayjs";
|
|
3929
|
+
import duration from "dayjs/plugin/duration";
|
|
3930
|
+
import utc3 from "dayjs/plugin/utc";
|
|
3931
|
+
import timezone3 from "dayjs/plugin/timezone";
|
|
3932
|
+
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
3933
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
3934
|
+
dayjs3.extend(duration);
|
|
3935
|
+
dayjs3.extend(utc3);
|
|
3936
|
+
dayjs3.extend(timezone3);
|
|
3937
|
+
dayjs3.extend(quarterOfYear);
|
|
3938
|
+
dayjs3.extend(localizedFormat);
|
|
3939
|
+
var TimeUnitShortNames = {
|
|
3940
|
+
s: "seconds",
|
|
3941
|
+
m: "minutes",
|
|
3942
|
+
h: "hours",
|
|
3943
|
+
d: "days",
|
|
3944
|
+
w: "weeks",
|
|
3945
|
+
M: "months",
|
|
3946
|
+
y: "years"
|
|
3947
|
+
};
|
|
3948
|
+
function dateRangeOfSeries(series) {
|
|
3949
|
+
let min = /* @__PURE__ */ new Date();
|
|
3950
|
+
let max = /* @__PURE__ */ new Date(0);
|
|
3951
|
+
for (const s of series) {
|
|
3952
|
+
if (s.data.length > 0) {
|
|
3953
|
+
const dmin = s.data[0][0] || min;
|
|
3954
|
+
const dmax = s.data[s.data.length - 1][0] || max;
|
|
3955
|
+
if (dmin < min) min = dmin;
|
|
3956
|
+
if (dmax > max) max = dmax;
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
return [min, max];
|
|
3960
|
+
}
|
|
3961
|
+
function durationToSeconds(d) {
|
|
3962
|
+
if (!d) return 0;
|
|
3963
|
+
return dayjs3.duration(Number(d.value) || 0, d.unit).asSeconds();
|
|
3964
|
+
}
|
|
3965
|
+
function parseDuration(s) {
|
|
3966
|
+
const m = s.match(/(\d+)([a-z]+)/i);
|
|
3967
|
+
if (m) {
|
|
3968
|
+
const [, value, unit] = m;
|
|
3969
|
+
return { value: parseInt(value), unit: TimeUnitShortNames[unit] };
|
|
3970
|
+
}
|
|
3971
|
+
return { value: 0, unit: "second" };
|
|
3972
|
+
}
|
|
3973
|
+
function roundInterval(diff) {
|
|
3974
|
+
switch (true) {
|
|
3975
|
+
case diff <= dayjs3.duration(15, "minute").asMilliseconds():
|
|
3976
|
+
return "10s";
|
|
3977
|
+
case diff <= dayjs3.duration(1, "day").asMilliseconds():
|
|
3978
|
+
return "1m";
|
|
3979
|
+
case diff <= dayjs3.duration(30, "day").asMilliseconds():
|
|
3980
|
+
return "1h";
|
|
3981
|
+
case diff <= dayjs3.duration(2, "years").asMilliseconds():
|
|
3982
|
+
return "1d";
|
|
3983
|
+
case diff <= dayjs3.duration(10, "years").asMilliseconds():
|
|
3984
|
+
default:
|
|
3985
|
+
return "7d";
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
function calculateStepByDate(start, end) {
|
|
3989
|
+
return parseDuration(roundInterval(end.getTime() - start.getTime()));
|
|
3990
|
+
}
|
|
3991
|
+
function shiftTimezone(time, tz) {
|
|
3992
|
+
const origin = dayjs3.isDayjs(time) ? time : dayjs3(time);
|
|
3993
|
+
if (!tz) return origin.toDate();
|
|
3994
|
+
const offset = origin.tz(tz).utcOffset() - origin.utcOffset();
|
|
3995
|
+
return origin.add(offset, "minute").toDate();
|
|
3996
|
+
}
|
|
3997
|
+
var formatTime = (time, tz, interval) => {
|
|
3998
|
+
const d = dayjs3(shiftTimezone(time, tz));
|
|
3999
|
+
switch (interval?.unit) {
|
|
4000
|
+
case "s":
|
|
4001
|
+
return d.format("HH:mm:ss");
|
|
4002
|
+
case "m":
|
|
4003
|
+
return d.format("DD HH:mm");
|
|
4004
|
+
case "h":
|
|
4005
|
+
return d.format("MM-DD HH:mm");
|
|
4006
|
+
case "d":
|
|
4007
|
+
case "w":
|
|
4008
|
+
return d.format("YYYY-MM-DD");
|
|
4009
|
+
case "M":
|
|
4010
|
+
return interval.value === 3 ? `${d.format("YYYY")}-Q${d.quarter()}` : d.format("YYYY-MMM");
|
|
4011
|
+
default:
|
|
4012
|
+
return d.format("lll");
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
|
|
4016
|
+
// src/charts/time-utils.ts
|
|
4017
|
+
import dayjs4 from "dayjs";
|
|
4018
|
+
import {
|
|
4019
|
+
toDayjs,
|
|
4020
|
+
isRelativeTime,
|
|
4021
|
+
now,
|
|
4022
|
+
TimeUnitShortNames as TimeUnitShortNames2
|
|
4023
|
+
} from "@sentio/ui-core";
|
|
4024
|
+
function alignTime(time, step, tz, align = "start") {
|
|
4025
|
+
try {
|
|
4026
|
+
const d = toDayjs(time);
|
|
4027
|
+
const seconds = durationToSeconds(step);
|
|
4028
|
+
const tzOffset = (tz ? d.tz(tz).utcOffset() : 0) * 60;
|
|
4029
|
+
const offset = (d.unix() + tzOffset) % seconds;
|
|
4030
|
+
if (offset === 0) {
|
|
4031
|
+
return time;
|
|
4032
|
+
}
|
|
4033
|
+
return align == "start" ? d.subtract(offset, "second") : d.add(seconds - offset, "second");
|
|
4034
|
+
} catch (e) {
|
|
4035
|
+
console.error(e);
|
|
4036
|
+
return time;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
function timeBefore(time, duration2, asStart = true) {
|
|
4040
|
+
const durationValue = Number(duration2.value);
|
|
4041
|
+
if (isRelativeTime(time)) {
|
|
4042
|
+
const rt = time;
|
|
4043
|
+
if (rt.unit == null || time == now) {
|
|
4044
|
+
return {
|
|
4045
|
+
sign: -1,
|
|
4046
|
+
unit: TimeUnitShortNames2[duration2.unit],
|
|
4047
|
+
value: durationValue
|
|
4048
|
+
};
|
|
4049
|
+
}
|
|
4050
|
+
if (rt.align) {
|
|
4051
|
+
const t2 = toDayjs(rt, asStart);
|
|
4052
|
+
return t2.subtract(durationValue, TimeUnitShortNames2[duration2.unit]);
|
|
4053
|
+
}
|
|
4054
|
+
const t = toDayjs(time);
|
|
4055
|
+
const nt = t.subtract(durationValue, TimeUnitShortNames2[duration2.unit]);
|
|
4056
|
+
const unit = "days";
|
|
4057
|
+
const value = nt.diff(dayjs4(), unit);
|
|
4058
|
+
return { sign: value < 0 ? -1 : 1, unit, value: Math.abs(value) };
|
|
4059
|
+
} else {
|
|
4060
|
+
const t = toDayjs(time);
|
|
4061
|
+
return t.subtract(durationValue, TimeUnitShortNames2[duration2.unit]);
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
// src/charts/TimeSeriesChart.tsx
|
|
4066
|
+
import {
|
|
4067
|
+
toDayjs as toDayjs2,
|
|
4068
|
+
fromNumber,
|
|
4069
|
+
classNames as classNames8,
|
|
4070
|
+
PopupMenuButton
|
|
4071
|
+
} from "@sentio/ui-core";
|
|
4072
|
+
|
|
4073
|
+
// src/charts/options/YaxisControls.tsx
|
|
4074
|
+
import { defaults } from "lodash";
|
|
4075
|
+
import { Button, Checkbox, DisclosurePanel } from "@sentio/ui-core";
|
|
4076
|
+
|
|
4077
|
+
// src/charts/options/controls-ui.tsx
|
|
4078
|
+
import { classNames as classNames7 } from "@sentio/ui-core";
|
|
4079
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
4080
|
+
var AddonLabel = ({
|
|
4081
|
+
className,
|
|
4082
|
+
children
|
|
4083
|
+
}) => /* @__PURE__ */ jsx25(
|
|
4084
|
+
"span",
|
|
4085
|
+
{
|
|
4086
|
+
className: classNames7(
|
|
4087
|
+
"sm:text-icontent border-main inline-flex items-center whitespace-nowrap bg-gray-50",
|
|
4088
|
+
className
|
|
4089
|
+
),
|
|
4090
|
+
children
|
|
4091
|
+
}
|
|
4092
|
+
);
|
|
4093
|
+
|
|
4094
|
+
// src/charts/options/YaxisControls.tsx
|
|
4095
|
+
import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4096
|
+
var initialConfig = {
|
|
4097
|
+
yAxis: {
|
|
4098
|
+
min: "",
|
|
4099
|
+
max: "",
|
|
4100
|
+
scale: true,
|
|
4101
|
+
stack: ""
|
|
4102
|
+
}
|
|
4103
|
+
};
|
|
4104
|
+
function YaxisControls({
|
|
4105
|
+
yAxis,
|
|
4106
|
+
setYAxis,
|
|
4107
|
+
defaultOpen,
|
|
4108
|
+
columnSelect,
|
|
4109
|
+
supportSetName = true,
|
|
4110
|
+
supportSetMinMax = true,
|
|
4111
|
+
supportStackSeries = true,
|
|
4112
|
+
supportAlwaysShowZero = true,
|
|
4113
|
+
supportReset = true,
|
|
4114
|
+
panelTitle = "Y-Axis Controls"
|
|
4115
|
+
}) {
|
|
4116
|
+
yAxis = defaults(yAxis || {}, initialConfig.yAxis);
|
|
4117
|
+
const onChangeInput = (field) => (event) => {
|
|
4118
|
+
const { value } = event.target;
|
|
4119
|
+
setYAxis({
|
|
4120
|
+
...yAxis,
|
|
4121
|
+
[field]: value || void 0,
|
|
4122
|
+
scale: field == "min" && value > "0" ? true : yAxis?.scale
|
|
4123
|
+
});
|
|
4124
|
+
};
|
|
4125
|
+
const onToggleZero = (checked) => {
|
|
4126
|
+
setYAxis({ ...yAxis, scale: !checked, min: checked ? "" : yAxis?.min });
|
|
4127
|
+
};
|
|
4128
|
+
const onClickResetYAxis = () => {
|
|
4129
|
+
setYAxis(initialConfig.yAxis);
|
|
4130
|
+
};
|
|
4131
|
+
const onToggleStack = (checked) => {
|
|
4132
|
+
setYAxis({ ...yAxis, stacked: checked ? "samesign" : "" });
|
|
4133
|
+
};
|
|
4134
|
+
const minMaxLabelCls = "inline-flex items-center border border-r-0 sm:text-icontent border-main bg-gray-50 px-2 rounded-l-md";
|
|
4135
|
+
const minMaxInputCls = "border focus:border-primary-500 rounded-r-md sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30";
|
|
4136
|
+
return /* @__PURE__ */ jsx26(
|
|
4137
|
+
DisclosurePanel,
|
|
4138
|
+
{
|
|
4139
|
+
title: panelTitle,
|
|
4140
|
+
defaultOpen,
|
|
4141
|
+
containerClassName: "w-full bg-default-bg",
|
|
4142
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "text-icontent flex flex-wrap gap-[10px]", children: [
|
|
4143
|
+
supportSetName && /* @__PURE__ */ jsxs16("label", { className: "inline-flex h-8", children: [
|
|
4144
|
+
/* @__PURE__ */ jsx26(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Name" }),
|
|
4145
|
+
/* @__PURE__ */ jsx26(
|
|
4146
|
+
"input",
|
|
4147
|
+
{
|
|
4148
|
+
type: "text",
|
|
4149
|
+
className: "focus:border-primary-500 sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 w-40 rounded-r-md border",
|
|
4150
|
+
value: yAxis?.name,
|
|
4151
|
+
placeholder: "Axis Name",
|
|
4152
|
+
onChange: onChangeInput("name")
|
|
4153
|
+
}
|
|
4154
|
+
)
|
|
4155
|
+
] }),
|
|
4156
|
+
columnSelect && /* @__PURE__ */ jsxs16("span", { className: "inline-flex h-8", children: [
|
|
4157
|
+
/* @__PURE__ */ jsx26(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Column" }),
|
|
4158
|
+
columnSelect
|
|
4159
|
+
] }),
|
|
4160
|
+
supportSetMinMax && /* @__PURE__ */ jsxs16(Fragment8, { children: [
|
|
4161
|
+
/* @__PURE__ */ jsxs16("label", { className: "inline-flex h-8", children: [
|
|
4162
|
+
/* @__PURE__ */ jsx26("span", { className: minMaxLabelCls, children: "Min" }),
|
|
4163
|
+
/* @__PURE__ */ jsx26(
|
|
4164
|
+
"input",
|
|
4165
|
+
{
|
|
4166
|
+
type: "text",
|
|
4167
|
+
className: minMaxInputCls,
|
|
4168
|
+
style: { width: "10em" },
|
|
4169
|
+
value: yAxis.min,
|
|
4170
|
+
placeholder: "Auto",
|
|
4171
|
+
onChange: onChangeInput("min")
|
|
4172
|
+
}
|
|
4173
|
+
)
|
|
4174
|
+
] }),
|
|
4175
|
+
/* @__PURE__ */ jsxs16("label", { className: "inline-flex h-8", children: [
|
|
4176
|
+
/* @__PURE__ */ jsx26("span", { className: minMaxLabelCls, children: "Max" }),
|
|
4177
|
+
/* @__PURE__ */ jsx26(
|
|
4178
|
+
"input",
|
|
4179
|
+
{
|
|
4180
|
+
type: "text",
|
|
4181
|
+
className: minMaxInputCls,
|
|
4182
|
+
style: { width: "10em" },
|
|
4183
|
+
value: yAxis.max,
|
|
4184
|
+
placeholder: "Auto",
|
|
4185
|
+
onChange: onChangeInput("max")
|
|
4186
|
+
}
|
|
4187
|
+
)
|
|
4188
|
+
] })
|
|
4189
|
+
] }),
|
|
4190
|
+
supportStackSeries && /* @__PURE__ */ jsx26(
|
|
4191
|
+
Checkbox,
|
|
4192
|
+
{
|
|
4193
|
+
checked: !!yAxis?.stacked,
|
|
4194
|
+
onChange: onToggleStack,
|
|
4195
|
+
label: "Stack series"
|
|
4196
|
+
}
|
|
4197
|
+
),
|
|
4198
|
+
supportAlwaysShowZero && /* @__PURE__ */ jsx26(
|
|
4199
|
+
Checkbox,
|
|
4200
|
+
{
|
|
4201
|
+
checked: !yAxis.scale,
|
|
4202
|
+
onChange: onToggleZero,
|
|
4203
|
+
label: "Always show zero"
|
|
4204
|
+
}
|
|
4205
|
+
),
|
|
4206
|
+
supportReset && /* @__PURE__ */ jsx26(Button, { type: "button", role: "link", onClick: onClickResetYAxis, children: "Reset" })
|
|
4207
|
+
] })
|
|
4208
|
+
}
|
|
4209
|
+
);
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
// src/charts/options/XaxisControls.tsx
|
|
4213
|
+
import {
|
|
4214
|
+
Button as Button2,
|
|
4215
|
+
DisclosurePanel as DisclosurePanel2,
|
|
4216
|
+
PopoverTooltip,
|
|
4217
|
+
Select
|
|
4218
|
+
} from "@sentio/ui-core";
|
|
4219
|
+
import { LuInfo } from "react-icons/lu";
|
|
4220
|
+
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4221
|
+
var TypeSelect = Select;
|
|
4222
|
+
var SortSelect = Select;
|
|
4223
|
+
var OrderSelect = Select;
|
|
4224
|
+
var sortByItems = [
|
|
4225
|
+
{ label: "Name", value: "ByName" },
|
|
4226
|
+
{ label: "Value", value: "ByValue" }
|
|
4227
|
+
];
|
|
4228
|
+
var orderItems = [
|
|
4229
|
+
{ label: "Ascendant", value: false },
|
|
4230
|
+
{ label: "Descendant", value: true }
|
|
4231
|
+
];
|
|
4232
|
+
var XAxisControls = ({
|
|
4233
|
+
xAxis,
|
|
4234
|
+
setXAxis,
|
|
4235
|
+
defaultOpen,
|
|
4236
|
+
columnSelect,
|
|
4237
|
+
columnIsNonTime,
|
|
4238
|
+
panelTitle = "X-Axis Controls",
|
|
4239
|
+
supportName = true,
|
|
4240
|
+
supportSort,
|
|
4241
|
+
supportSetType
|
|
4242
|
+
}) => {
|
|
4243
|
+
const onChangeInput = (field) => (event) => {
|
|
4244
|
+
const { value } = event.target;
|
|
4245
|
+
setXAxis({ ...xAxis, [field]: value || void 0 });
|
|
4246
|
+
};
|
|
4247
|
+
const onClickResetXAxis = () => {
|
|
4248
|
+
setXAxis(void 0);
|
|
4249
|
+
};
|
|
4250
|
+
const isXAixsNoneTime = xAxis && xAxis.column && columnIsNonTime;
|
|
4251
|
+
return /* @__PURE__ */ jsx27(
|
|
4252
|
+
DisclosurePanel2,
|
|
4253
|
+
{
|
|
4254
|
+
title: panelTitle,
|
|
4255
|
+
defaultOpen,
|
|
4256
|
+
containerClassName: "w-full bg-default-bg",
|
|
4257
|
+
children: /* @__PURE__ */ jsxs17("div", { className: "text-icontent flex flex-wrap gap-[10px]", children: [
|
|
4258
|
+
supportName && /* @__PURE__ */ jsxs17("label", { className: "inline-flex h-8", children: [
|
|
4259
|
+
/* @__PURE__ */ jsx27(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Name" }),
|
|
4260
|
+
/* @__PURE__ */ jsx27(
|
|
4261
|
+
"input",
|
|
4262
|
+
{
|
|
4263
|
+
type: "text",
|
|
4264
|
+
className: "sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 w-40 rounded-r-md",
|
|
4265
|
+
value: xAxis?.name,
|
|
4266
|
+
placeholder: "Axis Name",
|
|
4267
|
+
onChange: onChangeInput("name")
|
|
4268
|
+
}
|
|
4269
|
+
)
|
|
4270
|
+
] }),
|
|
4271
|
+
supportSetType && /* @__PURE__ */ jsxs17("span", { className: "inline-flex h-8", children: [
|
|
4272
|
+
/* @__PURE__ */ jsxs17("span", { className: "sm:text-icontent border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-2", children: [
|
|
4273
|
+
"X-Axis Type",
|
|
4274
|
+
" ",
|
|
4275
|
+
/* @__PURE__ */ jsx27(
|
|
4276
|
+
PopoverTooltip,
|
|
4277
|
+
{
|
|
4278
|
+
strategy: "fixed",
|
|
4279
|
+
hideArrow: true,
|
|
4280
|
+
placementOption: "bottom",
|
|
4281
|
+
text: /* @__PURE__ */ jsxs17("div", { className: "text-text-foreground max-w-[300px] p-2", children: [
|
|
4282
|
+
/* @__PURE__ */ jsx27("span", { className: "font-medium", children: "Discrete axis" }),
|
|
4283
|
+
" displays",
|
|
4284
|
+
" ",
|
|
4285
|
+
/* @__PURE__ */ jsx27("span", { className: "text-primary-600", children: "discrete values evenly" }),
|
|
4286
|
+
", while ",
|
|
4287
|
+
/* @__PURE__ */ jsx27("span", { className: "font-medium", children: "Continuous axis" }),
|
|
4288
|
+
" ",
|
|
4289
|
+
"shows",
|
|
4290
|
+
" ",
|
|
4291
|
+
/* @__PURE__ */ jsx27("span", { className: "text-primary-600", children: "continuous time series" }),
|
|
4292
|
+
" ",
|
|
4293
|
+
"and",
|
|
4294
|
+
" ",
|
|
4295
|
+
/* @__PURE__ */ jsx27("span", { className: "text-primary-600", children: "auto-fills missing time points" })
|
|
4296
|
+
] }),
|
|
4297
|
+
children: /* @__PURE__ */ jsx27(LuInfo, { className: "text-text-foreground-secondary h-4 w-4" })
|
|
4298
|
+
}
|
|
4299
|
+
)
|
|
4300
|
+
] }),
|
|
4301
|
+
/* @__PURE__ */ jsx27(
|
|
4302
|
+
TypeSelect,
|
|
4303
|
+
{
|
|
4304
|
+
className: "h-8 w-40",
|
|
4305
|
+
buttonClassName: "h-full border-main rounded-l-none items-center inline-flex items-center",
|
|
4306
|
+
value: xAxis?.type || "time",
|
|
4307
|
+
onChange: (val) => {
|
|
4308
|
+
setXAxis({ ...xAxis, type: val });
|
|
4309
|
+
},
|
|
4310
|
+
options: [
|
|
4311
|
+
{ label: "Continuous", value: "time" },
|
|
4312
|
+
{ label: "Discrete", value: "category" }
|
|
4313
|
+
]
|
|
4314
|
+
}
|
|
4315
|
+
)
|
|
4316
|
+
] }),
|
|
4317
|
+
columnSelect && /* @__PURE__ */ jsxs17("span", { className: "inline-flex h-8", children: [
|
|
4318
|
+
/* @__PURE__ */ jsx27(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Column" }),
|
|
4319
|
+
columnSelect
|
|
4320
|
+
] }),
|
|
4321
|
+
supportSort && isXAixsNoneTime && /* @__PURE__ */ jsxs17("span", { className: "inline-flex h-8", children: [
|
|
4322
|
+
/* @__PURE__ */ jsx27(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Sort By" }),
|
|
4323
|
+
/* @__PURE__ */ jsx27(
|
|
4324
|
+
SortSelect,
|
|
4325
|
+
{
|
|
4326
|
+
className: "h-8 w-20 leading-8",
|
|
4327
|
+
buttonClassName: "h-full border-main rounded-none inline-flex items-center",
|
|
4328
|
+
options: sortByItems,
|
|
4329
|
+
value: xAxis?.sort?.sortBy,
|
|
4330
|
+
onChange: (value) => {
|
|
4331
|
+
setXAxis({
|
|
4332
|
+
...xAxis,
|
|
4333
|
+
sort: { ...xAxis?.sort, sortBy: value }
|
|
4334
|
+
});
|
|
4335
|
+
},
|
|
4336
|
+
placeholder: "Sort By"
|
|
4337
|
+
}
|
|
4338
|
+
),
|
|
4339
|
+
/* @__PURE__ */ jsx27(
|
|
4340
|
+
OrderSelect,
|
|
4341
|
+
{
|
|
4342
|
+
className: "h-8 w-40 leading-8",
|
|
4343
|
+
buttonClassName: "h-full border-l-0 border-main rounded-l-none inline-flex items-center",
|
|
4344
|
+
options: orderItems,
|
|
4345
|
+
value: xAxis?.sort?.orderDesc,
|
|
4346
|
+
onChange: (value) => {
|
|
4347
|
+
setXAxis({
|
|
4348
|
+
...xAxis,
|
|
4349
|
+
sort: { ...xAxis?.sort, orderDesc: value }
|
|
4350
|
+
});
|
|
4351
|
+
},
|
|
4352
|
+
placeholder: "Sort Order"
|
|
4353
|
+
}
|
|
4354
|
+
)
|
|
4355
|
+
] }),
|
|
4356
|
+
/* @__PURE__ */ jsx27(
|
|
4357
|
+
Button2,
|
|
4358
|
+
{
|
|
4359
|
+
type: "button",
|
|
4360
|
+
role: "link",
|
|
4361
|
+
onClick: onClickResetXAxis,
|
|
4362
|
+
className: "h-8",
|
|
4363
|
+
children: "Reset"
|
|
4364
|
+
}
|
|
4365
|
+
)
|
|
4366
|
+
] })
|
|
4367
|
+
}
|
|
4368
|
+
);
|
|
4369
|
+
};
|
|
4370
|
+
|
|
4371
|
+
// src/charts/TimeSeriesChart.tsx
|
|
4372
|
+
import ReactDOMServer from "react-dom/server";
|
|
4373
|
+
import { isArray, isEqual as isEqual3, isNumber as isNumber3, uniq } from "lodash";
|
|
4374
|
+
import {
|
|
4375
|
+
flip,
|
|
4376
|
+
FloatingOverlay,
|
|
4377
|
+
FloatingPortal as FloatingPortal2,
|
|
4378
|
+
shift as shift2,
|
|
4379
|
+
useFloating as useFloating3
|
|
4380
|
+
} from "@floating-ui/react";
|
|
4381
|
+
import { useBoolean } from "@sentio/ui-core";
|
|
4382
|
+
import { LuChevronDown as LuChevronDown2 } from "react-icons/lu";
|
|
4383
|
+
import { jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4384
|
+
var NumberFormat = (o) => new Intl.NumberFormat("en-US", o);
|
|
4385
|
+
function roundByDPR(value) {
|
|
4386
|
+
const dpr = window.devicePixelRatio || 1;
|
|
4387
|
+
return Math.round(value * dpr) / dpr;
|
|
4388
|
+
}
|
|
4389
|
+
function onClickPreventDefault(e) {
|
|
4390
|
+
e.preventDefault();
|
|
4391
|
+
e.stopPropagation();
|
|
4392
|
+
}
|
|
4393
|
+
var closestNumber = (arr, needle) => {
|
|
4394
|
+
return arr?.reduce(
|
|
4395
|
+
(a, b) => Math.abs(b - needle) < Math.abs(a - needle) ? b : a
|
|
4396
|
+
);
|
|
4397
|
+
};
|
|
4398
|
+
var initialConfig2 = {
|
|
4399
|
+
xAxis: {
|
|
4400
|
+
type: "category",
|
|
4401
|
+
min: "",
|
|
4402
|
+
max: "",
|
|
4403
|
+
scale: true,
|
|
4404
|
+
name: "",
|
|
4405
|
+
column: ""
|
|
4406
|
+
},
|
|
4407
|
+
yAxis: {
|
|
4408
|
+
min: "",
|
|
4409
|
+
max: "",
|
|
4410
|
+
scale: true
|
|
4411
|
+
}
|
|
4412
|
+
};
|
|
4413
|
+
var createYAxisResult = (min, max, scale, name) => {
|
|
4414
|
+
const result = { min, max, scale };
|
|
4415
|
+
if (name) {
|
|
4416
|
+
result.name = name;
|
|
4417
|
+
}
|
|
4418
|
+
return result;
|
|
4419
|
+
};
|
|
4420
|
+
var calculateMargin = (value, isMin) => {
|
|
4421
|
+
if (isMin) {
|
|
4422
|
+
return value >= 0 ? Math.max(0, value * 0.9) : value * 1.1;
|
|
4423
|
+
} else {
|
|
4424
|
+
return value >= 0 ? value * 1.1 : value * 0.9;
|
|
4425
|
+
}
|
|
4426
|
+
};
|
|
4427
|
+
var yAxisToChartOption = (option, markLines = [], values) => {
|
|
4428
|
+
const { min, max, scale, name } = option || {};
|
|
4429
|
+
const hasValidMin = min !== void 0 && min !== "";
|
|
4430
|
+
const hasValidMax = max !== void 0 && max !== "";
|
|
4431
|
+
const optionMin = hasValidMin ? parseFloat(min) || min : void 0;
|
|
4432
|
+
const optionMax = hasValidMax ? parseFloat(max) || max : void 0;
|
|
4433
|
+
if (hasValidMin && hasValidMax) {
|
|
4434
|
+
return createYAxisResult(optionMin, optionMax, scale, name);
|
|
4435
|
+
}
|
|
4436
|
+
const lineValues = markLines.map((m) => m.value).filter(
|
|
4437
|
+
(v) => v !== void 0 && v !== 0 && v !== "0"
|
|
4438
|
+
);
|
|
4439
|
+
if (lineValues.length === 0 && !hasValidMin && !hasValidMax) {
|
|
4440
|
+
return createYAxisResult(void 0, void 0, scale, name);
|
|
4441
|
+
}
|
|
4442
|
+
const allValues = [...lineValues];
|
|
4443
|
+
if (values) {
|
|
4444
|
+
const valueSet = /* @__PURE__ */ new Set();
|
|
4445
|
+
values.forEach((series) => {
|
|
4446
|
+
series.data.forEach((point) => {
|
|
4447
|
+
const value = point[1];
|
|
4448
|
+
if (isNumber3(value)) {
|
|
4449
|
+
valueSet.add(value);
|
|
4450
|
+
}
|
|
4451
|
+
});
|
|
4452
|
+
});
|
|
4453
|
+
valueSet.forEach((value) => {
|
|
4454
|
+
allValues.push(value);
|
|
4455
|
+
});
|
|
4456
|
+
}
|
|
4457
|
+
let finalMin = optionMin;
|
|
4458
|
+
let finalMax = optionMax;
|
|
4459
|
+
if (allValues.length > 0) {
|
|
4460
|
+
if (!hasValidMin) {
|
|
4461
|
+
const minValue = allValues.reduce(
|
|
4462
|
+
(min2, current) => Math.min(min2, current),
|
|
4463
|
+
Infinity
|
|
4464
|
+
);
|
|
4465
|
+
finalMin = calculateMargin(minValue, true);
|
|
4466
|
+
}
|
|
4467
|
+
if (!hasValidMax) {
|
|
4468
|
+
const maxValue = allValues.reduce(
|
|
4469
|
+
(max2, current) => Math.max(max2, current),
|
|
4470
|
+
-Infinity
|
|
4471
|
+
);
|
|
4472
|
+
finalMax = calculateMargin(maxValue, false);
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
return createYAxisResult(finalMin, finalMax, scale, name);
|
|
4476
|
+
};
|
|
4477
|
+
var getEventName = (name) => {
|
|
4478
|
+
let eventName = name.split("-")[0].trim();
|
|
4479
|
+
if (eventName.toLowerCase() === "all events") {
|
|
4480
|
+
eventName = void 0;
|
|
4481
|
+
}
|
|
4482
|
+
return eventName;
|
|
4483
|
+
};
|
|
4484
|
+
var DARK_AREA_FILL_OPACITY = 0.35;
|
|
4485
|
+
var applyDarkAreaOpacity = (series) => {
|
|
4486
|
+
if (series.length <= 1) {
|
|
4487
|
+
return series;
|
|
4488
|
+
}
|
|
4489
|
+
return series.map((s) => {
|
|
4490
|
+
if (!s?.areaStyle) {
|
|
4491
|
+
return s;
|
|
4492
|
+
}
|
|
4493
|
+
const existing = typeof s.areaStyle.opacity === "number" ? s.areaStyle.opacity : 0.7;
|
|
4494
|
+
return {
|
|
4495
|
+
...s,
|
|
4496
|
+
areaStyle: {
|
|
4497
|
+
...s.areaStyle,
|
|
4498
|
+
opacity: Math.min(existing, DARK_AREA_FILL_OPACITY)
|
|
4499
|
+
}
|
|
4500
|
+
};
|
|
4501
|
+
});
|
|
4502
|
+
};
|
|
4503
|
+
var fixTimeSeries = (series) => {
|
|
4504
|
+
try {
|
|
4505
|
+
if (!series?.length) {
|
|
4506
|
+
return;
|
|
4507
|
+
}
|
|
4508
|
+
const isValidDateSeries = series.every(
|
|
4509
|
+
(s) => s.data?.every((point) => {
|
|
4510
|
+
const date = point?.[0];
|
|
4511
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
4512
|
+
})
|
|
4513
|
+
);
|
|
4514
|
+
if (!isValidDateSeries || series.length < 2 || uniq(series.map((s) => s.data?.length)).length === 1) {
|
|
4515
|
+
return;
|
|
4516
|
+
}
|
|
4517
|
+
const timeIndex = [];
|
|
4518
|
+
const dataIndexes = new Array(series.length).fill(0);
|
|
4519
|
+
while (dataIndexes.some((d, index) => d < (series[index]?.data?.length || 0))) {
|
|
4520
|
+
const times = dataIndexes.map((d, index) => {
|
|
4521
|
+
const date = series[index]?.data?.[d]?.[0];
|
|
4522
|
+
return date instanceof Date && !isNaN(date.getTime()) ? date.getTime() : Infinity;
|
|
4523
|
+
});
|
|
4524
|
+
const minTime = Math.min(...times);
|
|
4525
|
+
if (!isFinite(minTime)) {
|
|
4526
|
+
break;
|
|
4527
|
+
}
|
|
4528
|
+
const newDate = new Date(minTime);
|
|
4529
|
+
if (isNaN(newDate.getTime())) {
|
|
4530
|
+
break;
|
|
4531
|
+
}
|
|
4532
|
+
timeIndex.push(newDate);
|
|
4533
|
+
dataIndexes.forEach((d, index) => {
|
|
4534
|
+
const date = series[index]?.data?.[d]?.[0];
|
|
4535
|
+
if (date instanceof Date && !isNaN(date.getTime()) && date.getTime() === minTime) {
|
|
4536
|
+
dataIndexes[index]++;
|
|
4537
|
+
}
|
|
4538
|
+
});
|
|
4539
|
+
}
|
|
4540
|
+
series.forEach((s) => {
|
|
4541
|
+
if (!s?.data) return;
|
|
4542
|
+
const data = s.data;
|
|
4543
|
+
const fixedData = [];
|
|
4544
|
+
let index = 0;
|
|
4545
|
+
timeIndex.forEach((t) => {
|
|
4546
|
+
if (data[index]?.[0] instanceof Date && !isNaN(data[index][0].getTime()) && isEqual3(data[index][0], t)) {
|
|
4547
|
+
fixedData.push(data[index]);
|
|
4548
|
+
index++;
|
|
4549
|
+
} else {
|
|
4550
|
+
fixedData.push([t, null]);
|
|
4551
|
+
}
|
|
4552
|
+
});
|
|
4553
|
+
s.data = fixedData;
|
|
4554
|
+
});
|
|
4555
|
+
} catch (error) {
|
|
4556
|
+
console.warn("Error in fixTimeSeries:", error);
|
|
4557
|
+
}
|
|
4558
|
+
};
|
|
4559
|
+
var TimeSeriesChart = forwardRef5(
|
|
4560
|
+
(props, ref) => {
|
|
4561
|
+
const yAxisRef = useRef4(null);
|
|
4562
|
+
const {
|
|
4563
|
+
group,
|
|
4564
|
+
title,
|
|
4565
|
+
startTime,
|
|
4566
|
+
endTime,
|
|
4567
|
+
tz,
|
|
4568
|
+
minHeight,
|
|
4569
|
+
onSelectTimeRange,
|
|
4570
|
+
loading,
|
|
4571
|
+
controls,
|
|
4572
|
+
config,
|
|
4573
|
+
markAreas,
|
|
4574
|
+
markLines,
|
|
4575
|
+
onChangeConfig,
|
|
4576
|
+
style,
|
|
4577
|
+
chartType,
|
|
4578
|
+
allowClick,
|
|
4579
|
+
sourceType,
|
|
4580
|
+
getEventNameById,
|
|
4581
|
+
noLegend: _noLegend = false,
|
|
4582
|
+
onInitChart,
|
|
4583
|
+
nonXAxis,
|
|
4584
|
+
// injected
|
|
4585
|
+
series: seriesProp,
|
|
4586
|
+
compareSeries: compareSeriesProp,
|
|
4587
|
+
legend: legendProp,
|
|
4588
|
+
numberFormatter,
|
|
4589
|
+
overlay,
|
|
4590
|
+
templateVariableKeys: _templateVariableKeys,
|
|
4591
|
+
seriesToMetricLabels,
|
|
4592
|
+
eventNameMap,
|
|
4593
|
+
eventsQueryMap,
|
|
4594
|
+
onViewLogs,
|
|
4595
|
+
onViewUsers,
|
|
4596
|
+
viewLogDisabled: viewLogDisabledProp,
|
|
4597
|
+
viewUsersDisabled: viewUsersDisabledProp,
|
|
4598
|
+
returnedSeries,
|
|
4599
|
+
totalSeries
|
|
4600
|
+
} = props;
|
|
4601
|
+
void _templateVariableKeys;
|
|
4602
|
+
const seriesToMetricLabelsRef = useMemo9(
|
|
4603
|
+
() => seriesToMetricLabels ?? [],
|
|
4604
|
+
[seriesToMetricLabels]
|
|
4605
|
+
);
|
|
4606
|
+
const eventNameMapRef = useMemo9(
|
|
4607
|
+
() => eventNameMap ?? /* @__PURE__ */ new Map(),
|
|
4608
|
+
[eventNameMap]
|
|
4609
|
+
);
|
|
4610
|
+
const eventsQueryMapRef = useMemo9(
|
|
4611
|
+
() => eventsQueryMap ?? /* @__PURE__ */ new Map(),
|
|
4612
|
+
[eventsQueryMap]
|
|
4613
|
+
);
|
|
4614
|
+
const [yAxis, setYAxis] = useState10(config?.yAxis || initialConfig2.yAxis);
|
|
4615
|
+
const [xAxis, setXAxis] = useState10(config?.xAxis || initialConfig2.xAxis);
|
|
4616
|
+
const [maximumSignificantDigits, setMaximumSignificantDigits] = useState10(3);
|
|
4617
|
+
const isDarkMode = useDarkMode();
|
|
4618
|
+
const minRef = useRef4(0);
|
|
4619
|
+
const maxRef = useRef4(0);
|
|
4620
|
+
const getSymbolSize = useCallback4(
|
|
4621
|
+
(value) => {
|
|
4622
|
+
const val = value[2] || 0;
|
|
4623
|
+
return normalize(
|
|
4624
|
+
val,
|
|
4625
|
+
minRef.current,
|
|
4626
|
+
maxRef.current,
|
|
4627
|
+
config?.scatterConfig?.minSize,
|
|
4628
|
+
config?.scatterConfig?.maxSize
|
|
4629
|
+
);
|
|
4630
|
+
},
|
|
4631
|
+
[config?.scatterConfig?.minSize, config?.scatterConfig?.maxSize]
|
|
4632
|
+
);
|
|
4633
|
+
useEffect8(() => {
|
|
4634
|
+
setYAxis(config?.yAxis || initialConfig2.yAxis);
|
|
4635
|
+
}, [config]);
|
|
4636
|
+
const legend = useMemo9(() => legendProp || [], [legendProp]);
|
|
4637
|
+
const series = useMemo9(() => {
|
|
4638
|
+
const result = (seriesProp || []).map((s) => ({ ...s }));
|
|
4639
|
+
computeMarkLines(result, markLines || []);
|
|
4640
|
+
computeMarksAreas(result, markAreas || []);
|
|
4641
|
+
if (config?.yAxis?.stacked) {
|
|
4642
|
+
fixTimeSeries(result);
|
|
4643
|
+
result.forEach((s) => {
|
|
4644
|
+
if (config?.seriesConfig && config.seriesConfig.series?.[s.name]) {
|
|
4645
|
+
return;
|
|
4646
|
+
}
|
|
4647
|
+
s.stack = "Total";
|
|
4648
|
+
s.stackStrategy = config?.yAxis?.stacked;
|
|
4649
|
+
});
|
|
4650
|
+
}
|
|
4651
|
+
if (config?.lineConfig) {
|
|
4652
|
+
result.forEach((s) => {
|
|
4653
|
+
s.lineStyle = {
|
|
4654
|
+
...s.lineStyle,
|
|
4655
|
+
type: config?.lineConfig?.style?.toLowerCase() || "solid"
|
|
4656
|
+
};
|
|
4657
|
+
if (config?.lineConfig?.smooth) {
|
|
4658
|
+
s.smooth = true;
|
|
4659
|
+
}
|
|
4660
|
+
});
|
|
4661
|
+
}
|
|
4662
|
+
if (chartType === "SCATTER") {
|
|
4663
|
+
result.forEach((s) => {
|
|
4664
|
+
const min = s.data?.reduce((min2, p) => {
|
|
4665
|
+
const val = p[2] || 0;
|
|
4666
|
+
return Math.min(min2, val);
|
|
4667
|
+
}, Infinity);
|
|
4668
|
+
const max = s.data?.reduce((max2, p) => {
|
|
4669
|
+
const val = p[2] || 0;
|
|
4670
|
+
return Math.max(max2, val);
|
|
4671
|
+
}, -Infinity);
|
|
4672
|
+
minRef.current = min;
|
|
4673
|
+
maxRef.current = max;
|
|
4674
|
+
s.symbolSize = getSymbolSize;
|
|
4675
|
+
});
|
|
4676
|
+
}
|
|
4677
|
+
if (allowClick) {
|
|
4678
|
+
result.forEach((serie) => {
|
|
4679
|
+
serie.emphasis = serie.type === "bar" ? {
|
|
4680
|
+
itemStyle: {
|
|
4681
|
+
shadowColor: "rgba(0, 0, 0, 0.3)",
|
|
4682
|
+
shadowBlur: 10
|
|
4683
|
+
}
|
|
4684
|
+
} : {
|
|
4685
|
+
scale: 1.5
|
|
4686
|
+
};
|
|
4687
|
+
});
|
|
4688
|
+
}
|
|
4689
|
+
return result;
|
|
4690
|
+
}, [
|
|
4691
|
+
seriesProp,
|
|
4692
|
+
markAreas,
|
|
4693
|
+
markLines,
|
|
4694
|
+
chartType,
|
|
4695
|
+
config?.yAxis,
|
|
4696
|
+
config?.lineConfig,
|
|
4697
|
+
config?.seriesConfig,
|
|
4698
|
+
allowClick,
|
|
4699
|
+
getSymbolSize
|
|
4700
|
+
]);
|
|
4701
|
+
useEffect8(() => {
|
|
4702
|
+
setMaximumSignificantDigits(3);
|
|
4703
|
+
}, [seriesProp]);
|
|
4704
|
+
const compareSeries = useMemo9(() => {
|
|
4705
|
+
if (!compareSeriesProp?.length) {
|
|
4706
|
+
return [];
|
|
4707
|
+
}
|
|
4708
|
+
const result = compareSeriesProp.map((s) => ({ ...s }));
|
|
4709
|
+
for (const s of result) {
|
|
4710
|
+
s.lineStyle = {
|
|
4711
|
+
...s.lineStyle,
|
|
4712
|
+
type: "dashed"
|
|
4713
|
+
};
|
|
4714
|
+
s.itemStyle = {
|
|
4715
|
+
...s.itemStyle,
|
|
4716
|
+
color: "rgba(120, 120, 120, 0.3)"
|
|
4717
|
+
};
|
|
4718
|
+
s.xAxisIndex = 1;
|
|
4719
|
+
if (chartType === "SCATTER") {
|
|
4720
|
+
s.symbolSize = getSymbolSize;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
return result;
|
|
4724
|
+
}, [compareSeriesProp, chartType, getSymbolSize]);
|
|
4725
|
+
const NF = NumberFormat({ notation: "compact", maximumSignificantDigits });
|
|
4726
|
+
const NF_LARGE = NumberFormat({ notation: "scientific" });
|
|
4727
|
+
const seriesIdToYAxisName = overlay?.seriesIdToYAxisName ?? /* @__PURE__ */ new Map();
|
|
4728
|
+
const overlaySeriesIdToFormatter = overlay?.overlaySeriesIdToFormatter ?? /* @__PURE__ */ new Map();
|
|
4729
|
+
const applyOverlaySeries = overlay?.applyOverlaySeries ?? ((options2) => options2);
|
|
4730
|
+
const setYAxisWrap = (yAxis2) => {
|
|
4731
|
+
setYAxis(yAxis2);
|
|
4732
|
+
onChangeConfig?.({ ...config, yAxis: yAxis2 });
|
|
4733
|
+
};
|
|
4734
|
+
let yAxisLabel;
|
|
4735
|
+
const [start, end] = useMemo9(() => {
|
|
4736
|
+
const [dataStart, dataEnd] = dateRangeOfSeries(series);
|
|
4737
|
+
const selectStart = startTime && toDayjs2(startTime, true).toDate();
|
|
4738
|
+
const selectEnd = endTime && toDayjs2(endTime, false).toDate();
|
|
4739
|
+
const selStart = selectStart ? shiftTimezone(selectStart, tz) : void 0;
|
|
4740
|
+
const selEnd = selectEnd ? shiftTimezone(selectEnd, tz) : void 0;
|
|
4741
|
+
const start2 = dataStart && selStart ? dataStart.getTime() < selStart.getTime() ? dataStart : selStart : selStart;
|
|
4742
|
+
const end2 = dataEnd && selEnd ? dataEnd.getTime() > selEnd.getTime() ? dataEnd : selEnd : selEnd;
|
|
4743
|
+
return [start2, end2];
|
|
4744
|
+
}, [series, startTime, endTime]);
|
|
4745
|
+
const xLabelFormatter = useMemo9(() => {
|
|
4746
|
+
return config?.xAxis?.type === "category" ? (value) => {
|
|
4747
|
+
const date = shiftTimezone(value, tz);
|
|
4748
|
+
let interval = config?.timeRangeOverride?.timeRange?.interval;
|
|
4749
|
+
if (!interval && start && end) {
|
|
4750
|
+
interval = calculateStepByDate(start, end);
|
|
4751
|
+
}
|
|
4752
|
+
return formatTime(date, tz, interval);
|
|
4753
|
+
} : void 0;
|
|
4754
|
+
}, [
|
|
4755
|
+
config?.xAxis?.type,
|
|
4756
|
+
config?.timeRangeOverride?.timeRange,
|
|
4757
|
+
tz,
|
|
4758
|
+
start,
|
|
4759
|
+
end
|
|
4760
|
+
]);
|
|
4761
|
+
const tooltipParmsRef = useRef4({});
|
|
4762
|
+
const getSeriesContext = useCallback4(
|
|
4763
|
+
(seriesId, seriesIndex) => {
|
|
4764
|
+
const params = tooltipParmsRef.current?.data;
|
|
4765
|
+
if (!params || !seriesToMetricLabelsRef) {
|
|
4766
|
+
return null;
|
|
4767
|
+
}
|
|
4768
|
+
let value;
|
|
4769
|
+
let idx;
|
|
4770
|
+
if (Array.isArray(params)) {
|
|
4771
|
+
const param = params.find(
|
|
4772
|
+
(p) => p.seriesId === seriesId || p.seriesIndex === seriesIndex
|
|
4773
|
+
);
|
|
4774
|
+
if (!param) return null;
|
|
4775
|
+
value = param.value;
|
|
4776
|
+
idx = param.seriesIndex;
|
|
4777
|
+
} else {
|
|
4778
|
+
value = params.value;
|
|
4779
|
+
idx = seriesIndex;
|
|
4780
|
+
}
|
|
4781
|
+
if (!value) return null;
|
|
4782
|
+
const {
|
|
4783
|
+
labels = {},
|
|
4784
|
+
name = "",
|
|
4785
|
+
id
|
|
4786
|
+
} = seriesToMetricLabelsRef[idx] || {};
|
|
4787
|
+
const isEventSeries = eventNameMapRef.has(id) || sourceType === "ANALYTICS";
|
|
4788
|
+
let eventName;
|
|
4789
|
+
if (sourceType === "ANALYTICS") {
|
|
4790
|
+
try {
|
|
4791
|
+
const _eventName = getEventNameById?.(id);
|
|
4792
|
+
eventName = _eventName == void 0 ? getEventName(name) : _eventName;
|
|
4793
|
+
} catch {
|
|
4794
|
+
}
|
|
4795
|
+
} else if (eventNameMapRef.has(id)) {
|
|
4796
|
+
eventName = eventNameMapRef.get(id) || void 0;
|
|
4797
|
+
}
|
|
4798
|
+
const query = eventsQueryMapRef.get(id);
|
|
4799
|
+
return {
|
|
4800
|
+
value,
|
|
4801
|
+
labels,
|
|
4802
|
+
name,
|
|
4803
|
+
id,
|
|
4804
|
+
isEventSeries,
|
|
4805
|
+
eventName,
|
|
4806
|
+
query
|
|
4807
|
+
};
|
|
4808
|
+
},
|
|
4809
|
+
[
|
|
4810
|
+
seriesToMetricLabelsRef,
|
|
4811
|
+
eventNameMapRef,
|
|
4812
|
+
eventsQueryMapRef,
|
|
4813
|
+
sourceType,
|
|
4814
|
+
getEventNameById
|
|
4815
|
+
]
|
|
4816
|
+
);
|
|
4817
|
+
const handleViewLogs = useCallback4(
|
|
4818
|
+
(seriesId, seriesIndex) => {
|
|
4819
|
+
const ctx = getSeriesContext(seriesId, seriesIndex);
|
|
4820
|
+
if (!ctx) return;
|
|
4821
|
+
onViewLogs?.(ctx);
|
|
4822
|
+
},
|
|
4823
|
+
[getSeriesContext, onViewLogs]
|
|
4824
|
+
);
|
|
4825
|
+
const handleViewUsers = useCallback4(
|
|
4826
|
+
(seriesId, seriesIndex) => {
|
|
4827
|
+
const ctx = getSeriesContext(seriesId, seriesIndex);
|
|
4828
|
+
if (!ctx) return;
|
|
4829
|
+
onViewUsers?.(ctx);
|
|
4830
|
+
},
|
|
4831
|
+
[getSeriesContext, onViewUsers]
|
|
4832
|
+
);
|
|
4833
|
+
const getViewLogDisabled = useCallback4(
|
|
4834
|
+
(seriesId, seriesIndex) => {
|
|
4835
|
+
const ctx = getSeriesContext(seriesId, seriesIndex);
|
|
4836
|
+
return viewLogDisabledProp?.(ctx) ?? false;
|
|
4837
|
+
},
|
|
4838
|
+
[getSeriesContext, viewLogDisabledProp]
|
|
4839
|
+
);
|
|
4840
|
+
const getViewUsersDisabled = useCallback4(
|
|
4841
|
+
(seriesId, seriesIndex) => {
|
|
4842
|
+
const ctx = getSeriesContext(seriesId, seriesIndex);
|
|
4843
|
+
return viewUsersDisabledProp?.(ctx) ?? false;
|
|
4844
|
+
},
|
|
4845
|
+
[getSeriesContext, viewUsersDisabledProp]
|
|
4846
|
+
);
|
|
4847
|
+
const tooltipFormatter = useCallback4(
|
|
4848
|
+
(params) => {
|
|
4849
|
+
const paramsArray = Array.isArray(params) ? params : [params];
|
|
4850
|
+
if (allowClick) {
|
|
4851
|
+
yAxisRef.current = paramsArray.map((param) => ({
|
|
4852
|
+
value: param.value,
|
|
4853
|
+
seriesIndex: param.seriesIndex,
|
|
4854
|
+
seriesName: param.seriesName
|
|
4855
|
+
}));
|
|
4856
|
+
}
|
|
4857
|
+
let title2 = void 0;
|
|
4858
|
+
if (nonXAxis) {
|
|
4859
|
+
const value = paramsArray?.[0]?.data?.[0];
|
|
4860
|
+
title2 = `${config?.xAxis?.column ? `${config?.xAxis?.column}:` : ""} ${value}`;
|
|
4861
|
+
} else if (xLabelFormatter) {
|
|
4862
|
+
const value = paramsArray?.[0]?.data?.[0];
|
|
4863
|
+
title2 = xLabelFormatter(value);
|
|
4864
|
+
}
|
|
4865
|
+
const annotatedParams = paramsArray.map((param) => {
|
|
4866
|
+
const yAxisName = seriesIdToYAxisName.get(param.seriesId);
|
|
4867
|
+
if (yAxisName) {
|
|
4868
|
+
return { ...param, seriesName: `${param.seriesName}(${yAxisName})` };
|
|
4869
|
+
}
|
|
4870
|
+
return param;
|
|
4871
|
+
});
|
|
4872
|
+
const parmas = {
|
|
4873
|
+
data: chartType === "SCATTER" ? params : annotatedParams,
|
|
4874
|
+
title: title2,
|
|
4875
|
+
highlightSeriesId: global.highlightSeriesId,
|
|
4876
|
+
compareTimeDuration: config?.timeRangeOverride?.compareTime?.ago,
|
|
4877
|
+
numberFormatter: (value, seriesId) => {
|
|
4878
|
+
const seriesFormatter = seriesId ? overlaySeriesIdToFormatter.get(seriesId) : void 0;
|
|
4879
|
+
if (seriesFormatter) {
|
|
4880
|
+
return seriesFormatter(value);
|
|
4881
|
+
}
|
|
4882
|
+
return numberFormatter(value);
|
|
4883
|
+
},
|
|
4884
|
+
showTotal: config?.valueConfig?.tooltipTotal,
|
|
4885
|
+
// Gate on the outward props existing (same as the original gating on the
|
|
4886
|
+
// handlers existing): no handler → button doesn't render.
|
|
4887
|
+
onViewLogs: onViewLogs ? handleViewLogs : void 0,
|
|
4888
|
+
viewLogDisabled: onViewLogs ? getViewLogDisabled : void 0,
|
|
4889
|
+
onViewUsers: onViewUsers ? handleViewUsers : void 0,
|
|
4890
|
+
viewUsersDisabled: onViewUsers ? getViewUsersDisabled : void 0,
|
|
4891
|
+
sizeTitle: config?.scatterConfig?.symbolSize
|
|
4892
|
+
};
|
|
4893
|
+
tooltipParmsRef.current = parmas;
|
|
4894
|
+
if (chartType === "SCATTER") {
|
|
4895
|
+
return ReactDOMServer.renderToString(
|
|
4896
|
+
/* @__PURE__ */ jsx28(
|
|
4897
|
+
ScatterChartTooltip,
|
|
4898
|
+
{
|
|
4899
|
+
...parmas,
|
|
4900
|
+
onViewLogs: void 0,
|
|
4901
|
+
viewLogDisabled: void 0,
|
|
4902
|
+
onViewUsers: void 0,
|
|
4903
|
+
viewUsersDisabled: void 0,
|
|
4904
|
+
sizeTitle: config?.scatterConfig?.symbolSize
|
|
4905
|
+
}
|
|
4906
|
+
)
|
|
4907
|
+
);
|
|
4908
|
+
} else {
|
|
4909
|
+
return ReactDOMServer.renderToString(
|
|
4910
|
+
/* @__PURE__ */ jsx28(
|
|
4911
|
+
ChartTooltip,
|
|
4912
|
+
{
|
|
4913
|
+
...parmas,
|
|
4914
|
+
onViewLogs: void 0,
|
|
4915
|
+
viewLogDisabled: void 0,
|
|
4916
|
+
onViewUsers: void 0,
|
|
4917
|
+
viewUsersDisabled: void 0
|
|
4918
|
+
}
|
|
4919
|
+
)
|
|
4920
|
+
);
|
|
4921
|
+
}
|
|
4922
|
+
},
|
|
4923
|
+
[
|
|
4924
|
+
allowClick,
|
|
4925
|
+
numberFormatter,
|
|
4926
|
+
overlaySeriesIdToFormatter,
|
|
4927
|
+
config,
|
|
4928
|
+
nonXAxis,
|
|
4929
|
+
chartType,
|
|
4930
|
+
xLabelFormatter,
|
|
4931
|
+
onViewLogs,
|
|
4932
|
+
handleViewLogs,
|
|
4933
|
+
getViewLogDisabled,
|
|
4934
|
+
onViewUsers,
|
|
4935
|
+
handleViewUsers,
|
|
4936
|
+
getViewUsersDisabled,
|
|
4937
|
+
seriesIdToYAxisName
|
|
4938
|
+
]
|
|
4939
|
+
);
|
|
4940
|
+
const [active, setActive] = useState10(false);
|
|
4941
|
+
const onSelect = useCallback4(
|
|
4942
|
+
(start2, end2) => {
|
|
4943
|
+
if (onSelectTimeRange && active) {
|
|
4944
|
+
let startTime2 = fromNumber(start2);
|
|
4945
|
+
let endTime2 = fromNumber(end2);
|
|
4946
|
+
const interval = config?.timeRangeOverride?.timeRange?.interval;
|
|
4947
|
+
if (interval) {
|
|
4948
|
+
startTime2 = alignTime(startTime2, interval, tz, "start");
|
|
4949
|
+
endTime2 = alignTime(endTime2, interval, tz, "end");
|
|
4950
|
+
}
|
|
4951
|
+
onSelectTimeRange(startTime2, endTime2);
|
|
4952
|
+
}
|
|
4953
|
+
},
|
|
4954
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4955
|
+
[onSelectTimeRange, active]
|
|
4956
|
+
);
|
|
4957
|
+
const allowBrush = useMemo9(() => {
|
|
4958
|
+
if (nonXAxis) {
|
|
4959
|
+
return false;
|
|
4960
|
+
}
|
|
4961
|
+
if (onSelectTimeRange && startTime && endTime) {
|
|
4962
|
+
const interval = config?.timeRangeOverride?.timeRange?.interval;
|
|
4963
|
+
const diff = toDayjs2(endTime).diff(toDayjs2(startTime), "seconds");
|
|
4964
|
+
return interval ? diff > durationToSeconds(interval) : true;
|
|
4965
|
+
}
|
|
4966
|
+
return false;
|
|
4967
|
+
}, [
|
|
4968
|
+
config?.timeRangeOverride?.timeRange,
|
|
4969
|
+
startTime,
|
|
4970
|
+
endTime,
|
|
4971
|
+
onSelectTimeRange,
|
|
4972
|
+
nonXAxis
|
|
4973
|
+
]);
|
|
4974
|
+
const xAxisData = useMemo9(() => {
|
|
4975
|
+
if (nonXAxis) {
|
|
4976
|
+
return [
|
|
4977
|
+
{
|
|
4978
|
+
type: "category",
|
|
4979
|
+
axisLabel: {
|
|
4980
|
+
hideOverlap: true,
|
|
4981
|
+
fontSize: 11
|
|
4982
|
+
},
|
|
4983
|
+
name: config?.xAxis?.name
|
|
4984
|
+
}
|
|
4985
|
+
];
|
|
4986
|
+
}
|
|
4987
|
+
const ret = [
|
|
4988
|
+
{
|
|
4989
|
+
type: config?.xAxis?.type || "time",
|
|
4990
|
+
min: config?.xAxis?.type === "category" ? void 0 : start,
|
|
4991
|
+
max: config?.xAxis?.type === "category" ? void 0 : end,
|
|
4992
|
+
axisLabel: {
|
|
4993
|
+
hideOverlap: true,
|
|
4994
|
+
fontSize: 11,
|
|
4995
|
+
formatter: xLabelFormatter
|
|
4996
|
+
},
|
|
4997
|
+
axisTick: {
|
|
4998
|
+
show: false
|
|
4999
|
+
}
|
|
5000
|
+
}
|
|
5001
|
+
];
|
|
5002
|
+
if (config?.xAxis?.name) {
|
|
5003
|
+
ret[0].name = config?.xAxis?.name;
|
|
5004
|
+
}
|
|
5005
|
+
if (config?.timeRangeOverride?.compareTime?.ago) {
|
|
5006
|
+
const d = config?.timeRangeOverride?.compareTime?.ago;
|
|
5007
|
+
const compareStart = toDayjs2(timeBefore(dayjs5(start), d, true)).toDate();
|
|
5008
|
+
const compareEnd = toDayjs2(timeBefore(dayjs5(end), d, false)).toDate();
|
|
5009
|
+
ret.push({
|
|
5010
|
+
show: false,
|
|
5011
|
+
type: config?.xAxis?.type || "time",
|
|
5012
|
+
min: config?.xAxis?.type === "category" ? void 0 : compareStart,
|
|
5013
|
+
max: config?.xAxis?.type === "category" ? void 0 : compareEnd,
|
|
5014
|
+
axisLabel: {
|
|
5015
|
+
hideOverlap: true,
|
|
5016
|
+
fontSize: 11,
|
|
5017
|
+
formatter: xLabelFormatter
|
|
5018
|
+
}
|
|
5019
|
+
});
|
|
5020
|
+
}
|
|
5021
|
+
return ret;
|
|
5022
|
+
}, [
|
|
5023
|
+
config?.timeRangeOverride?.compareTime,
|
|
5024
|
+
start,
|
|
5025
|
+
end,
|
|
5026
|
+
nonXAxis,
|
|
5027
|
+
config?.xAxis,
|
|
5028
|
+
xLabelFormatter
|
|
5029
|
+
]);
|
|
5030
|
+
const options = useMemo9(() => {
|
|
5031
|
+
const primarySeries = xAxisData.length == 2 ? [...series, ...compareSeries] : series;
|
|
5032
|
+
const primaryYAxis = {
|
|
5033
|
+
type: "value",
|
|
5034
|
+
axisLabel: {
|
|
5035
|
+
formatter: function(value) {
|
|
5036
|
+
if (value == yAxisLabel && maximumSignificantDigits < 21) {
|
|
5037
|
+
setMaximumSignificantDigits(maximumSignificantDigits + 1);
|
|
5038
|
+
}
|
|
5039
|
+
yAxisLabel = value;
|
|
5040
|
+
if (value > 1e21) {
|
|
5041
|
+
return NF_LARGE.format(value);
|
|
5042
|
+
}
|
|
5043
|
+
return NF.format(value);
|
|
5044
|
+
},
|
|
5045
|
+
margin: chartType === "SCATTER" ? config?.scatterConfig?.maxSize ? config.scatterConfig.maxSize : 30 : 4
|
|
5046
|
+
},
|
|
5047
|
+
...yAxisToChartOption(
|
|
5048
|
+
yAxis,
|
|
5049
|
+
markLines,
|
|
5050
|
+
primarySeries
|
|
5051
|
+
)
|
|
5052
|
+
};
|
|
5053
|
+
const baseOptions = {
|
|
5054
|
+
title: {
|
|
5055
|
+
text: title
|
|
5056
|
+
},
|
|
5057
|
+
grid: {
|
|
5058
|
+
top: title ? 48 : 16,
|
|
5059
|
+
right: chartType === "SCATTER" ? 16 : 8,
|
|
5060
|
+
bottom: 8,
|
|
5061
|
+
left: chartType === "SCATTER" ? 20 : 12,
|
|
5062
|
+
containLabel: true
|
|
5063
|
+
},
|
|
5064
|
+
xAxis: xAxisData,
|
|
5065
|
+
dataZoom: {
|
|
5066
|
+
type: "inside",
|
|
5067
|
+
zoomLock: true
|
|
5068
|
+
},
|
|
5069
|
+
legend: {
|
|
5070
|
+
data: legend,
|
|
5071
|
+
top: -1e4,
|
|
5072
|
+
left: -1e4
|
|
5073
|
+
},
|
|
5074
|
+
brush: allowBrush ? {
|
|
5075
|
+
xAxisIndex: 0
|
|
5076
|
+
} : void 0,
|
|
5077
|
+
toolbox: {
|
|
5078
|
+
show: false
|
|
5079
|
+
},
|
|
5080
|
+
yAxis: primaryYAxis,
|
|
5081
|
+
animation: false,
|
|
5082
|
+
series: primarySeries,
|
|
5083
|
+
tooltip: {
|
|
5084
|
+
trigger: chartType === "SCATTER" ? "item" : "axis",
|
|
5085
|
+
confine: true,
|
|
5086
|
+
textStyle: {
|
|
5087
|
+
fontSize: 14,
|
|
5088
|
+
fontFamily: sansFontFamily
|
|
5089
|
+
},
|
|
5090
|
+
extraCssText: "max-width: 75%; max-height: 50vh; overflow-y: auto; padding: 10px 0; background-color: rgba(var(--text-background)); border-color: rgba(var(--border-color));",
|
|
5091
|
+
formatter: tooltipFormatter
|
|
5092
|
+
},
|
|
5093
|
+
visualMap: chartType === "SCATTER" && config?.scatterConfig?.color && sentioColors.dark[config.scatterConfig.color] ? {
|
|
5094
|
+
dimension: 2,
|
|
5095
|
+
min: minRef.current,
|
|
5096
|
+
max: maxRef.current,
|
|
5097
|
+
show: false,
|
|
5098
|
+
inRange: {
|
|
5099
|
+
color: isDarkMode ? sentioColors.dark[config.scatterConfig.color] : sentioColors.light[config.scatterConfig.color]
|
|
5100
|
+
}
|
|
5101
|
+
} : void 0
|
|
5102
|
+
};
|
|
5103
|
+
const finalOptions = applyOverlaySeries(baseOptions);
|
|
5104
|
+
if (isDarkMode && Array.isArray(finalOptions.series)) {
|
|
5105
|
+
finalOptions.series = applyDarkAreaOpacity(
|
|
5106
|
+
finalOptions.series
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5109
|
+
return finalOptions;
|
|
5110
|
+
}, [
|
|
5111
|
+
title,
|
|
5112
|
+
xAxisData,
|
|
5113
|
+
legend,
|
|
5114
|
+
allowBrush,
|
|
5115
|
+
yAxis,
|
|
5116
|
+
series,
|
|
5117
|
+
compareSeries,
|
|
5118
|
+
applyOverlaySeries,
|
|
5119
|
+
tooltipFormatter,
|
|
5120
|
+
maximumSignificantDigits,
|
|
5121
|
+
xAxis,
|
|
5122
|
+
chartType,
|
|
5123
|
+
isDarkMode
|
|
5124
|
+
]);
|
|
5125
|
+
const {
|
|
5126
|
+
value: isOpen,
|
|
5127
|
+
setFalse: setClose,
|
|
5128
|
+
setTrue: setOpen
|
|
5129
|
+
} = useBoolean(false);
|
|
5130
|
+
const clickEventParamsRef = useRef4(null);
|
|
5131
|
+
const [selectedSeriesIndex, setSelectedSeriesIndex] = useState10(0);
|
|
5132
|
+
const chartPositionRef = useRef4(null);
|
|
5133
|
+
const { x, y, strategy, refs } = useFloating3({
|
|
5134
|
+
open: isOpen,
|
|
5135
|
+
placement: "right",
|
|
5136
|
+
middleware: [flip(), shift2()]
|
|
5137
|
+
});
|
|
5138
|
+
const onClick = useCallback4(
|
|
5139
|
+
(params, rawParams) => {
|
|
5140
|
+
if (!params) {
|
|
5141
|
+
setClose();
|
|
5142
|
+
return;
|
|
5143
|
+
}
|
|
5144
|
+
const baseBoundingRect = chartPositionRef.current?.getBoundingClientRect();
|
|
5145
|
+
if (params.event) {
|
|
5146
|
+
const { event } = params;
|
|
5147
|
+
clickEventParamsRef.current = params;
|
|
5148
|
+
const targetBoundRect = event.target.getBoundingRect();
|
|
5149
|
+
refs.setPositionReference({
|
|
5150
|
+
getBoundingClientRect: () => {
|
|
5151
|
+
return {
|
|
5152
|
+
x: event.offsetX + (baseBoundingRect?.x ?? 0),
|
|
5153
|
+
y: event.offsetY + (baseBoundingRect?.y ?? 0),
|
|
5154
|
+
width: targetBoundRect.width,
|
|
5155
|
+
height: targetBoundRect.height,
|
|
5156
|
+
top: event.offsetY + (baseBoundingRect?.top ?? 0),
|
|
5157
|
+
right: event.offsetX + (baseBoundingRect?.right ?? 0),
|
|
5158
|
+
bottom: event.offsetY + (baseBoundingRect?.bottom ?? 0),
|
|
5159
|
+
left: event.offsetX + (baseBoundingRect?.left ?? 0)
|
|
5160
|
+
};
|
|
5161
|
+
}
|
|
5162
|
+
});
|
|
5163
|
+
} else if (isArray(params)) {
|
|
5164
|
+
const targetValue = closestNumber(
|
|
5165
|
+
yAxisRef.current?.map((item) => item.value[1]),
|
|
5166
|
+
params[1]
|
|
5167
|
+
);
|
|
5168
|
+
clickEventParamsRef.current = yAxisRef.current?.find(
|
|
5169
|
+
(item) => item.value[1] === targetValue
|
|
5170
|
+
);
|
|
5171
|
+
refs.setPositionReference({
|
|
5172
|
+
getBoundingClientRect: () => {
|
|
5173
|
+
return {
|
|
5174
|
+
x: rawParams.offsetX + (baseBoundingRect?.x ?? 0),
|
|
5175
|
+
y: rawParams.offsetY + (baseBoundingRect?.y ?? 0),
|
|
5176
|
+
width: 10,
|
|
5177
|
+
height: 10,
|
|
5178
|
+
top: rawParams.offsetY + (baseBoundingRect?.top ?? 0),
|
|
5179
|
+
right: rawParams.offsetX + (baseBoundingRect?.right ?? 0),
|
|
5180
|
+
bottom: rawParams.offsetY + (baseBoundingRect?.bottom ?? 0),
|
|
5181
|
+
left: rawParams.offsetX + (baseBoundingRect?.left ?? 0)
|
|
5182
|
+
};
|
|
5183
|
+
}
|
|
5184
|
+
});
|
|
5185
|
+
}
|
|
5186
|
+
setOpen();
|
|
5187
|
+
},
|
|
5188
|
+
[refs, setClose, setOpen]
|
|
5189
|
+
);
|
|
5190
|
+
const onSeriesEvent = useCallback4((event, params) => {
|
|
5191
|
+
switch (event) {
|
|
5192
|
+
case "click":
|
|
5193
|
+
setSelectedSeriesIndex(params.seriesIndex);
|
|
5194
|
+
break;
|
|
5195
|
+
case "mouseover":
|
|
5196
|
+
;
|
|
5197
|
+
global.highlightSeriesId = params.seriesId;
|
|
5198
|
+
document.querySelectorAll(`.series_${params.seriesId}`).forEach((node) => {
|
|
5199
|
+
node.classList.add("highlighted");
|
|
5200
|
+
});
|
|
5201
|
+
break;
|
|
5202
|
+
case "mouseout":
|
|
5203
|
+
const previousSeriesId = global.highlightSeriesId;
|
|
5204
|
+
if (previousSeriesId) {
|
|
5205
|
+
document.querySelectorAll(`.series_${previousSeriesId}`).forEach((node) => {
|
|
5206
|
+
node.classList.remove("highlighted");
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
;
|
|
5210
|
+
global.highlightSeriesId = "";
|
|
5211
|
+
}
|
|
5212
|
+
}, []);
|
|
5213
|
+
const onSelectSeries = useCallback4(
|
|
5214
|
+
(seriesIndex) => {
|
|
5215
|
+
clickEventParamsRef.current = {
|
|
5216
|
+
seriesIndex,
|
|
5217
|
+
seriesName: series[seriesIndex].name
|
|
5218
|
+
};
|
|
5219
|
+
if (yAxisRef.current[seriesIndex]?.value) {
|
|
5220
|
+
clickEventParamsRef.current.value = yAxisRef.current[seriesIndex].value;
|
|
5221
|
+
}
|
|
5222
|
+
setSelectedSeriesIndex(seriesIndex);
|
|
5223
|
+
},
|
|
5224
|
+
[series, setSelectedSeriesIndex]
|
|
5225
|
+
);
|
|
5226
|
+
const switchSeries = useMemo9(() => {
|
|
5227
|
+
const items = [
|
|
5228
|
+
series.map((serie, index) => ({
|
|
5229
|
+
label: serie.name || "",
|
|
5230
|
+
key: `${index}`
|
|
5231
|
+
}))
|
|
5232
|
+
];
|
|
5233
|
+
return /* @__PURE__ */ jsx28(
|
|
5234
|
+
PopupMenuButton,
|
|
5235
|
+
{
|
|
5236
|
+
onSelect: (d) => onSelectSeries(parseInt(d, 10)),
|
|
5237
|
+
items,
|
|
5238
|
+
buttonIcon: (open) => /* @__PURE__ */ jsx28(
|
|
5239
|
+
"span",
|
|
5240
|
+
{
|
|
5241
|
+
className: classNames8(
|
|
5242
|
+
"text-primary-100",
|
|
5243
|
+
"hover:bg-primary-200/80 inline-block cursor-pointer rounded-md px-1 py-0.5",
|
|
5244
|
+
open ? "bg-primary-200/80" : ""
|
|
5245
|
+
),
|
|
5246
|
+
children: /* @__PURE__ */ jsx28(LuChevronDown2, { className: "h-3.5 w-3.5" })
|
|
5247
|
+
}
|
|
5248
|
+
),
|
|
5249
|
+
portal: false,
|
|
5250
|
+
placement: "bottom-end",
|
|
5251
|
+
itemsClassName: "max-h-[50vh] overflow-y-auto"
|
|
5252
|
+
}
|
|
5253
|
+
);
|
|
5254
|
+
}, [series]);
|
|
5255
|
+
void switchSeries;
|
|
5256
|
+
void selectedSeriesIndex;
|
|
5257
|
+
const noLegend = useMemo9(() => {
|
|
5258
|
+
if (chartType === "SCATTER" && series.length === 1) {
|
|
5259
|
+
return true;
|
|
5260
|
+
}
|
|
5261
|
+
return _noLegend;
|
|
5262
|
+
}, [_noLegend, chartType, series?.length]);
|
|
5263
|
+
return /* @__PURE__ */ jsxs18(
|
|
5264
|
+
"div",
|
|
5265
|
+
{
|
|
5266
|
+
className: "h-full w-full",
|
|
5267
|
+
onMouseOver: () => {
|
|
5268
|
+
setActive(true);
|
|
5269
|
+
},
|
|
5270
|
+
onMouseOut: () => {
|
|
5271
|
+
setActive(false);
|
|
5272
|
+
},
|
|
5273
|
+
children: [
|
|
5274
|
+
/* @__PURE__ */ jsx28(
|
|
5275
|
+
ReactEChartsBase,
|
|
5276
|
+
{
|
|
5277
|
+
ref,
|
|
5278
|
+
loading,
|
|
5279
|
+
group,
|
|
5280
|
+
option: options,
|
|
5281
|
+
minHeight,
|
|
5282
|
+
returnedSeries,
|
|
5283
|
+
totalSeries,
|
|
5284
|
+
onSelect,
|
|
5285
|
+
onClick: allowClick ? onClick : void 0,
|
|
5286
|
+
style,
|
|
5287
|
+
onSeriesEvent,
|
|
5288
|
+
noLegend,
|
|
5289
|
+
onInitChart
|
|
5290
|
+
}
|
|
5291
|
+
),
|
|
5292
|
+
controls && nonXAxis && /* @__PURE__ */ jsx28(XAxisControls, { xAxis, setXAxis, defaultOpen: true }),
|
|
5293
|
+
controls && /* @__PURE__ */ jsx28(YaxisControls, { yAxis, setYAxis: setYAxisWrap }),
|
|
5294
|
+
/* @__PURE__ */ jsx28("div", { className: "absolute left-0 top-0", ref: chartPositionRef }),
|
|
5295
|
+
isOpen && allowClick && /* @__PURE__ */ jsx28(FloatingPortal2, { children: /* @__PURE__ */ jsx28(FloatingOverlay, { className: "z-50 bg-gray-100/20", onClick: setClose, children: /* @__PURE__ */ jsx28(
|
|
5296
|
+
"div",
|
|
5297
|
+
{
|
|
5298
|
+
ref: refs.setFloating,
|
|
5299
|
+
className: "border-border-color bg-default-bg min-w-64 absolute w-fit divide-y rounded-md border pb-2 shadow-sm",
|
|
5300
|
+
style: {
|
|
5301
|
+
position: strategy,
|
|
5302
|
+
top: 0,
|
|
5303
|
+
left: 0,
|
|
5304
|
+
transform: `translate(${roundByDPR(x || 0)}px,${roundByDPR(y || 0)}px)`
|
|
5305
|
+
},
|
|
5306
|
+
onClick: onClickPreventDefault,
|
|
5307
|
+
children: /* @__PURE__ */ jsx28("div", { className: "text-text-foreground max-h-80 max-w-[50vw] overflow-y-auto py-2 text-sm", children: chartType === "SCATTER" ? /* @__PURE__ */ jsx28(ScatterChartTooltip, { ...tooltipParmsRef.current, isFixed: true }) : /* @__PURE__ */ jsx28(ChartTooltip, { ...tooltipParmsRef.current, isFixed: true }) })
|
|
5308
|
+
}
|
|
5309
|
+
) }) })
|
|
5310
|
+
]
|
|
5311
|
+
}
|
|
5312
|
+
);
|
|
5313
|
+
}
|
|
5314
|
+
);
|
|
5315
|
+
TimeSeriesChart.displayName = "TimeSeriesChart";
|
|
5316
|
+
function computeMarkLines(series, markLines) {
|
|
5317
|
+
if (markLines && markLines.length > 0 && series.length > 0) {
|
|
5318
|
+
series[0] = {
|
|
5319
|
+
...series[0],
|
|
5320
|
+
markLine: {
|
|
5321
|
+
symbol: [],
|
|
5322
|
+
data: markLines.map((area) => {
|
|
5323
|
+
if (area.from || area.to) {
|
|
5324
|
+
return [
|
|
5325
|
+
{
|
|
5326
|
+
name: "threshold",
|
|
5327
|
+
xAxis: area.from,
|
|
5328
|
+
yAxis: area.value ?? "min",
|
|
5329
|
+
symbol: "react",
|
|
5330
|
+
symbolSize: [20, 1],
|
|
5331
|
+
symbolOffset: [area.below ? -10 : 10, 0],
|
|
5332
|
+
label: {
|
|
5333
|
+
formatter: `${area.label}`,
|
|
5334
|
+
position: area.below ? "insideMiddleBottom" : "insideMiddleTop",
|
|
5335
|
+
color: area.color || "#ff0000"
|
|
5336
|
+
},
|
|
5337
|
+
lineStyle: {
|
|
5338
|
+
color: area.color || "#ff0000"
|
|
5339
|
+
}
|
|
5340
|
+
},
|
|
5341
|
+
{
|
|
5342
|
+
symbol: "rect",
|
|
5343
|
+
symbolSize: [20, 1],
|
|
5344
|
+
symbolOffset: [area.below ? 10 : -10, 0],
|
|
5345
|
+
xAxis: area.to ? area.to : void 0,
|
|
5346
|
+
yAxis: area.value ?? "max"
|
|
5347
|
+
}
|
|
5348
|
+
];
|
|
5349
|
+
} else {
|
|
5350
|
+
return {
|
|
5351
|
+
name: "threshold",
|
|
5352
|
+
yAxis: area.value,
|
|
5353
|
+
symbol: "react",
|
|
5354
|
+
symbolSize: [20, 1],
|
|
5355
|
+
symbolOffset: [area.below ? -10 : 10, 0],
|
|
5356
|
+
label: {
|
|
5357
|
+
formatter: `${area.label}`,
|
|
5358
|
+
position: area.below ? "insideStartBottom" : "insideStartTop",
|
|
5359
|
+
color: area.color || "#ff0000"
|
|
5360
|
+
},
|
|
5361
|
+
lineStyle: {
|
|
5362
|
+
color: area.color || "#ff0000"
|
|
5363
|
+
}
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
})
|
|
5367
|
+
}
|
|
5368
|
+
};
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
function computeMarksAreas(series, markAreas) {
|
|
5372
|
+
if (markAreas && markAreas.length > 0 && series.length > 0) {
|
|
5373
|
+
series[0].markArea = {
|
|
5374
|
+
itemStyle: {
|
|
5375
|
+
color: markAreas[0].color || "rgba(255, 173, 177, 0.4)"
|
|
5376
|
+
}
|
|
5377
|
+
};
|
|
5378
|
+
series[0].markArea.data = markAreas.map((markArea) => {
|
|
5379
|
+
return [
|
|
5380
|
+
{
|
|
5381
|
+
xAxis: markArea.from ? markArea.from : void 0
|
|
5382
|
+
},
|
|
5383
|
+
{
|
|
5384
|
+
xAxis: markArea.to ? markArea.to : void 0
|
|
5385
|
+
}
|
|
5386
|
+
];
|
|
5387
|
+
});
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
var MIN_SIZE = 5;
|
|
5391
|
+
var MAX_SIZE = 30;
|
|
5392
|
+
var LEVELS = 10;
|
|
5393
|
+
function normalize(value, min, max, minSize = MIN_SIZE, maxSize = MAX_SIZE) {
|
|
5394
|
+
if (max === min) return MIN_SIZE;
|
|
5395
|
+
if (value <= min) return minSize;
|
|
5396
|
+
if (value >= max) return maxSize;
|
|
5397
|
+
const range = max - min;
|
|
5398
|
+
const levelRange = range / LEVELS;
|
|
5399
|
+
const sizeIncrement = (maxSize - minSize) / (LEVELS - 1);
|
|
5400
|
+
const level = Math.floor((value - min) / levelRange);
|
|
5401
|
+
const clampedLevel = Math.min(level, LEVELS - 1);
|
|
5402
|
+
return minSize + clampedLevel * sizeIncrement;
|
|
5403
|
+
}
|
|
5404
|
+
|
|
3916
5405
|
// src/charts/options/LineControls.tsx
|
|
3917
5406
|
import { produce as produce4 } from "immer";
|
|
3918
5407
|
import {
|
|
3919
|
-
DisclosurePanel,
|
|
5408
|
+
DisclosurePanel as DisclosurePanel3,
|
|
3920
5409
|
NewButtonGroup as ButtonGroup2,
|
|
3921
|
-
Checkbox
|
|
5410
|
+
Checkbox as Checkbox2
|
|
3922
5411
|
} from "@sentio/ui-core";
|
|
3923
|
-
import { jsx as
|
|
5412
|
+
import { jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3924
5413
|
var lineStyles = [
|
|
3925
5414
|
{ label: "Solid", value: "Solid" },
|
|
3926
5415
|
{ label: "Dotted", value: "Dotted" }
|
|
@@ -3940,13 +5429,13 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
|
|
|
3940
5429
|
})
|
|
3941
5430
|
);
|
|
3942
5431
|
};
|
|
3943
|
-
return /* @__PURE__ */
|
|
3944
|
-
|
|
5432
|
+
return /* @__PURE__ */ jsx29(
|
|
5433
|
+
DisclosurePanel3,
|
|
3945
5434
|
{
|
|
3946
5435
|
title: "Line style",
|
|
3947
5436
|
containerClassName: "w-full bg-default-bg",
|
|
3948
|
-
children: /* @__PURE__ */
|
|
3949
|
-
/* @__PURE__ */
|
|
5437
|
+
children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-4", children: [
|
|
5438
|
+
/* @__PURE__ */ jsx29(
|
|
3950
5439
|
ButtonGroup2,
|
|
3951
5440
|
{
|
|
3952
5441
|
buttons: lineStyles,
|
|
@@ -3955,8 +5444,8 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
|
|
|
3955
5444
|
small: true
|
|
3956
5445
|
}
|
|
3957
5446
|
),
|
|
3958
|
-
/* @__PURE__ */
|
|
3959
|
-
|
|
5447
|
+
/* @__PURE__ */ jsx29(
|
|
5448
|
+
Checkbox2,
|
|
3960
5449
|
{
|
|
3961
5450
|
label: "Smooth Curves",
|
|
3962
5451
|
checked: config?.smooth,
|
|
@@ -3969,16 +5458,16 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
|
|
|
3969
5458
|
};
|
|
3970
5459
|
|
|
3971
5460
|
// src/charts/options/LabelControls.tsx
|
|
3972
|
-
import { useEffect as
|
|
5461
|
+
import { useEffect as useEffect9, useMemo as useMemo10 } from "react";
|
|
3973
5462
|
import { produce as produce5 } from "immer";
|
|
3974
|
-
import { Button as NewButton2, DisclosurePanel as
|
|
3975
|
-
import { jsx as
|
|
3976
|
-
var
|
|
5463
|
+
import { Button as NewButton2, DisclosurePanel as DisclosurePanel4, HelpIcon as HelpIcon2 } from "@sentio/ui-core";
|
|
5464
|
+
import { jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5465
|
+
var initialConfig3 = {
|
|
3977
5466
|
columns: [],
|
|
3978
5467
|
alias: ""
|
|
3979
5468
|
};
|
|
3980
5469
|
var LabelControls = ({ config, setConfig, defaultOpen }) => {
|
|
3981
|
-
|
|
5470
|
+
useEffect9(() => {
|
|
3982
5471
|
if (config?.columns && config.columns.length > 0 && !config.alias) {
|
|
3983
5472
|
const aliasParts = [];
|
|
3984
5473
|
config.columns.forEach((colConfig) => {
|
|
@@ -4003,36 +5492,36 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
|
|
|
4003
5492
|
}, [config, setConfig]);
|
|
4004
5493
|
const onAliasChanged = (alias) => {
|
|
4005
5494
|
setConfig(
|
|
4006
|
-
produce5(config ??
|
|
5495
|
+
produce5(config ?? initialConfig3, (draft) => {
|
|
4007
5496
|
draft.alias = alias;
|
|
4008
5497
|
})
|
|
4009
5498
|
);
|
|
4010
5499
|
};
|
|
4011
|
-
const _defaultOpen =
|
|
5500
|
+
const _defaultOpen = useMemo10(() => {
|
|
4012
5501
|
if (defaultOpen) {
|
|
4013
5502
|
return true;
|
|
4014
5503
|
}
|
|
4015
5504
|
return config?.alias !== "" || config?.columns && config.columns.length > 0;
|
|
4016
5505
|
}, [config, defaultOpen]);
|
|
4017
|
-
return /* @__PURE__ */
|
|
4018
|
-
|
|
5506
|
+
return /* @__PURE__ */ jsx30(
|
|
5507
|
+
DisclosurePanel4,
|
|
4019
5508
|
{
|
|
4020
5509
|
title: "Label Controls",
|
|
4021
5510
|
defaultOpen: _defaultOpen,
|
|
4022
5511
|
containerClassName: "w-full bg-default-bg",
|
|
4023
|
-
children: /* @__PURE__ */
|
|
4024
|
-
/* @__PURE__ */
|
|
4025
|
-
/* @__PURE__ */
|
|
5512
|
+
children: /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-2", children: [
|
|
5513
|
+
/* @__PURE__ */ jsxs20("div", { className: "inline-flex h-8", children: [
|
|
5514
|
+
/* @__PURE__ */ jsxs20("span", { className: "sm:text-icontent border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-2 font-medium", children: [
|
|
4026
5515
|
"Label Alias",
|
|
4027
|
-
/* @__PURE__ */
|
|
5516
|
+
/* @__PURE__ */ jsx30(
|
|
4028
5517
|
HelpIcon2,
|
|
4029
5518
|
{
|
|
4030
|
-
text: /* @__PURE__ */
|
|
4031
|
-
/* @__PURE__ */
|
|
4032
|
-
/* @__PURE__ */
|
|
5519
|
+
text: /* @__PURE__ */ jsxs20("div", { className: "text-icontent text-text-foreground", children: [
|
|
5520
|
+
/* @__PURE__ */ jsx30("div", { children: "Series name override or template." }),
|
|
5521
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
4033
5522
|
"Ex.",
|
|
4034
5523
|
" ",
|
|
4035
|
-
/* @__PURE__ */
|
|
5524
|
+
/* @__PURE__ */ jsx30("span", { className: "text-primary mx-1 font-semibold italic", children: "{{contract}}" }),
|
|
4036
5525
|
" ",
|
|
4037
5526
|
"will be replaced with the value of the contract label."
|
|
4038
5527
|
] })
|
|
@@ -4040,7 +5529,7 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
|
|
|
4040
5529
|
}
|
|
4041
5530
|
)
|
|
4042
5531
|
] }),
|
|
4043
|
-
/* @__PURE__ */
|
|
5532
|
+
/* @__PURE__ */ jsx30(
|
|
4044
5533
|
"input",
|
|
4045
5534
|
{
|
|
4046
5535
|
type: "text",
|
|
@@ -4051,13 +5540,13 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
|
|
|
4051
5540
|
}
|
|
4052
5541
|
)
|
|
4053
5542
|
] }),
|
|
4054
|
-
/* @__PURE__ */
|
|
5543
|
+
/* @__PURE__ */ jsx30(
|
|
4055
5544
|
NewButton2,
|
|
4056
5545
|
{
|
|
4057
5546
|
type: "button",
|
|
4058
5547
|
role: "link",
|
|
4059
5548
|
onClick: () => {
|
|
4060
|
-
setConfig(
|
|
5549
|
+
setConfig(initialConfig3);
|
|
4061
5550
|
},
|
|
4062
5551
|
children: "Reset"
|
|
4063
5552
|
}
|
|
@@ -4069,13 +5558,13 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
|
|
|
4069
5558
|
|
|
4070
5559
|
// src/charts/options/PieChartControls.tsx
|
|
4071
5560
|
import { produce as produce6 } from "immer";
|
|
4072
|
-
import { defaults } from "lodash";
|
|
5561
|
+
import { defaults as defaults3 } from "lodash";
|
|
4073
5562
|
import {
|
|
4074
|
-
Checkbox as
|
|
4075
|
-
DisclosurePanel as
|
|
5563
|
+
Checkbox as Checkbox3,
|
|
5564
|
+
DisclosurePanel as DisclosurePanel5,
|
|
4076
5565
|
NewButtonGroup as ButtonGroup3
|
|
4077
5566
|
} from "@sentio/ui-core";
|
|
4078
|
-
import { jsx as
|
|
5567
|
+
import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4079
5568
|
var defaultConfig = {
|
|
4080
5569
|
pieType: "Pie",
|
|
4081
5570
|
calculation: "LAST",
|
|
@@ -4096,7 +5585,7 @@ var PieTypeItems = [
|
|
|
4096
5585
|
{ label: "Donut", value: "Donut" }
|
|
4097
5586
|
];
|
|
4098
5587
|
function PieChartControls({ config, defaultOpen, onChange }) {
|
|
4099
|
-
config =
|
|
5588
|
+
config = defaults3(config, defaultConfig);
|
|
4100
5589
|
function onCalculationChange(cal) {
|
|
4101
5590
|
config && onChange(produce6(config, (draft) => void (draft.calculation = cal)));
|
|
4102
5591
|
}
|
|
@@ -4110,14 +5599,14 @@ function PieChartControls({ config, defaultOpen, onChange }) {
|
|
|
4110
5599
|
})
|
|
4111
5600
|
);
|
|
4112
5601
|
}
|
|
4113
|
-
return /* @__PURE__ */
|
|
4114
|
-
|
|
5602
|
+
return /* @__PURE__ */ jsx31(
|
|
5603
|
+
DisclosurePanel5,
|
|
4115
5604
|
{
|
|
4116
5605
|
title: "Pie Chart Options",
|
|
4117
5606
|
defaultOpen,
|
|
4118
5607
|
containerClassName: "w-full bg-default-bg",
|
|
4119
|
-
children: /* @__PURE__ */
|
|
4120
|
-
/* @__PURE__ */
|
|
5608
|
+
children: /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-4", children: [
|
|
5609
|
+
/* @__PURE__ */ jsx31("div", { className: "shadow-xs flex rounded-md", children: /* @__PURE__ */ jsx31(
|
|
4121
5610
|
ButtonGroup3,
|
|
4122
5611
|
{
|
|
4123
5612
|
small: true,
|
|
@@ -4126,22 +5615,22 @@ function PieChartControls({ config, defaultOpen, onChange }) {
|
|
|
4126
5615
|
onChange: onPieTypeChange
|
|
4127
5616
|
}
|
|
4128
5617
|
) }),
|
|
4129
|
-
/* @__PURE__ */
|
|
4130
|
-
/* @__PURE__ */
|
|
4131
|
-
/* @__PURE__ */
|
|
5618
|
+
/* @__PURE__ */ jsxs21("div", { className: "shadow-xs flex rounded-md", children: [
|
|
5619
|
+
/* @__PURE__ */ jsx31("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
|
|
5620
|
+
/* @__PURE__ */ jsx31(
|
|
4132
5621
|
"select",
|
|
4133
5622
|
{
|
|
4134
5623
|
value: config.calculation,
|
|
4135
5624
|
className: "sm:text-ilabel text-text-foreground border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
|
|
4136
5625
|
onChange: (e) => onCalculationChange(e.target.value),
|
|
4137
5626
|
children: CalculationItems.map((d) => {
|
|
4138
|
-
return /* @__PURE__ */
|
|
5627
|
+
return /* @__PURE__ */ jsx31("option", { value: d.value, children: d.label }, d.value);
|
|
4139
5628
|
})
|
|
4140
5629
|
}
|
|
4141
5630
|
)
|
|
4142
5631
|
] }),
|
|
4143
|
-
/* @__PURE__ */
|
|
4144
|
-
|
|
5632
|
+
/* @__PURE__ */ jsx31(
|
|
5633
|
+
Checkbox3,
|
|
4145
5634
|
{
|
|
4146
5635
|
checked: config?.showValue,
|
|
4147
5636
|
onChange: (v) => toggle("showValue", v),
|
|
@@ -4149,8 +5638,8 @@ function PieChartControls({ config, defaultOpen, onChange }) {
|
|
|
4149
5638
|
labelClassName: "whitespace-nowrap"
|
|
4150
5639
|
}
|
|
4151
5640
|
),
|
|
4152
|
-
/* @__PURE__ */
|
|
4153
|
-
|
|
5641
|
+
/* @__PURE__ */ jsx31(
|
|
5642
|
+
Checkbox3,
|
|
4154
5643
|
{
|
|
4155
5644
|
checked: config?.showPercent,
|
|
4156
5645
|
onChange: (v) => toggle("showPercent", v),
|
|
@@ -4158,8 +5647,8 @@ function PieChartControls({ config, defaultOpen, onChange }) {
|
|
|
4158
5647
|
labelClassName: "whitespace-nowrap"
|
|
4159
5648
|
}
|
|
4160
5649
|
),
|
|
4161
|
-
/* @__PURE__ */
|
|
4162
|
-
|
|
5650
|
+
/* @__PURE__ */ jsx31(
|
|
5651
|
+
Checkbox3,
|
|
4163
5652
|
{
|
|
4164
5653
|
checked: config?.absValue,
|
|
4165
5654
|
onChange: (v) => toggle("absValue", v),
|
|
@@ -4174,9 +5663,9 @@ function PieChartControls({ config, defaultOpen, onChange }) {
|
|
|
4174
5663
|
|
|
4175
5664
|
// src/charts/options/BarGaugeControls.tsx
|
|
4176
5665
|
import { produce as produce7 } from "immer";
|
|
4177
|
-
import { defaults as
|
|
4178
|
-
import { DisclosurePanel as
|
|
4179
|
-
import { jsx as
|
|
5666
|
+
import { defaults as defaults4 } from "lodash";
|
|
5667
|
+
import { DisclosurePanel as DisclosurePanel6 } from "@sentio/ui-core";
|
|
5668
|
+
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4180
5669
|
var defaultConfig2 = {
|
|
4181
5670
|
direction: "HORIZONTAL",
|
|
4182
5671
|
calculation: "LAST",
|
|
@@ -4197,16 +5686,16 @@ var CalculationItems2 = [
|
|
|
4197
5686
|
{ label: "Max", value: "MAX" },
|
|
4198
5687
|
{ label: "Min", value: "MIN" }
|
|
4199
5688
|
];
|
|
4200
|
-
var
|
|
5689
|
+
var sortByItems2 = [
|
|
4201
5690
|
{ label: "Name", value: "ByName" },
|
|
4202
5691
|
{ label: "Value", value: "ByValue" }
|
|
4203
5692
|
];
|
|
4204
|
-
var
|
|
5693
|
+
var orderItems2 = [
|
|
4205
5694
|
{ label: "Ascendant", value: "false" },
|
|
4206
5695
|
{ label: "Descendant", value: "true" }
|
|
4207
5696
|
];
|
|
4208
5697
|
function BarGaugeControls({ config, defaultOpen, onChange }) {
|
|
4209
|
-
config =
|
|
5698
|
+
config = defaults4(config, defaultConfig2);
|
|
4210
5699
|
function onCalculationChange(cal) {
|
|
4211
5700
|
config && onChange(produce7(config, (draft) => void (draft.calculation = cal)));
|
|
4212
5701
|
}
|
|
@@ -4229,62 +5718,62 @@ function BarGaugeControls({ config, defaultOpen, onChange }) {
|
|
|
4229
5718
|
})
|
|
4230
5719
|
);
|
|
4231
5720
|
}
|
|
4232
|
-
return /* @__PURE__ */
|
|
4233
|
-
|
|
5721
|
+
return /* @__PURE__ */ jsx32(
|
|
5722
|
+
DisclosurePanel6,
|
|
4234
5723
|
{
|
|
4235
5724
|
title: "Bar Gauge Options",
|
|
4236
5725
|
defaultOpen,
|
|
4237
5726
|
containerClassName: "w-full bg-default-bg",
|
|
4238
|
-
children: /* @__PURE__ */
|
|
4239
|
-
/* @__PURE__ */
|
|
4240
|
-
/* @__PURE__ */
|
|
4241
|
-
/* @__PURE__ */
|
|
5727
|
+
children: /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-4", children: [
|
|
5728
|
+
/* @__PURE__ */ jsxs22("div", { className: "shadow-xs flex rounded-md", children: [
|
|
5729
|
+
/* @__PURE__ */ jsx32("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Direction" }),
|
|
5730
|
+
/* @__PURE__ */ jsx32(
|
|
4242
5731
|
"select",
|
|
4243
5732
|
{
|
|
4244
5733
|
value: config.direction,
|
|
4245
5734
|
className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
|
|
4246
5735
|
onChange: (e) => onDirectionChange(e.target.value),
|
|
4247
5736
|
children: directionItems.map((d) => {
|
|
4248
|
-
return /* @__PURE__ */
|
|
5737
|
+
return /* @__PURE__ */ jsx32("option", { value: d.value, children: d.label }, d.value);
|
|
4249
5738
|
})
|
|
4250
5739
|
}
|
|
4251
5740
|
)
|
|
4252
5741
|
] }),
|
|
4253
|
-
/* @__PURE__ */
|
|
4254
|
-
/* @__PURE__ */
|
|
4255
|
-
/* @__PURE__ */
|
|
5742
|
+
/* @__PURE__ */ jsxs22("div", { className: "shadow-xs flex rounded-md", children: [
|
|
5743
|
+
/* @__PURE__ */ jsx32("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
|
|
5744
|
+
/* @__PURE__ */ jsx32(
|
|
4256
5745
|
"select",
|
|
4257
5746
|
{
|
|
4258
5747
|
value: config.calculation,
|
|
4259
5748
|
className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
|
|
4260
5749
|
onChange: (e) => onCalculationChange(e.target.value),
|
|
4261
5750
|
children: CalculationItems2.map((d) => {
|
|
4262
|
-
return /* @__PURE__ */
|
|
5751
|
+
return /* @__PURE__ */ jsx32("option", { value: d.value, children: d.label }, d.value);
|
|
4263
5752
|
})
|
|
4264
5753
|
}
|
|
4265
5754
|
)
|
|
4266
5755
|
] }),
|
|
4267
|
-
/* @__PURE__ */
|
|
4268
|
-
/* @__PURE__ */
|
|
4269
|
-
/* @__PURE__ */
|
|
5756
|
+
/* @__PURE__ */ jsxs22("div", { className: "shadow-xs flex rounded-md", children: [
|
|
5757
|
+
/* @__PURE__ */ jsx32("span", { className: "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap rounded-l-md border border-r-0 bg-gray-50 px-3", children: "Sort by" }),
|
|
5758
|
+
/* @__PURE__ */ jsx32(
|
|
4270
5759
|
"select",
|
|
4271
5760
|
{
|
|
4272
5761
|
value: config?.sort?.sortBy,
|
|
4273
5762
|
className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center border pl-4 pr-7",
|
|
4274
5763
|
onChange: (e) => onSortByChange(e.target.value),
|
|
4275
|
-
children:
|
|
4276
|
-
return /* @__PURE__ */
|
|
5764
|
+
children: sortByItems2.map((d) => {
|
|
5765
|
+
return /* @__PURE__ */ jsx32("option", { value: d.value, children: d.label }, d.value);
|
|
4277
5766
|
})
|
|
4278
5767
|
}
|
|
4279
5768
|
),
|
|
4280
|
-
/* @__PURE__ */
|
|
5769
|
+
/* @__PURE__ */ jsx32(
|
|
4281
5770
|
"select",
|
|
4282
5771
|
{
|
|
4283
5772
|
value: config?.sort?.orderDesc + "",
|
|
4284
5773
|
className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border border-l-0 pl-4 pr-7",
|
|
4285
5774
|
onChange: (e) => onOrderChange(e.target.value === "true"),
|
|
4286
|
-
children:
|
|
4287
|
-
return /* @__PURE__ */
|
|
5775
|
+
children: orderItems2.map((d) => {
|
|
5776
|
+
return /* @__PURE__ */ jsx32("option", { value: d.value + "", children: d.label }, d.label);
|
|
4288
5777
|
})
|
|
4289
5778
|
}
|
|
4290
5779
|
)
|
|
@@ -4296,30 +5785,13 @@ function BarGaugeControls({ config, defaultOpen, onChange }) {
|
|
|
4296
5785
|
|
|
4297
5786
|
// src/charts/options/ValueOptions.tsx
|
|
4298
5787
|
import { produce as produce9 } from "immer";
|
|
4299
|
-
import { ComboInput, classNames as
|
|
4300
|
-
|
|
4301
|
-
// src/charts/options/controls-ui.tsx
|
|
4302
|
-
import { classNames as classNames7 } from "@sentio/ui-core";
|
|
4303
|
-
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
4304
|
-
var AddonLabel = ({
|
|
4305
|
-
className,
|
|
4306
|
-
children
|
|
4307
|
-
}) => /* @__PURE__ */ jsx29(
|
|
4308
|
-
"span",
|
|
4309
|
-
{
|
|
4310
|
-
className: classNames7(
|
|
4311
|
-
"sm:text-icontent border-main inline-flex items-center whitespace-nowrap bg-gray-50",
|
|
4312
|
-
className
|
|
4313
|
-
),
|
|
4314
|
-
children
|
|
4315
|
-
}
|
|
4316
|
-
);
|
|
5788
|
+
import { ComboInput, classNames as classNames10 } from "@sentio/ui-core";
|
|
4317
5789
|
|
|
4318
5790
|
// src/charts/options/ValueStringMapping.tsx
|
|
4319
5791
|
import { LuPlus, LuTrash2 } from "react-icons/lu";
|
|
4320
|
-
import { Button, classNames as
|
|
5792
|
+
import { Button as Button3, classNames as classNames9 } from "@sentio/ui-core";
|
|
4321
5793
|
import { produce as produce8 } from "immer";
|
|
4322
|
-
import { jsx as
|
|
5794
|
+
import { jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4323
5795
|
var operators = {
|
|
4324
5796
|
">": "greater than",
|
|
4325
5797
|
">=": "greater or equal",
|
|
@@ -4329,17 +5801,17 @@ var operators = {
|
|
|
4329
5801
|
"<=": "less or equal"
|
|
4330
5802
|
};
|
|
4331
5803
|
var renderTreeLine = (index, isLast) => {
|
|
4332
|
-
return /* @__PURE__ */
|
|
4333
|
-
/* @__PURE__ */
|
|
5804
|
+
return /* @__PURE__ */ jsx33("div", { className: "mr-2 flex h-12 w-3 flex-col items-center justify-center", children: /* @__PURE__ */ jsxs23("div", { className: "flex h-full w-full items-center", children: [
|
|
5805
|
+
/* @__PURE__ */ jsx33(
|
|
4334
5806
|
"div",
|
|
4335
5807
|
{
|
|
4336
|
-
className:
|
|
5808
|
+
className: classNames9(
|
|
4337
5809
|
"w-px bg-gray-300",
|
|
4338
5810
|
isLast ? "h-1/2 self-start" : index === 0 ? "h-full self-end" : "h-full"
|
|
4339
5811
|
)
|
|
4340
5812
|
}
|
|
4341
5813
|
),
|
|
4342
|
-
/* @__PURE__ */
|
|
5814
|
+
/* @__PURE__ */ jsx33("div", { className: "h-px w-3 bg-gray-300" })
|
|
4343
5815
|
] }) });
|
|
4344
5816
|
};
|
|
4345
5817
|
function ValueStringMapping({ rules, onChange }) {
|
|
@@ -4370,31 +5842,31 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4370
5842
|
})
|
|
4371
5843
|
);
|
|
4372
5844
|
}
|
|
4373
|
-
return /* @__PURE__ */
|
|
5845
|
+
return /* @__PURE__ */ jsxs23("div", { className: "flex w-full flex-col rounded-md py-2", children: [
|
|
4374
5846
|
(rules || []).map((rule, index) => {
|
|
4375
5847
|
const isLast = index === (rules || []).length - 1;
|
|
4376
|
-
return /* @__PURE__ */
|
|
5848
|
+
return /* @__PURE__ */ jsxs23(
|
|
4377
5849
|
"div",
|
|
4378
5850
|
{
|
|
4379
5851
|
className: "text-text-foreground flex h-10 items-center py-1",
|
|
4380
5852
|
children: [
|
|
4381
5853
|
renderTreeLine(index, isLast),
|
|
4382
|
-
/* @__PURE__ */
|
|
4383
|
-
/* @__PURE__ */
|
|
5854
|
+
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel inline-flex h-full items-center pr-3 font-medium", children: "If value is" }),
|
|
5855
|
+
/* @__PURE__ */ jsx33(
|
|
4384
5856
|
"select",
|
|
4385
5857
|
{
|
|
4386
5858
|
value: rule.comparison,
|
|
4387
5859
|
onChange: (e) => changeRule(index, "comparison", e.target.value),
|
|
4388
5860
|
className: "rounded-r-0 sm:text-ilabel border-main text-text-foreground focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 inline-flex h-full items-center rounded-l-md border border-r-0 bg-gray-50 py-1 pl-4 pr-7",
|
|
4389
5861
|
children: Object.entries(operators).map(([op, display]) => {
|
|
4390
|
-
return /* @__PURE__ */
|
|
5862
|
+
return /* @__PURE__ */ jsxs23("option", { value: op, children: [
|
|
4391
5863
|
"is ",
|
|
4392
5864
|
display
|
|
4393
5865
|
] }, op);
|
|
4394
5866
|
})
|
|
4395
5867
|
}
|
|
4396
5868
|
),
|
|
4397
|
-
/* @__PURE__ */
|
|
5869
|
+
/* @__PURE__ */ jsx33(
|
|
4398
5870
|
"input",
|
|
4399
5871
|
{
|
|
4400
5872
|
type: "text",
|
|
@@ -4408,8 +5880,8 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4408
5880
|
}
|
|
4409
5881
|
}
|
|
4410
5882
|
),
|
|
4411
|
-
/* @__PURE__ */
|
|
4412
|
-
/* @__PURE__ */
|
|
5883
|
+
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-3 font-medium", children: ", then show" }),
|
|
5884
|
+
/* @__PURE__ */ jsx33(
|
|
4413
5885
|
"input",
|
|
4414
5886
|
{
|
|
4415
5887
|
type: "text",
|
|
@@ -4423,14 +5895,14 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4423
5895
|
}
|
|
4424
5896
|
}
|
|
4425
5897
|
),
|
|
4426
|
-
/* @__PURE__ */
|
|
5898
|
+
/* @__PURE__ */ jsx33(
|
|
4427
5899
|
"button",
|
|
4428
5900
|
{
|
|
4429
5901
|
type: "button",
|
|
4430
5902
|
className: "mx-2",
|
|
4431
5903
|
"aria-label": "remove",
|
|
4432
5904
|
onClick: () => removeRule(index),
|
|
4433
|
-
children: /* @__PURE__ */
|
|
5905
|
+
children: /* @__PURE__ */ jsx33(
|
|
4434
5906
|
LuTrash2,
|
|
4435
5907
|
{
|
|
4436
5908
|
className: "icon text-text-foreground-disabled",
|
|
@@ -4444,8 +5916,8 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4444
5916
|
index
|
|
4445
5917
|
);
|
|
4446
5918
|
}),
|
|
4447
|
-
/* @__PURE__ */
|
|
4448
|
-
|
|
5919
|
+
/* @__PURE__ */ jsxs23(
|
|
5920
|
+
Button3,
|
|
4449
5921
|
{
|
|
4450
5922
|
type: "button",
|
|
4451
5923
|
role: "secondary",
|
|
@@ -4453,7 +5925,7 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4453
5925
|
"aria-label": "remove",
|
|
4454
5926
|
onClick: addRule,
|
|
4455
5927
|
children: [
|
|
4456
|
-
/* @__PURE__ */
|
|
5928
|
+
/* @__PURE__ */ jsx33(LuPlus, { className: classNames9("h-4 w-4"), "aria-hidden": "true" }),
|
|
4457
5929
|
"Add Formatting Rule"
|
|
4458
5930
|
]
|
|
4459
5931
|
}
|
|
@@ -4462,7 +5934,7 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
4462
5934
|
}
|
|
4463
5935
|
|
|
4464
5936
|
// src/charts/options/ValueOptions.tsx
|
|
4465
|
-
import { Fragment as
|
|
5937
|
+
import { Fragment as Fragment9, jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4466
5938
|
var ValueFormatters = [
|
|
4467
5939
|
{ label: "Number", value: "NumberFormatter" },
|
|
4468
5940
|
{ label: "Date", value: "DateFormatter" },
|
|
@@ -4491,7 +5963,7 @@ var CurrencySymbols = [
|
|
|
4491
5963
|
var AddonLabel2 = ({
|
|
4492
5964
|
className,
|
|
4493
5965
|
children
|
|
4494
|
-
}) => /* @__PURE__ */
|
|
5966
|
+
}) => /* @__PURE__ */ jsx34(AddonLabel, { className: classNames10("px-3", className), children });
|
|
4495
5967
|
var ValueOptions = ({
|
|
4496
5968
|
config,
|
|
4497
5969
|
onChange,
|
|
@@ -4558,9 +6030,9 @@ var ValueOptions = ({
|
|
|
4558
6030
|
function numberAddons(style) {
|
|
4559
6031
|
switch (style) {
|
|
4560
6032
|
case "None":
|
|
4561
|
-
return /* @__PURE__ */
|
|
4562
|
-
/* @__PURE__ */
|
|
4563
|
-
/* @__PURE__ */
|
|
6033
|
+
return /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6034
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-l-0", children: "Fraction Digits" }),
|
|
6035
|
+
/* @__PURE__ */ jsx34(
|
|
4564
6036
|
"input",
|
|
4565
6037
|
{
|
|
4566
6038
|
disabled: true,
|
|
@@ -4571,9 +6043,9 @@ var ValueOptions = ({
|
|
|
4571
6043
|
] });
|
|
4572
6044
|
case "Percent":
|
|
4573
6045
|
case "Standard":
|
|
4574
|
-
return /* @__PURE__ */
|
|
4575
|
-
/* @__PURE__ */
|
|
4576
|
-
/* @__PURE__ */
|
|
6046
|
+
return /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6047
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-x-0", children: "Fraction Digits" }),
|
|
6048
|
+
/* @__PURE__ */ jsx34(
|
|
4577
6049
|
"input",
|
|
4578
6050
|
{
|
|
4579
6051
|
type: "number",
|
|
@@ -4587,9 +6059,9 @@ var ValueOptions = ({
|
|
|
4587
6059
|
)
|
|
4588
6060
|
] });
|
|
4589
6061
|
case "Currency":
|
|
4590
|
-
return /* @__PURE__ */
|
|
4591
|
-
/* @__PURE__ */
|
|
4592
|
-
/* @__PURE__ */
|
|
6062
|
+
return /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6063
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-r-0", children: "Symbol" }),
|
|
6064
|
+
/* @__PURE__ */ jsx34("div", { className: "w-28 ", children: /* @__PURE__ */ jsx34(
|
|
4593
6065
|
ComboInput,
|
|
4594
6066
|
{
|
|
4595
6067
|
onChange: onChangeSymbol,
|
|
@@ -4602,8 +6074,8 @@ var ValueOptions = ({
|
|
|
4602
6074
|
value: config?.currencySymbol
|
|
4603
6075
|
}
|
|
4604
6076
|
) }),
|
|
4605
|
-
/* @__PURE__ */
|
|
4606
|
-
/* @__PURE__ */
|
|
6077
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border", children: "Precision" }),
|
|
6078
|
+
/* @__PURE__ */ jsx34(
|
|
4607
6079
|
"input",
|
|
4608
6080
|
{
|
|
4609
6081
|
type: "number",
|
|
@@ -4618,9 +6090,9 @@ var ValueOptions = ({
|
|
|
4618
6090
|
)
|
|
4619
6091
|
] });
|
|
4620
6092
|
default:
|
|
4621
|
-
return /* @__PURE__ */
|
|
4622
|
-
/* @__PURE__ */
|
|
4623
|
-
/* @__PURE__ */
|
|
6093
|
+
return /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6094
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-x-0", children: "Max significant digits" }),
|
|
6095
|
+
/* @__PURE__ */ jsx34(
|
|
4624
6096
|
"input",
|
|
4625
6097
|
{
|
|
4626
6098
|
type: "number",
|
|
@@ -4635,62 +6107,62 @@ var ValueOptions = ({
|
|
|
4635
6107
|
] });
|
|
4636
6108
|
}
|
|
4637
6109
|
}
|
|
4638
|
-
return /* @__PURE__ */
|
|
4639
|
-
/* @__PURE__ */
|
|
4640
|
-
/* @__PURE__ */
|
|
4641
|
-
/* @__PURE__ */
|
|
6110
|
+
return /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6111
|
+
/* @__PURE__ */ jsx34("div", { children: /* @__PURE__ */ jsxs24("div", { className: "flex", children: [
|
|
6112
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "rounded-l-md border border-r-0", children: "Value formatter" }),
|
|
6113
|
+
/* @__PURE__ */ jsx34(
|
|
4642
6114
|
"select",
|
|
4643
6115
|
{
|
|
4644
6116
|
value: config.valueFormatter,
|
|
4645
|
-
className:
|
|
6117
|
+
className: classNames10(
|
|
4646
6118
|
"sm:text-ilabel border-main text-text-foreground hover:border-primary-600 inline-flex items-center border py-1.5 pl-4 pr-7 focus:ring-0",
|
|
4647
6119
|
config.valueFormatter == "StringFormatter" ? "rounded-r-md" : ""
|
|
4648
6120
|
),
|
|
4649
6121
|
onChange: (e) => onChangeFormatter(e.target.value),
|
|
4650
6122
|
children: formatters.map((d) => {
|
|
4651
|
-
return /* @__PURE__ */
|
|
6123
|
+
return /* @__PURE__ */ jsx34("option", { value: d.value, children: d.label }, d.value);
|
|
4652
6124
|
})
|
|
4653
6125
|
}
|
|
4654
6126
|
),
|
|
4655
|
-
config.valueFormatter == "NumberFormatter" && /* @__PURE__ */
|
|
4656
|
-
/* @__PURE__ */
|
|
4657
|
-
/* @__PURE__ */
|
|
6127
|
+
config.valueFormatter == "NumberFormatter" && /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6128
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-l-0 border-r-0", children: "Style" }),
|
|
6129
|
+
/* @__PURE__ */ jsxs24(
|
|
4658
6130
|
"select",
|
|
4659
6131
|
{
|
|
4660
6132
|
value: config.style,
|
|
4661
6133
|
className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 inline-flex items-center border py-1 pl-4 pr-7 focus:ring-0",
|
|
4662
6134
|
onChange: (e) => onStyleChange(e.target.value),
|
|
4663
6135
|
children: [
|
|
4664
|
-
/* @__PURE__ */
|
|
4665
|
-
/* @__PURE__ */
|
|
4666
|
-
/* @__PURE__ */
|
|
4667
|
-
/* @__PURE__ */
|
|
4668
|
-
/* @__PURE__ */
|
|
4669
|
-
/* @__PURE__ */
|
|
6136
|
+
/* @__PURE__ */ jsx34("option", { value: "None", children: "None" }),
|
|
6137
|
+
/* @__PURE__ */ jsx34("option", { value: "Compact", children: "Compact" }),
|
|
6138
|
+
/* @__PURE__ */ jsx34("option", { value: "Standard", children: "Standard" }),
|
|
6139
|
+
/* @__PURE__ */ jsx34("option", { value: "Scientific", children: "Scientific" }),
|
|
6140
|
+
/* @__PURE__ */ jsx34("option", { value: "Percent", children: "Percent" }),
|
|
6141
|
+
/* @__PURE__ */ jsx34("option", { value: "Currency", children: "Currency" })
|
|
4670
6142
|
]
|
|
4671
6143
|
}
|
|
4672
6144
|
),
|
|
4673
6145
|
config.style && numberAddons(config.style)
|
|
4674
6146
|
] }),
|
|
4675
|
-
config.valueFormatter == "DateFormatter" && /* @__PURE__ */
|
|
4676
|
-
/* @__PURE__ */
|
|
4677
|
-
/* @__PURE__ */
|
|
6147
|
+
config.valueFormatter == "DateFormatter" && /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6148
|
+
/* @__PURE__ */ jsx34(AddonLabel2, { className: "border border-l-0", children: "Date format" }),
|
|
6149
|
+
/* @__PURE__ */ jsx34(
|
|
4678
6150
|
"select",
|
|
4679
6151
|
{
|
|
4680
6152
|
value: config.dateFormat,
|
|
4681
6153
|
className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center rounded-r-md border border-l-0 py-1 pl-4 pr-7",
|
|
4682
6154
|
onChange: (e) => onChangeDateFormat(e.target.value),
|
|
4683
6155
|
children: dateFormats.map((d) => {
|
|
4684
|
-
return /* @__PURE__ */
|
|
6156
|
+
return /* @__PURE__ */ jsx34("option", { value: d.value, children: d.label }, d.value);
|
|
4685
6157
|
})
|
|
4686
6158
|
}
|
|
4687
6159
|
)
|
|
4688
6160
|
] })
|
|
4689
6161
|
] }) }),
|
|
4690
|
-
(showPrefix || showSuffix) && /* @__PURE__ */
|
|
4691
|
-
showPrefix && /* @__PURE__ */
|
|
4692
|
-
/* @__PURE__ */
|
|
4693
|
-
/* @__PURE__ */
|
|
6162
|
+
(showPrefix || showSuffix) && /* @__PURE__ */ jsx34("div", { children: /* @__PURE__ */ jsxs24("div", { className: "mt-2 flex items-center gap-4", children: [
|
|
6163
|
+
showPrefix && /* @__PURE__ */ jsxs24("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
|
|
6164
|
+
/* @__PURE__ */ jsx34("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Prefix" }),
|
|
6165
|
+
/* @__PURE__ */ jsx34(
|
|
4694
6166
|
"input",
|
|
4695
6167
|
{
|
|
4696
6168
|
type: "text",
|
|
@@ -4701,9 +6173,9 @@ var ValueOptions = ({
|
|
|
4701
6173
|
}
|
|
4702
6174
|
)
|
|
4703
6175
|
] }),
|
|
4704
|
-
showSuffix && /* @__PURE__ */
|
|
4705
|
-
/* @__PURE__ */
|
|
4706
|
-
/* @__PURE__ */
|
|
6176
|
+
showSuffix && /* @__PURE__ */ jsxs24("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
|
|
6177
|
+
/* @__PURE__ */ jsx34("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Suffix" }),
|
|
6178
|
+
/* @__PURE__ */ jsx34(
|
|
4707
6179
|
"input",
|
|
4708
6180
|
{
|
|
4709
6181
|
type: "text",
|
|
@@ -4715,7 +6187,7 @@ var ValueOptions = ({
|
|
|
4715
6187
|
)
|
|
4716
6188
|
] })
|
|
4717
6189
|
] }) }),
|
|
4718
|
-
config.valueFormatter == "StringFormatter" && /* @__PURE__ */
|
|
6190
|
+
config.valueFormatter == "StringFormatter" && /* @__PURE__ */ jsx34(
|
|
4719
6191
|
ValueStringMapping,
|
|
4720
6192
|
{
|
|
4721
6193
|
rules: config.mappingRules || [],
|
|
@@ -4726,10 +6198,10 @@ var ValueOptions = ({
|
|
|
4726
6198
|
};
|
|
4727
6199
|
|
|
4728
6200
|
// src/charts/options/ValueControls.tsx
|
|
4729
|
-
import { defaults as
|
|
4730
|
-
import { Checkbox as
|
|
6201
|
+
import { defaults as defaults5 } from "lodash";
|
|
6202
|
+
import { Checkbox as Checkbox4, DisclosurePanel as DisclosurePanel7 } from "@sentio/ui-core";
|
|
4731
6203
|
import { produce as produce10 } from "immer";
|
|
4732
|
-
import { jsx as
|
|
6204
|
+
import { jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
4733
6205
|
var defaultConfig4 = {
|
|
4734
6206
|
valueFormatter: "NumberFormatter",
|
|
4735
6207
|
showValueLabel: false,
|
|
@@ -4747,7 +6219,7 @@ var ValueControls = ({
|
|
|
4747
6219
|
showPrefix,
|
|
4748
6220
|
showSuffix
|
|
4749
6221
|
}) => {
|
|
4750
|
-
config =
|
|
6222
|
+
config = defaults5(config || {}, defaultConfig4);
|
|
4751
6223
|
function toggleShowValueLabel(checked) {
|
|
4752
6224
|
config && onChange(
|
|
4753
6225
|
produce10(config, (draft) => void (draft.showValueLabel = checked))
|
|
@@ -4756,14 +6228,14 @@ var ValueControls = ({
|
|
|
4756
6228
|
function toggleTooltipTotal(checked) {
|
|
4757
6229
|
config && onChange(produce10(config, (draft) => void (draft.tooltipTotal = checked)));
|
|
4758
6230
|
}
|
|
4759
|
-
return /* @__PURE__ */
|
|
4760
|
-
|
|
6231
|
+
return /* @__PURE__ */ jsxs25(
|
|
6232
|
+
DisclosurePanel7,
|
|
4761
6233
|
{
|
|
4762
6234
|
title: "Value Options",
|
|
4763
6235
|
defaultOpen,
|
|
4764
6236
|
containerClassName: "w-full bg-default-bg",
|
|
4765
6237
|
children: [
|
|
4766
|
-
/* @__PURE__ */
|
|
6238
|
+
/* @__PURE__ */ jsx35(
|
|
4767
6239
|
ValueOptions,
|
|
4768
6240
|
{
|
|
4769
6241
|
onChange,
|
|
@@ -4773,17 +6245,17 @@ var ValueControls = ({
|
|
|
4773
6245
|
showSuffix
|
|
4774
6246
|
}
|
|
4775
6247
|
),
|
|
4776
|
-
/* @__PURE__ */
|
|
4777
|
-
/* @__PURE__ */
|
|
4778
|
-
|
|
6248
|
+
/* @__PURE__ */ jsxs25("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
6249
|
+
/* @__PURE__ */ jsx35(
|
|
6250
|
+
Checkbox4,
|
|
4779
6251
|
{
|
|
4780
6252
|
checked: config?.showValueLabel,
|
|
4781
6253
|
onChange: toggleShowValueLabel,
|
|
4782
6254
|
label: "Show value label"
|
|
4783
6255
|
}
|
|
4784
6256
|
),
|
|
4785
|
-
/* @__PURE__ */
|
|
4786
|
-
|
|
6257
|
+
/* @__PURE__ */ jsx35(
|
|
6258
|
+
Checkbox4,
|
|
4787
6259
|
{
|
|
4788
6260
|
checked: config?.tooltipTotal,
|
|
4789
6261
|
onChange: toggleTooltipTotal,
|
|
@@ -4796,290 +6268,11 @@ var ValueControls = ({
|
|
|
4796
6268
|
);
|
|
4797
6269
|
};
|
|
4798
6270
|
|
|
4799
|
-
// src/charts/options/YaxisControls.tsx
|
|
4800
|
-
import { defaults as defaults4 } from "lodash";
|
|
4801
|
-
import { Button as Button2, Checkbox as Checkbox4, DisclosurePanel as DisclosurePanel6 } from "@sentio/ui-core";
|
|
4802
|
-
import { Fragment as Fragment9, jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4803
|
-
var initialConfig2 = {
|
|
4804
|
-
yAxis: {
|
|
4805
|
-
min: "",
|
|
4806
|
-
max: "",
|
|
4807
|
-
scale: true,
|
|
4808
|
-
stack: ""
|
|
4809
|
-
}
|
|
4810
|
-
};
|
|
4811
|
-
function YaxisControls({
|
|
4812
|
-
yAxis,
|
|
4813
|
-
setYAxis,
|
|
4814
|
-
defaultOpen,
|
|
4815
|
-
columnSelect,
|
|
4816
|
-
supportSetName = true,
|
|
4817
|
-
supportSetMinMax = true,
|
|
4818
|
-
supportStackSeries = true,
|
|
4819
|
-
supportAlwaysShowZero = true,
|
|
4820
|
-
supportReset = true,
|
|
4821
|
-
panelTitle = "Y-Axis Controls"
|
|
4822
|
-
}) {
|
|
4823
|
-
yAxis = defaults4(yAxis || {}, initialConfig2.yAxis);
|
|
4824
|
-
const onChangeInput = (field) => (event) => {
|
|
4825
|
-
const { value } = event.target;
|
|
4826
|
-
setYAxis({
|
|
4827
|
-
...yAxis,
|
|
4828
|
-
[field]: value || void 0,
|
|
4829
|
-
scale: field == "min" && value > "0" ? true : yAxis?.scale
|
|
4830
|
-
});
|
|
4831
|
-
};
|
|
4832
|
-
const onToggleZero = (checked) => {
|
|
4833
|
-
setYAxis({ ...yAxis, scale: !checked, min: checked ? "" : yAxis?.min });
|
|
4834
|
-
};
|
|
4835
|
-
const onClickResetYAxis = () => {
|
|
4836
|
-
setYAxis(initialConfig2.yAxis);
|
|
4837
|
-
};
|
|
4838
|
-
const onToggleStack = (checked) => {
|
|
4839
|
-
setYAxis({ ...yAxis, stacked: checked ? "samesign" : "" });
|
|
4840
|
-
};
|
|
4841
|
-
const minMaxLabelCls = "inline-flex items-center border border-r-0 sm:text-icontent border-main bg-gray-50 px-2 rounded-l-md";
|
|
4842
|
-
const minMaxInputCls = "border focus:border-primary-500 rounded-r-md sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30";
|
|
4843
|
-
return /* @__PURE__ */ jsx33(
|
|
4844
|
-
DisclosurePanel6,
|
|
4845
|
-
{
|
|
4846
|
-
title: panelTitle,
|
|
4847
|
-
defaultOpen,
|
|
4848
|
-
containerClassName: "w-full bg-default-bg",
|
|
4849
|
-
children: /* @__PURE__ */ jsxs23("div", { className: "text-icontent flex flex-wrap gap-[10px]", children: [
|
|
4850
|
-
supportSetName && /* @__PURE__ */ jsxs23("label", { className: "inline-flex h-8", children: [
|
|
4851
|
-
/* @__PURE__ */ jsx33(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Name" }),
|
|
4852
|
-
/* @__PURE__ */ jsx33(
|
|
4853
|
-
"input",
|
|
4854
|
-
{
|
|
4855
|
-
type: "text",
|
|
4856
|
-
className: "focus:border-primary-500 sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 w-40 rounded-r-md border",
|
|
4857
|
-
value: yAxis?.name,
|
|
4858
|
-
placeholder: "Axis Name",
|
|
4859
|
-
onChange: onChangeInput("name")
|
|
4860
|
-
}
|
|
4861
|
-
)
|
|
4862
|
-
] }),
|
|
4863
|
-
columnSelect && /* @__PURE__ */ jsxs23("span", { className: "inline-flex h-8", children: [
|
|
4864
|
-
/* @__PURE__ */ jsx33(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Column" }),
|
|
4865
|
-
columnSelect
|
|
4866
|
-
] }),
|
|
4867
|
-
supportSetMinMax && /* @__PURE__ */ jsxs23(Fragment9, { children: [
|
|
4868
|
-
/* @__PURE__ */ jsxs23("label", { className: "inline-flex h-8", children: [
|
|
4869
|
-
/* @__PURE__ */ jsx33("span", { className: minMaxLabelCls, children: "Min" }),
|
|
4870
|
-
/* @__PURE__ */ jsx33(
|
|
4871
|
-
"input",
|
|
4872
|
-
{
|
|
4873
|
-
type: "text",
|
|
4874
|
-
className: minMaxInputCls,
|
|
4875
|
-
style: { width: "10em" },
|
|
4876
|
-
value: yAxis.min,
|
|
4877
|
-
placeholder: "Auto",
|
|
4878
|
-
onChange: onChangeInput("min")
|
|
4879
|
-
}
|
|
4880
|
-
)
|
|
4881
|
-
] }),
|
|
4882
|
-
/* @__PURE__ */ jsxs23("label", { className: "inline-flex h-8", children: [
|
|
4883
|
-
/* @__PURE__ */ jsx33("span", { className: minMaxLabelCls, children: "Max" }),
|
|
4884
|
-
/* @__PURE__ */ jsx33(
|
|
4885
|
-
"input",
|
|
4886
|
-
{
|
|
4887
|
-
type: "text",
|
|
4888
|
-
className: minMaxInputCls,
|
|
4889
|
-
style: { width: "10em" },
|
|
4890
|
-
value: yAxis.max,
|
|
4891
|
-
placeholder: "Auto",
|
|
4892
|
-
onChange: onChangeInput("max")
|
|
4893
|
-
}
|
|
4894
|
-
)
|
|
4895
|
-
] })
|
|
4896
|
-
] }),
|
|
4897
|
-
supportStackSeries && /* @__PURE__ */ jsx33(
|
|
4898
|
-
Checkbox4,
|
|
4899
|
-
{
|
|
4900
|
-
checked: !!yAxis?.stacked,
|
|
4901
|
-
onChange: onToggleStack,
|
|
4902
|
-
label: "Stack series"
|
|
4903
|
-
}
|
|
4904
|
-
),
|
|
4905
|
-
supportAlwaysShowZero && /* @__PURE__ */ jsx33(
|
|
4906
|
-
Checkbox4,
|
|
4907
|
-
{
|
|
4908
|
-
checked: !yAxis.scale,
|
|
4909
|
-
onChange: onToggleZero,
|
|
4910
|
-
label: "Always show zero"
|
|
4911
|
-
}
|
|
4912
|
-
),
|
|
4913
|
-
supportReset && /* @__PURE__ */ jsx33(Button2, { type: "button", role: "link", onClick: onClickResetYAxis, children: "Reset" })
|
|
4914
|
-
] })
|
|
4915
|
-
}
|
|
4916
|
-
);
|
|
4917
|
-
}
|
|
4918
|
-
|
|
4919
|
-
// src/charts/options/XaxisControls.tsx
|
|
4920
|
-
import {
|
|
4921
|
-
Button as Button3,
|
|
4922
|
-
DisclosurePanel as DisclosurePanel7,
|
|
4923
|
-
PopoverTooltip,
|
|
4924
|
-
Select
|
|
4925
|
-
} from "@sentio/ui-core";
|
|
4926
|
-
import { LuInfo } from "react-icons/lu";
|
|
4927
|
-
import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4928
|
-
var TypeSelect = Select;
|
|
4929
|
-
var SortSelect = Select;
|
|
4930
|
-
var OrderSelect = Select;
|
|
4931
|
-
var sortByItems2 = [
|
|
4932
|
-
{ label: "Name", value: "ByName" },
|
|
4933
|
-
{ label: "Value", value: "ByValue" }
|
|
4934
|
-
];
|
|
4935
|
-
var orderItems2 = [
|
|
4936
|
-
{ label: "Ascendant", value: false },
|
|
4937
|
-
{ label: "Descendant", value: true }
|
|
4938
|
-
];
|
|
4939
|
-
var XAxisControls = ({
|
|
4940
|
-
xAxis,
|
|
4941
|
-
setXAxis,
|
|
4942
|
-
defaultOpen,
|
|
4943
|
-
columnSelect,
|
|
4944
|
-
columnIsNonTime,
|
|
4945
|
-
panelTitle = "X-Axis Controls",
|
|
4946
|
-
supportName = true,
|
|
4947
|
-
supportSort,
|
|
4948
|
-
supportSetType
|
|
4949
|
-
}) => {
|
|
4950
|
-
const onChangeInput = (field) => (event) => {
|
|
4951
|
-
const { value } = event.target;
|
|
4952
|
-
setXAxis({ ...xAxis, [field]: value || void 0 });
|
|
4953
|
-
};
|
|
4954
|
-
const onClickResetXAxis = () => {
|
|
4955
|
-
setXAxis(void 0);
|
|
4956
|
-
};
|
|
4957
|
-
const isXAixsNoneTime = xAxis && xAxis.column && columnIsNonTime;
|
|
4958
|
-
return /* @__PURE__ */ jsx34(
|
|
4959
|
-
DisclosurePanel7,
|
|
4960
|
-
{
|
|
4961
|
-
title: panelTitle,
|
|
4962
|
-
defaultOpen,
|
|
4963
|
-
containerClassName: "w-full bg-default-bg",
|
|
4964
|
-
children: /* @__PURE__ */ jsxs24("div", { className: "text-icontent flex flex-wrap gap-[10px]", children: [
|
|
4965
|
-
supportName && /* @__PURE__ */ jsxs24("label", { className: "inline-flex h-8", children: [
|
|
4966
|
-
/* @__PURE__ */ jsx34(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Name" }),
|
|
4967
|
-
/* @__PURE__ */ jsx34(
|
|
4968
|
-
"input",
|
|
4969
|
-
{
|
|
4970
|
-
type: "text",
|
|
4971
|
-
className: "sm:text-icontent border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 w-40 rounded-r-md",
|
|
4972
|
-
value: xAxis?.name,
|
|
4973
|
-
placeholder: "Axis Name",
|
|
4974
|
-
onChange: onChangeInput("name")
|
|
4975
|
-
}
|
|
4976
|
-
)
|
|
4977
|
-
] }),
|
|
4978
|
-
supportSetType && /* @__PURE__ */ jsxs24("span", { className: "inline-flex h-8", children: [
|
|
4979
|
-
/* @__PURE__ */ jsxs24("span", { className: "sm:text-icontent border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-2", children: [
|
|
4980
|
-
"X-Axis Type",
|
|
4981
|
-
" ",
|
|
4982
|
-
/* @__PURE__ */ jsx34(
|
|
4983
|
-
PopoverTooltip,
|
|
4984
|
-
{
|
|
4985
|
-
strategy: "fixed",
|
|
4986
|
-
hideArrow: true,
|
|
4987
|
-
placementOption: "bottom",
|
|
4988
|
-
text: /* @__PURE__ */ jsxs24("div", { className: "text-text-foreground max-w-[300px] p-2", children: [
|
|
4989
|
-
/* @__PURE__ */ jsx34("span", { className: "font-medium", children: "Discrete axis" }),
|
|
4990
|
-
" displays",
|
|
4991
|
-
" ",
|
|
4992
|
-
/* @__PURE__ */ jsx34("span", { className: "text-primary-600", children: "discrete values evenly" }),
|
|
4993
|
-
", while ",
|
|
4994
|
-
/* @__PURE__ */ jsx34("span", { className: "font-medium", children: "Continuous axis" }),
|
|
4995
|
-
" ",
|
|
4996
|
-
"shows",
|
|
4997
|
-
" ",
|
|
4998
|
-
/* @__PURE__ */ jsx34("span", { className: "text-primary-600", children: "continuous time series" }),
|
|
4999
|
-
" ",
|
|
5000
|
-
"and",
|
|
5001
|
-
" ",
|
|
5002
|
-
/* @__PURE__ */ jsx34("span", { className: "text-primary-600", children: "auto-fills missing time points" })
|
|
5003
|
-
] }),
|
|
5004
|
-
children: /* @__PURE__ */ jsx34(LuInfo, { className: "text-text-foreground-secondary h-4 w-4" })
|
|
5005
|
-
}
|
|
5006
|
-
)
|
|
5007
|
-
] }),
|
|
5008
|
-
/* @__PURE__ */ jsx34(
|
|
5009
|
-
TypeSelect,
|
|
5010
|
-
{
|
|
5011
|
-
className: "h-8 w-40",
|
|
5012
|
-
buttonClassName: "h-full border-main rounded-l-none items-center inline-flex items-center",
|
|
5013
|
-
value: xAxis?.type || "time",
|
|
5014
|
-
onChange: (val) => {
|
|
5015
|
-
setXAxis({ ...xAxis, type: val });
|
|
5016
|
-
},
|
|
5017
|
-
options: [
|
|
5018
|
-
{ label: "Continuous", value: "time" },
|
|
5019
|
-
{ label: "Discrete", value: "category" }
|
|
5020
|
-
]
|
|
5021
|
-
}
|
|
5022
|
-
)
|
|
5023
|
-
] }),
|
|
5024
|
-
columnSelect && /* @__PURE__ */ jsxs24("span", { className: "inline-flex h-8", children: [
|
|
5025
|
-
/* @__PURE__ */ jsx34(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Column" }),
|
|
5026
|
-
columnSelect
|
|
5027
|
-
] }),
|
|
5028
|
-
supportSort && isXAixsNoneTime && /* @__PURE__ */ jsxs24("span", { className: "inline-flex h-8", children: [
|
|
5029
|
-
/* @__PURE__ */ jsx34(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Sort By" }),
|
|
5030
|
-
/* @__PURE__ */ jsx34(
|
|
5031
|
-
SortSelect,
|
|
5032
|
-
{
|
|
5033
|
-
className: "h-8 w-20 leading-8",
|
|
5034
|
-
buttonClassName: "h-full border-main rounded-none inline-flex items-center",
|
|
5035
|
-
options: sortByItems2,
|
|
5036
|
-
value: xAxis?.sort?.sortBy,
|
|
5037
|
-
onChange: (value) => {
|
|
5038
|
-
setXAxis({
|
|
5039
|
-
...xAxis,
|
|
5040
|
-
sort: { ...xAxis?.sort, sortBy: value }
|
|
5041
|
-
});
|
|
5042
|
-
},
|
|
5043
|
-
placeholder: "Sort By"
|
|
5044
|
-
}
|
|
5045
|
-
),
|
|
5046
|
-
/* @__PURE__ */ jsx34(
|
|
5047
|
-
OrderSelect,
|
|
5048
|
-
{
|
|
5049
|
-
className: "h-8 w-40 leading-8",
|
|
5050
|
-
buttonClassName: "h-full border-l-0 border-main rounded-l-none inline-flex items-center",
|
|
5051
|
-
options: orderItems2,
|
|
5052
|
-
value: xAxis?.sort?.orderDesc,
|
|
5053
|
-
onChange: (value) => {
|
|
5054
|
-
setXAxis({
|
|
5055
|
-
...xAxis,
|
|
5056
|
-
sort: { ...xAxis?.sort, orderDesc: value }
|
|
5057
|
-
});
|
|
5058
|
-
},
|
|
5059
|
-
placeholder: "Sort Order"
|
|
5060
|
-
}
|
|
5061
|
-
)
|
|
5062
|
-
] }),
|
|
5063
|
-
/* @__PURE__ */ jsx34(
|
|
5064
|
-
Button3,
|
|
5065
|
-
{
|
|
5066
|
-
type: "button",
|
|
5067
|
-
role: "link",
|
|
5068
|
-
onClick: onClickResetXAxis,
|
|
5069
|
-
className: "h-8",
|
|
5070
|
-
children: "Reset"
|
|
5071
|
-
}
|
|
5072
|
-
)
|
|
5073
|
-
] })
|
|
5074
|
-
}
|
|
5075
|
-
);
|
|
5076
|
-
};
|
|
5077
|
-
|
|
5078
6271
|
// src/charts/options/MarkerControls.tsx
|
|
5079
6272
|
import { produce as produce11 } from "immer";
|
|
5080
6273
|
import { LuMinus, LuPlus as LuPlus2 } from "react-icons/lu";
|
|
5081
6274
|
import { Button as Button4, DisclosurePanel as DisclosurePanel8 } from "@sentio/ui-core";
|
|
5082
|
-
import { jsx as
|
|
6275
|
+
import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5083
6276
|
var labelCls = "inline-flex items-center border border-r-0 sm:text-icontent border-main bg-gray-50 px-2 rounded-l-md";
|
|
5084
6277
|
var inputCls = "border focus:border-primary-500 rounded-r-md sm:text-icontent border-main w-28 hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30";
|
|
5085
6278
|
function MarkerInput({
|
|
@@ -5096,25 +6289,25 @@ function MarkerInput({
|
|
|
5096
6289
|
})
|
|
5097
6290
|
);
|
|
5098
6291
|
};
|
|
5099
|
-
return /* @__PURE__ */
|
|
5100
|
-
/* @__PURE__ */
|
|
5101
|
-
/* @__PURE__ */
|
|
5102
|
-
/* @__PURE__ */
|
|
5103
|
-
/* @__PURE__ */
|
|
6292
|
+
return /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-[10px]", children: [
|
|
6293
|
+
/* @__PURE__ */ jsxs26("label", { className: "inline-flex h-8", children: [
|
|
6294
|
+
/* @__PURE__ */ jsxs26("span", { className: labelCls, children: [
|
|
6295
|
+
/* @__PURE__ */ jsx36("span", { className: "pr-2", children: label }),
|
|
6296
|
+
/* @__PURE__ */ jsxs26(
|
|
5104
6297
|
"select",
|
|
5105
6298
|
{
|
|
5106
6299
|
className: "sm:text-ilabel border-main text-text-foreground inline-flex h-full items-center border border-b-0 border-t-0 bg-gray-50 p-0 pl-4 pr-7 focus:border-transparent focus:ring-inset",
|
|
5107
6300
|
value: marker.type,
|
|
5108
6301
|
onChange: (e) => _onChange("type", e.target.value),
|
|
5109
6302
|
children: [
|
|
5110
|
-
/* @__PURE__ */
|
|
5111
|
-
/* @__PURE__ */
|
|
6303
|
+
/* @__PURE__ */ jsx36("option", { value: "LINE", children: "horizontal line" }),
|
|
6304
|
+
/* @__PURE__ */ jsx36("option", { value: "LINEX", children: "vertical line" })
|
|
5112
6305
|
]
|
|
5113
6306
|
}
|
|
5114
6307
|
),
|
|
5115
|
-
/* @__PURE__ */
|
|
6308
|
+
/* @__PURE__ */ jsx36("span", { className: "pl-2", children: "at" })
|
|
5116
6309
|
] }),
|
|
5117
|
-
marker.type === "LINEX" ? /* @__PURE__ */
|
|
6310
|
+
marker.type === "LINEX" ? /* @__PURE__ */ jsx36(
|
|
5118
6311
|
"input",
|
|
5119
6312
|
{
|
|
5120
6313
|
className: inputCls,
|
|
@@ -5123,7 +6316,7 @@ function MarkerInput({
|
|
|
5123
6316
|
placeholder: "YYYY-MM-DD",
|
|
5124
6317
|
onChange: (e) => _onChange("valueX", e.target.value)
|
|
5125
6318
|
}
|
|
5126
|
-
) : /* @__PURE__ */
|
|
6319
|
+
) : /* @__PURE__ */ jsx36(
|
|
5127
6320
|
"input",
|
|
5128
6321
|
{
|
|
5129
6322
|
className: inputCls,
|
|
@@ -5133,11 +6326,11 @@ function MarkerInput({
|
|
|
5133
6326
|
}
|
|
5134
6327
|
)
|
|
5135
6328
|
] }),
|
|
5136
|
-
/* @__PURE__ */
|
|
5137
|
-
/* @__PURE__ */
|
|
5138
|
-
/* @__PURE__ */
|
|
5139
|
-
/* @__PURE__ */
|
|
5140
|
-
/* @__PURE__ */
|
|
6329
|
+
/* @__PURE__ */ jsxs26("label", { className: "inline-flex h-8", children: [
|
|
6330
|
+
/* @__PURE__ */ jsx36("span", { className: labelCls, children: "Color" }),
|
|
6331
|
+
/* @__PURE__ */ jsxs26("div", { className: "relative", children: [
|
|
6332
|
+
/* @__PURE__ */ jsx36("div", { className: "absolute inset-0 flex w-8 items-center justify-center", children: /* @__PURE__ */ jsx36("div", { className: "h-4 w-4", style: { background: marker.color } }) }),
|
|
6333
|
+
/* @__PURE__ */ jsx36(
|
|
5141
6334
|
"input",
|
|
5142
6335
|
{
|
|
5143
6336
|
className: inputCls + " pl-8",
|
|
@@ -5148,9 +6341,9 @@ function MarkerInput({
|
|
|
5148
6341
|
)
|
|
5149
6342
|
] })
|
|
5150
6343
|
] }),
|
|
5151
|
-
/* @__PURE__ */
|
|
5152
|
-
/* @__PURE__ */
|
|
5153
|
-
/* @__PURE__ */
|
|
6344
|
+
/* @__PURE__ */ jsxs26("label", { className: "inline-flex h-8", children: [
|
|
6345
|
+
/* @__PURE__ */ jsx36("span", { className: labelCls, children: "Label" }),
|
|
6346
|
+
/* @__PURE__ */ jsx36(
|
|
5154
6347
|
"input",
|
|
5155
6348
|
{
|
|
5156
6349
|
className: inputCls,
|
|
@@ -5160,14 +6353,14 @@ function MarkerInput({
|
|
|
5160
6353
|
}
|
|
5161
6354
|
)
|
|
5162
6355
|
] }),
|
|
5163
|
-
/* @__PURE__ */
|
|
6356
|
+
/* @__PURE__ */ jsx36(
|
|
5164
6357
|
"button",
|
|
5165
6358
|
{
|
|
5166
6359
|
type: "button",
|
|
5167
6360
|
className: "ml-2 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-gray-800 hover:bg-red-600",
|
|
5168
6361
|
"aria-label": "Remove marker",
|
|
5169
6362
|
onClick: onRemove,
|
|
5170
|
-
children: /* @__PURE__ */
|
|
6363
|
+
children: /* @__PURE__ */ jsx36(
|
|
5171
6364
|
LuMinus,
|
|
5172
6365
|
{
|
|
5173
6366
|
className: "dark:text-default-bg h-3 w-3 text-white",
|
|
@@ -5202,14 +6395,14 @@ function MarkerControls({ markers, onChange }) {
|
|
|
5202
6395
|
})
|
|
5203
6396
|
);
|
|
5204
6397
|
};
|
|
5205
|
-
return /* @__PURE__ */
|
|
6398
|
+
return /* @__PURE__ */ jsx36(
|
|
5206
6399
|
DisclosurePanel8,
|
|
5207
6400
|
{
|
|
5208
6401
|
title: "Markers",
|
|
5209
6402
|
containerClassName: "w-full bg-default-bg",
|
|
5210
6403
|
defaultOpen: true,
|
|
5211
|
-
children: /* @__PURE__ */
|
|
5212
|
-
_markers.map((marker, index) => /* @__PURE__ */
|
|
6404
|
+
children: /* @__PURE__ */ jsxs26("div", { className: "space-y-2", children: [
|
|
6405
|
+
_markers.map((marker, index) => /* @__PURE__ */ jsx36(
|
|
5213
6406
|
MarkerInput,
|
|
5214
6407
|
{
|
|
5215
6408
|
marker,
|
|
@@ -5219,8 +6412,8 @@ function MarkerControls({ markers, onChange }) {
|
|
|
5219
6412
|
},
|
|
5220
6413
|
index
|
|
5221
6414
|
)),
|
|
5222
|
-
/* @__PURE__ */
|
|
5223
|
-
/* @__PURE__ */
|
|
6415
|
+
/* @__PURE__ */ jsx36("div", { children: /* @__PURE__ */ jsxs26(Button4, { type: "button", onClick: onAdd, children: [
|
|
6416
|
+
/* @__PURE__ */ jsx36(LuPlus2, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
5224
6417
|
"Add Marker"
|
|
5225
6418
|
] }) })
|
|
5226
6419
|
] })
|
|
@@ -5230,9 +6423,9 @@ function MarkerControls({ markers, onChange }) {
|
|
|
5230
6423
|
|
|
5231
6424
|
// src/charts/options/DataControls.tsx
|
|
5232
6425
|
import { produce as produce12 } from "immer";
|
|
5233
|
-
import { defaults as
|
|
6426
|
+
import { defaults as defaults6 } from "lodash";
|
|
5234
6427
|
import { DisclosurePanel as DisclosurePanel9 } from "@sentio/ui-core";
|
|
5235
|
-
import { jsx as
|
|
6428
|
+
import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5236
6429
|
var defaultConfig5 = {
|
|
5237
6430
|
seriesLimit: void 0
|
|
5238
6431
|
};
|
|
@@ -5242,7 +6435,7 @@ function DataControls({
|
|
|
5242
6435
|
chartConfig,
|
|
5243
6436
|
defaultSeriesLimit = 20
|
|
5244
6437
|
}) {
|
|
5245
|
-
const config =
|
|
6438
|
+
const config = defaults6(chartConfig?.dataConfig, defaultConfig5);
|
|
5246
6439
|
const currentSeriesLimit = config?.seriesLimit || chartConfig?.tableConfig?.rowLimit;
|
|
5247
6440
|
function onSeriesLimitChange(e) {
|
|
5248
6441
|
const value = parseInt(e.target.value);
|
|
@@ -5260,15 +6453,15 @@ function DataControls({
|
|
|
5260
6453
|
e.preventDefault();
|
|
5261
6454
|
}
|
|
5262
6455
|
}
|
|
5263
|
-
return /* @__PURE__ */
|
|
6456
|
+
return /* @__PURE__ */ jsx37(
|
|
5264
6457
|
DisclosurePanel9,
|
|
5265
6458
|
{
|
|
5266
6459
|
title: "Data Options",
|
|
5267
6460
|
defaultOpen,
|
|
5268
6461
|
containerClassName: "w-full bg-default-bg",
|
|
5269
|
-
children: /* @__PURE__ */
|
|
5270
|
-
/* @__PURE__ */
|
|
5271
|
-
/* @__PURE__ */
|
|
6462
|
+
children: /* @__PURE__ */ jsxs27("div", { className: "flex h-8", children: [
|
|
6463
|
+
/* @__PURE__ */ jsx37(AddonLabel, { className: "rounded-l-md border border-r-0 px-3", children: "Max Series Limit" }),
|
|
6464
|
+
/* @__PURE__ */ jsx37(
|
|
5272
6465
|
"input",
|
|
5273
6466
|
{
|
|
5274
6467
|
type: "number",
|
|
@@ -5287,10 +6480,10 @@ function DataControls({
|
|
|
5287
6480
|
|
|
5288
6481
|
// src/charts/options/ScatterControls.tsx
|
|
5289
6482
|
import { produce as produce13 } from "immer";
|
|
5290
|
-
import { defaults as
|
|
5291
|
-
import { useCallback as
|
|
6483
|
+
import { defaults as defaults7 } from "lodash";
|
|
6484
|
+
import { useCallback as useCallback5 } from "react";
|
|
5292
6485
|
import { DisclosurePanel as DisclosurePanel10 } from "@sentio/ui-core";
|
|
5293
|
-
import { jsx as
|
|
6486
|
+
import { jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5294
6487
|
var defaultConfig6 = {
|
|
5295
6488
|
minSize: 5,
|
|
5296
6489
|
maxSize: 30
|
|
@@ -5302,57 +6495,57 @@ function ScatterControls({
|
|
|
5302
6495
|
columnSelect,
|
|
5303
6496
|
colorPicker
|
|
5304
6497
|
}) {
|
|
5305
|
-
config =
|
|
5306
|
-
const onSymbolSizeColumnChange =
|
|
6498
|
+
config = defaults7(config, defaultConfig6);
|
|
6499
|
+
const onSymbolSizeColumnChange = useCallback5(
|
|
5307
6500
|
(column) => {
|
|
5308
6501
|
config && onChange(produce13(config, (draft) => void (draft.symbolSize = column)));
|
|
5309
6502
|
},
|
|
5310
6503
|
[config, onChange]
|
|
5311
6504
|
);
|
|
5312
|
-
const onSymbolColorChange =
|
|
6505
|
+
const onSymbolColorChange = useCallback5(
|
|
5313
6506
|
(color) => {
|
|
5314
6507
|
config && onChange(produce13(config, (draft) => void (draft.color = color)));
|
|
5315
6508
|
},
|
|
5316
6509
|
[config, onChange]
|
|
5317
6510
|
);
|
|
5318
|
-
const onMinSizeChange =
|
|
6511
|
+
const onMinSizeChange = useCallback5(
|
|
5319
6512
|
(event) => {
|
|
5320
6513
|
const value = parseInt(event.target.value) || 5;
|
|
5321
6514
|
config && onChange(produce13(config, (draft) => void (draft.minSize = value)));
|
|
5322
6515
|
},
|
|
5323
6516
|
[config, onChange]
|
|
5324
6517
|
);
|
|
5325
|
-
const onMaxSizeChange =
|
|
6518
|
+
const onMaxSizeChange = useCallback5(
|
|
5326
6519
|
(event) => {
|
|
5327
6520
|
const value = parseInt(event.target.value) || 50;
|
|
5328
6521
|
config && onChange(produce13(config, (draft) => void (draft.maxSize = value)));
|
|
5329
6522
|
},
|
|
5330
6523
|
[config, onChange]
|
|
5331
6524
|
);
|
|
5332
|
-
return /* @__PURE__ */
|
|
6525
|
+
return /* @__PURE__ */ jsx38(
|
|
5333
6526
|
DisclosurePanel10,
|
|
5334
6527
|
{
|
|
5335
6528
|
title: "Scatter Chart Options",
|
|
5336
6529
|
defaultOpen,
|
|
5337
6530
|
containerClassName: "w-full bg-default-bg",
|
|
5338
|
-
children: /* @__PURE__ */
|
|
5339
|
-
columnSelect && /* @__PURE__ */
|
|
5340
|
-
/* @__PURE__ */
|
|
6531
|
+
children: /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-4", children: [
|
|
6532
|
+
columnSelect && /* @__PURE__ */ jsxs28("div", { className: "inline-flex h-8", children: [
|
|
6533
|
+
/* @__PURE__ */ jsx38(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Size By Column" }),
|
|
5341
6534
|
columnSelect({
|
|
5342
6535
|
value: config.symbolSize,
|
|
5343
6536
|
onChange: onSymbolSizeColumnChange
|
|
5344
6537
|
})
|
|
5345
6538
|
] }),
|
|
5346
|
-
colorPicker && /* @__PURE__ */
|
|
5347
|
-
/* @__PURE__ */
|
|
6539
|
+
colorPicker && /* @__PURE__ */ jsxs28("div", { className: "inline-flex h-8", children: [
|
|
6540
|
+
/* @__PURE__ */ jsx38(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Size Color Mapping" }),
|
|
5348
6541
|
colorPicker({
|
|
5349
6542
|
value: config.color,
|
|
5350
6543
|
onChange: onSymbolColorChange
|
|
5351
6544
|
})
|
|
5352
6545
|
] }),
|
|
5353
|
-
/* @__PURE__ */
|
|
5354
|
-
/* @__PURE__ */
|
|
5355
|
-
/* @__PURE__ */
|
|
6546
|
+
/* @__PURE__ */ jsxs28("div", { className: "inline-flex h-8", children: [
|
|
6547
|
+
/* @__PURE__ */ jsx38(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Min Size" }),
|
|
6548
|
+
/* @__PURE__ */ jsx38(
|
|
5356
6549
|
"input",
|
|
5357
6550
|
{
|
|
5358
6551
|
name: "minSize",
|
|
@@ -5365,9 +6558,9 @@ function ScatterControls({
|
|
|
5365
6558
|
}
|
|
5366
6559
|
)
|
|
5367
6560
|
] }),
|
|
5368
|
-
/* @__PURE__ */
|
|
5369
|
-
/* @__PURE__ */
|
|
5370
|
-
/* @__PURE__ */
|
|
6561
|
+
/* @__PURE__ */ jsxs28("div", { className: "inline-flex h-8", children: [
|
|
6562
|
+
/* @__PURE__ */ jsx38(AddonLabel, { className: "rounded-l-md border border-r-0 px-2", children: "Max Size" }),
|
|
6563
|
+
/* @__PURE__ */ jsx38(
|
|
5371
6564
|
"input",
|
|
5372
6565
|
{
|
|
5373
6566
|
name: "maxSize",
|
|
@@ -5422,6 +6615,7 @@ export {
|
|
|
5422
6615
|
ScatterIcon_default as ScatterIcon,
|
|
5423
6616
|
SystemLabels,
|
|
5424
6617
|
TableIcon_default as TableIcon,
|
|
6618
|
+
TimeSeriesChart,
|
|
5425
6619
|
ValueControls,
|
|
5426
6620
|
ValueFormatters,
|
|
5427
6621
|
ValueOptions,
|