@flexem/fc-gui 3.0.0-alpha.103 → 3.0.0-alpha.104

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.
@@ -24,9 +24,7 @@ export class RingGraphElement extends ReadableElement {
24
24
  this._barElement$ = el$.find('path[data-id="barArc"]');
25
25
  this._textElement$ = el$.find('text[data-id="pText"]');
26
26
  setTimeout(() => {
27
- if (this.model.minValueType !== VariableValueType.Variable) {
28
- this.initFrameNode();
29
- }
27
+ this.initFrameNode();
30
28
  this.changeStates();
31
29
  });
32
30
  }
@@ -60,12 +58,12 @@ export class RingGraphElement extends ReadableElement {
60
58
  const variable = new VariableDefinition(this.model.maxVariable.name, this.model.maxVariable.groupName, this.model.maxVariable.dataSourceCode, this.model.maxVariable.variableVersion);
61
59
  return VariableUtil.getConvertedVariableName(this.variableStore, variable);
62
60
  }
63
- initTransformFun() {
64
- if (this.needAddNumber <= 3)
65
- return;
61
+ initTransformFun(len) {
66
62
  this.$element[0].childNodes.forEach((node) => {
67
- const matrixE = node.transform.baseVal[0].matrix.e;
68
- node.transform.baseVal[0].matrix.e = matrixE + (this.needAddNumber - 3) * 5;
63
+ if (!node.transform.baseVal[0])
64
+ return;
65
+ // const matrixE = node.transform.baseVal[0].matrix.e;
66
+ // node.transform.baseVal[0].matrix.e = matrixE + len * 5;
69
67
  if (node.nodeName === 'g') {
70
68
  const nodeValue = node.attributes['clip-path'].value.replace('url(#', '').replace(')', '');
71
69
  const rootNode = node.parentNode.parentNode.parentElement;
@@ -77,8 +75,8 @@ export class RingGraphElement extends ReadableElement {
77
75
  const values = [];
78
76
  line.split(' ').forEach((item) => {
79
77
  const nItem = Number(item);
80
- if (!isNaN(nItem) && (index === 1 || nItem === -1)) {
81
- item = nItem > 0 ? nItem + (this.needAddNumber - 3) * 8 : nItem - (this.needAddNumber - 3) * 8;
78
+ if (!isNaN(nItem) && (index === 1 || index === 2 || nItem === -1)) {
79
+ item = nItem > 0 ? (index === 1 || index === 2 ? nItem + (len + 2) * 8 : nItem + len * 8) : nItem - len * 8;
82
80
  }
83
81
  values.push(item);
84
82
  });
@@ -91,8 +89,7 @@ export class RingGraphElement extends ReadableElement {
91
89
  initFrameNode() {
92
90
  const arcPath = Snap(this.$element[0]);
93
91
  const b = arcPath.getBBox(true);
94
- const width = this.needAddNumber <= 3 ? b.width : b.width + (this.needAddNumber - 3) * 8;
95
- this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', width).attr('height', b.height).attr('fill', 'transparent');
92
+ this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', b.width).attr('height', b.height).attr('fill', 'transparent');
96
93
  }
97
94
  init(variableName) {
98
95
  if (variableName) {
@@ -124,7 +121,6 @@ export class RingGraphElement extends ReadableElement {
124
121
  }
125
122
  updateScale() {
126
123
  // 刻度模糊问题
127
- let isInitTransform = false;
128
124
  const matrix = this.$element[0].transform.baseVal[0].matrix;
129
125
  if (!this.$element[0].style.transform) {
130
126
  this.$element[0].style.transform = `translate3d(${matrix.e}px, ${matrix.f}px, 0)`;
@@ -141,11 +137,13 @@ export class RingGraphElement extends ReadableElement {
141
137
  min = RingGraphElement.DEFAULT_MIN_VALUE;
142
138
  max = RingGraphElement.DEFAULT_MAX_VALUE;
143
139
  }
144
- if (this.model.minValueType === VariableValueType.Variable) {
145
- this.needAddNumber = max.toString().length > min.toString().length ? max.toString().length : min.toString().length;
146
- if (!this.initTransform) {
147
- this.initTransformFun();
148
- this.initFrameNode();
140
+ if (this.model.minValueType === VariableValueType.Variable || this.model.maxValueType === VariableValueType.Variable) {
141
+ const len = max.toString().length > min.toString().length ? max.toString().length : min.toString().length;
142
+ if (Math.abs(len - this.needAddNumber) > 2) {
143
+ const width = this.$element.find('rect').attr('width');
144
+ this.$element.find('rect').attr('width', Number(width) + (len - this.needAddNumber) * 8);
145
+ this.initTransformFun(Math.abs(len - this.needAddNumber));
146
+ this.needAddNumber = len;
149
147
  }
150
148
  }
151
149
  const avgSacle = ((max - min) / this.model.masterDivisionNumber).toFixed(5);
@@ -160,18 +158,23 @@ export class RingGraphElement extends ReadableElement {
160
158
  sacleValue = (sacleValue / Math.pow(10, this.model.fractionDigits)).toFixed(this.model.fractionDigits);
161
159
  }
162
160
  if (!isNaN(sacleValue)) {
161
+ const oriValue = text.innerHTML;
163
162
  text.innerHTML = sacleValue;
164
- isInitTransform = true;
165
163
  if (this.model.minValueType !== VariableValueType.Constant || this.model.maxValueType !== VariableValueType.Constant) {
166
164
  // FLEXCLOUD-2619 刻度显示不全问题
167
165
  const order = (i + 1) / textElements.length;
168
- if (!this.initTransform && order > 0.7 && sacleValue.toString().length > 3) {
169
- text.transform.baseVal[0].matrix.e -= (sacleValue.toString().length - 3) * 5;
166
+ const len = oriValue.toString().length - sacleValue.toString().length;
167
+ if (order <= 0.7 && len > 1 && !this.initTransform) {
168
+ text.transform.baseVal[0].matrix.e += (len - 1) * 5;
169
+ }
170
+ if (order > 0.7 && Math.abs(len) > 0) {
171
+ text.transform.baseVal[0].matrix.e += len > 1 ? (len - 1) * 5 : len < -1 ? (len + 1) * 5 : len * 5;
172
+ text.transform.baseVal[0].matrix.e += len === -2 ? -3 : 0;
170
173
  }
171
174
  }
172
175
  }
173
176
  }
174
- this.initTransform = this.initTransform || isInitTransform;
177
+ this.initTransform = true;
175
178
  }
176
179
  updateVariableValue(value, variableName) {
177
180
  this.updateValueObj(value, variableName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.103",
3
+ "version": "3.0.0-alpha.104",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",