@ecan-bi/datav 1.0.52 → 1.0.53

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.es.js CHANGED
@@ -3206,11 +3206,12 @@ const proportionProps = __spreadProps(__spreadValues({}, props), {
3206
3206
  strokeWidth: 6,
3207
3207
  fontWeight: 400,
3208
3208
  strokeTextWidth: "100%",
3209
- lineHeight: "26px"
3209
+ lineHeight: "26px",
3210
+ decimalFormat: false
3210
3211
  });
3211
3212
  const proportionComponentProps = transformToComponentProps(proportionProps);
3212
3213
  const proportionEvents = ["refreshData", "click"];
3213
- var Proportion_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".ecan-proportion[data-v-206755e6] {\n overflow: hidden;\n}\n.progress[data-v-206755e6] {\n width: 100%;\n height: 100%;\n}\n.format[data-v-206755e6] {\n margin: 0 auto;\n}\n")();
3214
+ var Proportion_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".ecan-proportion[data-v-f55c66cc] {\n overflow: hidden;\n}\n.progress[data-v-f55c66cc] {\n width: 100%;\n height: 100%;\n}\n.format[data-v-f55c66cc] {\n margin: 0 auto;\n}\n")();
3214
3215
  const _sfc_main$h = defineComponent({
3215
3216
  name: "EcanProportion",
3216
3217
  components: {
@@ -3224,41 +3225,55 @@ const _sfc_main$h = defineComponent({
3224
3225
  const width = props2.width;
3225
3226
  return parseFloat(width);
3226
3227
  });
3227
- const myData = ref(props2.data);
3228
+ const myData = ref({});
3229
+ watch(() => props2.data, () => {
3230
+ if (props2.dataType === "static" || unref(pageMode) === "design") {
3231
+ myData.value = props2.data;
3232
+ }
3233
+ }, {
3234
+ immediate: true,
3235
+ deep: true
3236
+ });
3228
3237
  const defaultValue = 0;
3229
3238
  const value = computed(() => {
3230
- var _a2;
3231
3239
  const data = unref(myData);
3232
3240
  if (data == null)
3233
3241
  return defaultValue;
3234
3242
  const values = Object.values(data);
3235
- return ((_a2 = values[0]) != null ? _a2 : 0) * 100;
3236
- });
3237
- const useValueKey = computed(() => {
3238
- const data = unref(myData) || {};
3239
- return Object.keys(data)[0];
3243
+ const value2 = values[0] * 100;
3244
+ if (!isNaN(value2)) {
3245
+ return props2.decimalFormat ? value2.toFixed(2) : value2;
3246
+ }
3247
+ return 0;
3240
3248
  });
3241
3249
  const text = computed(() => {
3242
- var _a2;
3243
3250
  let text2 = props2.text;
3244
3251
  const data = unref(myData);
3245
- const variables = text2.match(/\{\w*\}/g) || [];
3252
+ const variables = text2.match(/\{.*\}/g) || [];
3253
+ console.log("variables", variables);
3246
3254
  if (text2 === "")
3247
3255
  return unref(value) + "%";
3248
3256
  for (let i = 0; i < variables.length; i++) {
3249
3257
  const variable = variables[i];
3250
- const v = variable.slice(1, variable.length - 1);
3251
- let usedVariable = "";
3252
- if (unref(useValueKey) === v) {
3253
- usedVariable = unref(value).toFixed(2);
3254
- } else {
3255
- usedVariable = (_a2 = data[v]) != null ? _a2 : defaultValue;
3258
+ let statement = variable.slice(1, variable.length - 1);
3259
+ const textVariables = statement.match(/[a-zA-Z]\w*/g);
3260
+ console.log("textVariables", textVariables);
3261
+ for (let j = 0; j < textVariables.length; j++) {
3262
+ const textVariable = textVariables[i];
3263
+ if (data[textVariable] != null) {
3264
+ statement = statement.replace(textVariable, data[textVariable]);
3265
+ }
3256
3266
  }
3257
- if (usedVariable != null) {
3258
- text2 = text2.replace(variable, usedVariable);
3259
- } else {
3260
- text2 = text2.replace(variable, "");
3267
+ console.log("statement", statement);
3268
+ let usedVariable;
3269
+ if (/[+\-*/%]+/g.test(statement)) {
3270
+ const eval2 = eval;
3271
+ usedVariable = eval2(statement);
3272
+ }
3273
+ if (props2.decimalFormat) {
3274
+ usedVariable = usedVariable == null ? void 0 : usedVariable.toFixed(2);
3261
3275
  }
3276
+ text2 = text2.replace(variable, usedVariable + "");
3262
3277
  }
3263
3278
  return text2;
3264
3279
  });
@@ -3343,7 +3358,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
3343
3358
  }, 8, ["percent", "width", "type", "strokeColor", "strokeLinecap", "trailColor", "strokeWidth", "gapDegree", "onClick"])
3344
3359
  ], 4);
3345
3360
  }
3346
- var Proportion = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h], ["__scopeId", "data-v-206755e6"]]);
3361
+ var Proportion = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h], ["__scopeId", "data-v-f55c66cc"]]);
3347
3362
  const EcanProportion = withInstall(Proportion);
3348
3363
  const inputProps = __spreadProps(__spreadValues({}, props), {
3349
3364
  width: "200px",