@operato/chart 7.0.2 → 7.0.5
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/CHANGELOG.md +19 -0
- package/dist/src/chartjs/config-converter.js +1 -1
- package/dist/src/chartjs/config-converter.js.map +1 -1
- package/dist/src/chartjs/ox-chart-js.js +1 -1
- package/dist/src/chartjs/ox-chart-js.js.map +1 -1
- package/dist/src/editors/ox-property-editor-chart.js +1 -1
- package/dist/src/editors/ox-property-editor-chart.js.map +1 -1
- package/dist/src/progress/ox-progress-circle.d.ts +1 -1
- package/dist/src/progress/ox-progress-circle.js +1 -1
- package/dist/src/progress/ox-progress-circle.js.map +1 -1
- package/dist/src/scichart/ox-scichart.d.ts +0 -2
- package/dist/src/scichart/ox-scichart.js +1 -41
- package/dist/src/scichart/ox-scichart.js.map +1 -1
- package/dist/src/scichart/scichart-builder.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -8
- package/src/chartjs/config-converter.ts +1 -1
- package/src/chartjs/ox-chart-js.ts +1 -1
- package/src/editors/ox-property-editor-chart.ts +1 -1
- package/src/progress/ox-progress-circle.ts +1 -1
- package/src/scichart/ox-scichart.ts +1 -40
- package/src/scichart/scichart-builder.ts +1 -1
- package/dist/src/utils/text-formatter.d.ts +0 -1
- package/dist/src/utils/text-formatter.js +0 -78
- package/dist/src/utils/text-formatter.js.map +0 -1
- package/src/scichart/custom-point-markers.ts.xxx +0 -178
- package/src/utils/text-formatter.ts +0 -106
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export function format(mask, value) {
|
|
2
|
-
if (!mask || isNaN(+value)) {
|
|
3
|
-
return value.toString(); // return as it is.
|
|
4
|
-
}
|
|
5
|
-
let isNegative, result, decimal, group, posLeadZero, posTrailZero, posSeparator, part, szSep, integer,
|
|
6
|
-
// find prefix/suffix
|
|
7
|
-
len = mask.length, start = mask.search(/[0-9\-\+#]/), prefix = start > 0 ? mask.substring(0, start) : '',
|
|
8
|
-
// reverse string: not an ideal method if there are surrogate pairs
|
|
9
|
-
str = mask.split('').reverse().join(''), end = str.search(/[0-9\-\+#]/), offset = len - end, substr = mask.substring(offset, offset + 1), indx = offset + (substr === '.' || substr === ',' ? 1 : 0), suffix = end > 0 ? mask.substring(indx, len) : '', splittedMask, splittedValue, stringValue;
|
|
10
|
-
// mask with prefix & suffix removed
|
|
11
|
-
mask = mask.substring(start, indx);
|
|
12
|
-
// convert any string to number according to formation sign.
|
|
13
|
-
value = mask.charAt(0) === '-' ? -value : +value;
|
|
14
|
-
isNegative = value < 0 ? ((value = -value), true) : false; // process only abs(), and turn on flag.
|
|
15
|
-
// search for separator for grp & decimal, anything not digit, not +/- sign, not #.
|
|
16
|
-
result = mask.match(/[^\d\-\+#]/g);
|
|
17
|
-
decimal = '.'; // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함
|
|
18
|
-
group = (result && result[1] && result[0]) || ','; // treat the left most symbol as group separator
|
|
19
|
-
// split the decimal for the format string if any.
|
|
20
|
-
splittedMask = mask.split(decimal);
|
|
21
|
-
// Fix the decimal first, toFixed will auto fill trailing zero.
|
|
22
|
-
value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0));
|
|
23
|
-
stringValue = +value + ''; // convert number to string to trim off *all* trailing decimal zero(es)
|
|
24
|
-
// fill back any trailing zero according to format
|
|
25
|
-
posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0; // look for last zero in format
|
|
26
|
-
part = stringValue.split('.');
|
|
27
|
-
// integer will get !part[1]
|
|
28
|
-
if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {
|
|
29
|
-
stringValue = (+value).toFixed(posTrailZero + 1);
|
|
30
|
-
}
|
|
31
|
-
szSep = splittedMask[0].split(group); // look for separator
|
|
32
|
-
splittedMask[0] = szSep.join(''); // join back without separator for counting the pos of any leading 0.
|
|
33
|
-
posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0;
|
|
34
|
-
if (posLeadZero > -1) {
|
|
35
|
-
while (part[0].length < splittedMask[0].length - posLeadZero) {
|
|
36
|
-
part[0] = '0' + part[0];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (+part[0] === 0) {
|
|
40
|
-
part[0] = '';
|
|
41
|
-
}
|
|
42
|
-
splittedValue = stringValue.split('.');
|
|
43
|
-
splittedValue[0] = part[0];
|
|
44
|
-
// process the first group separator from decimal (.) only, the rest ignore.
|
|
45
|
-
// get the length of the last slice of split result.
|
|
46
|
-
posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0;
|
|
47
|
-
if (posSeparator) {
|
|
48
|
-
integer = splittedValue[0];
|
|
49
|
-
str = '';
|
|
50
|
-
offset = integer.length % posSeparator;
|
|
51
|
-
len = integer.length;
|
|
52
|
-
for (indx = 0; indx < len; indx++) {
|
|
53
|
-
str += integer.charAt(indx); // ie6 only support charAt for sz.
|
|
54
|
-
// -posSeparator so that won't trail separator on full length
|
|
55
|
-
/* jshint -W018 */
|
|
56
|
-
if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {
|
|
57
|
-
str += group;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
splittedValue[0] = str;
|
|
61
|
-
}
|
|
62
|
-
splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : '';
|
|
63
|
-
// remove negative sign if result is zero
|
|
64
|
-
result = splittedValue.join('');
|
|
65
|
-
if (result === '0' || result === '') {
|
|
66
|
-
// remove negative sign if result is zero
|
|
67
|
-
isNegative = false;
|
|
68
|
-
}
|
|
69
|
-
// 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌
|
|
70
|
-
let fixedPlusSign;
|
|
71
|
-
if (splittedMask[0].substring(0, 1) === '+')
|
|
72
|
-
fixedPlusSign = isNegative ? '-' : '+';
|
|
73
|
-
else
|
|
74
|
-
fixedPlusSign = isNegative ? '-' : '';
|
|
75
|
-
// put back any negation, combine integer and fraction, and add back prefix & suffix
|
|
76
|
-
return prefix + (fixedPlusSign + result) + suffix;
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=text-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-formatter.js","sourceRoot":"","sources":["../../../src/utils/text-formatter.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,KAAa;IAChD,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA,CAAC,mBAAmB;IAC7C,CAAC;IAED,IAAI,UAAmB,EACrB,MAAwC,EACxC,OAAe,EACf,KAAa,EACb,WAAmB,EACnB,YAAoB,EACpB,YAAoB,EACpB,IAAc,EACd,KAAe,EACf,OAAe;IACf,qBAAqB;IACrB,GAAG,GAAG,IAAI,CAAC,MAAM,EACjB,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EACjC,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;IAClD,mEAAmE;IACnE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EACvC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,EAC9B,MAAM,GAAG,GAAG,GAAG,GAAG,EAClB,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,EAC3C,IAAI,GAAG,MAAM,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D,MAAM,GAAG,GAAG,GAAG,CAAC,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CAAC,EAAE,CAAC,CAAC,KAAK,GAAG;QAAE,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;;QAC9E,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAE1C,oFAAoF;IACpF,OAAO,MAAM,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;AACnD,CAAC","sourcesContent":["export function format(mask: string, value: number): string {\n if (!mask || isNaN(+value)) {\n return value.toString() // return as it is.\n }\n\n let isNegative: boolean,\n result: string | RegExpMatchArray | null,\n decimal: string,\n group: string,\n posLeadZero: number,\n posTrailZero: number,\n posSeparator: number,\n part: string[],\n szSep: string[],\n integer: string,\n // find prefix/suffix\n len = mask.length,\n start = mask.search(/[0-9\\-\\+#]/),\n prefix = start > 0 ? mask.substring(0, start) : '',\n // reverse string: not an ideal method if there are surrogate pairs\n str = mask.split('').reverse().join(''),\n end = str.search(/[0-9\\-\\+#]/),\n offset = len - end,\n substr = mask.substring(offset, offset + 1),\n indx = offset + (substr === '.' || substr === ',' ? 1 : 0),\n suffix = end > 0 ? mask.substring(indx, len) : '',\n splittedMask: string[],\n splittedValue: string[],\n stringValue: string\n\n // mask with prefix & suffix removed\n mask = mask.substring(start, indx)\n\n // convert any string to number according to formation sign.\n value = mask.charAt(0) === '-' ? -value : +value\n isNegative = value < 0 ? ((value = -value), true) : false // process only abs(), and turn on flag.\n\n // search for separator for grp & decimal, anything not digit, not +/- sign, not #.\n result = mask.match(/[^\\d\\-\\+#]/g)\n decimal = '.' // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함\n group = (result && result[1] && result[0]) || ',' // treat the left most symbol as group separator\n\n // split the decimal for the format string if any.\n splittedMask = mask.split(decimal)\n // Fix the decimal first, toFixed will auto fill trailing zero.\n value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0))\n stringValue = +value + '' // convert number to string to trim off *all* trailing decimal zero(es)\n\n // fill back any trailing zero according to format\n posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0 // look for last zero in format\n part = stringValue.split('.')\n // integer will get !part[1]\n if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {\n stringValue = (+value).toFixed(posTrailZero + 1)\n }\n szSep = splittedMask[0].split(group) // look for separator\n splittedMask[0] = szSep.join('') // join back without separator for counting the pos of any leading 0.\n\n posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0\n if (posLeadZero > -1) {\n while (part[0].length < splittedMask[0].length - posLeadZero) {\n part[0] = '0' + part[0]\n }\n } else if (+part[0] === 0) {\n part[0] = ''\n }\n\n splittedValue = stringValue.split('.')\n splittedValue[0] = part[0]\n\n // process the first group separator from decimal (.) only, the rest ignore.\n // get the length of the last slice of split result.\n posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0\n if (posSeparator) {\n integer = splittedValue[0]\n str = ''\n offset = integer.length % posSeparator\n len = integer.length\n for (indx = 0; indx < len; indx++) {\n str += integer.charAt(indx) // ie6 only support charAt for sz.\n // -posSeparator so that won't trail separator on full length\n /* jshint -W018 */\n if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {\n str += group\n }\n }\n splittedValue[0] = str\n }\n splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : ''\n\n // remove negative sign if result is zero\n result = splittedValue.join('')\n if (result === '0' || result === '') {\n // remove negative sign if result is zero\n isNegative = false\n }\n\n // 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌\n let fixedPlusSign: string\n\n if (splittedMask[0].substring(0, 1) === '+') fixedPlusSign = isNegative ? '-' : '+'\n else fixedPlusSign = isNegative ? '-' : ''\n\n // put back any negation, combine integer and fraction, and add back prefix & suffix\n return prefix + (fixedPlusSign + result) + suffix\n}\n"]}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { BasePointMarker, TSciChart, IRenderableSeries, EPointMarkerType } from 'scichart'
|
|
2
|
-
|
|
3
|
-
interface PointMarkerOptions {
|
|
4
|
-
width?: number
|
|
5
|
-
height?: number
|
|
6
|
-
strokeThickness?: number
|
|
7
|
-
fill?: string
|
|
8
|
-
stroke?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
abstract class CustomPointMarker extends BasePointMarker {
|
|
12
|
-
private _width: number
|
|
13
|
-
private _height: number
|
|
14
|
-
private _strokeThickness: number
|
|
15
|
-
private _fill: string
|
|
16
|
-
private _stroke: string
|
|
17
|
-
|
|
18
|
-
constructor(wasmContext: TSciChart, options: PointMarkerOptions = {}) {
|
|
19
|
-
super(wasmContext)
|
|
20
|
-
this._width = options.width ?? 10
|
|
21
|
-
this._height = options.height ?? 10
|
|
22
|
-
this._strokeThickness = options.strokeThickness ?? 2
|
|
23
|
-
this._fill = options.fill ?? '#FF6600'
|
|
24
|
-
this._stroke = options.stroke ?? '#000000'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get width(): number {
|
|
28
|
-
return this._width
|
|
29
|
-
}
|
|
30
|
-
set width(value: number) {
|
|
31
|
-
this._width = value
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get height(): number {
|
|
35
|
-
return this._height
|
|
36
|
-
}
|
|
37
|
-
set height(value: number) {
|
|
38
|
-
this._height = value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get strokeThickness(): number {
|
|
42
|
-
return this._strokeThickness
|
|
43
|
-
}
|
|
44
|
-
set strokeThickness(value: number) {
|
|
45
|
-
this._strokeThickness = value
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get fill(): string {
|
|
49
|
-
return this._fill
|
|
50
|
-
}
|
|
51
|
-
set fill(value: string) {
|
|
52
|
-
this._fill = value
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get stroke(): string {
|
|
56
|
-
return this._stroke
|
|
57
|
-
}
|
|
58
|
-
set stroke(value: string) {
|
|
59
|
-
this._stroke = value
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get type(): EPointMarkerType {
|
|
63
|
-
return EPointMarkerType.Custom
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
drawSprite(
|
|
67
|
-
context: CanvasRenderingContext2D,
|
|
68
|
-
x: number,
|
|
69
|
-
y: number,
|
|
70
|
-
stroke: string,
|
|
71
|
-
dpiAdjustedStrokeThickness: number,
|
|
72
|
-
fill: string
|
|
73
|
-
): void {
|
|
74
|
-
this.draw(context, null as any, x, y)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
abstract draw(
|
|
78
|
-
context: CanvasRenderingContext2D,
|
|
79
|
-
renderableSeries: IRenderableSeries,
|
|
80
|
-
xCoord: number,
|
|
81
|
-
yCoord: number
|
|
82
|
-
): void
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Rotated Square Point Marker
|
|
86
|
-
export class RotatedSquarePointMarker extends CustomPointMarker {
|
|
87
|
-
draw(context: CanvasRenderingContext2D, renderableSeries: IRenderableSeries, xCoord: number, yCoord: number): void {
|
|
88
|
-
context.save()
|
|
89
|
-
context.translate(xCoord, yCoord)
|
|
90
|
-
context.rotate(Math.PI / 4) // 45 degrees rotation
|
|
91
|
-
context.fillStyle = this.fill
|
|
92
|
-
context.strokeStyle = this.stroke
|
|
93
|
-
context.lineWidth = this.strokeThickness
|
|
94
|
-
context.beginPath()
|
|
95
|
-
context.rect(-this.width / 2, -this.height / 2, this.width, this.height)
|
|
96
|
-
context.fill()
|
|
97
|
-
context.stroke()
|
|
98
|
-
context.restore()
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Cross Rot Point Marker
|
|
103
|
-
export class CrossRotPointMarker extends CustomPointMarker {
|
|
104
|
-
draw(context: CanvasRenderingContext2D, renderableSeries: IRenderableSeries, xCoord: number, yCoord: number): void {
|
|
105
|
-
context.save()
|
|
106
|
-
context.translate(xCoord, yCoord)
|
|
107
|
-
context.rotate(Math.PI / 4) // 45 degrees rotation
|
|
108
|
-
context.strokeStyle = this.stroke
|
|
109
|
-
context.lineWidth = this.strokeThickness
|
|
110
|
-
context.beginPath()
|
|
111
|
-
context.moveTo(-this.width / 2, 0)
|
|
112
|
-
context.lineTo(this.width / 2, 0)
|
|
113
|
-
context.moveTo(0, -this.height / 2)
|
|
114
|
-
context.lineTo(0, this.height / 2)
|
|
115
|
-
context.stroke()
|
|
116
|
-
context.restore()
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Star Point Marker
|
|
121
|
-
export class StarPointMarker extends CustomPointMarker {
|
|
122
|
-
draw(context: CanvasRenderingContext2D, renderableSeries: IRenderableSeries, xCoord: number, yCoord: number): void {
|
|
123
|
-
const spikes = 5
|
|
124
|
-
const outerRadius = this.width / 2
|
|
125
|
-
const innerRadius = outerRadius / 2
|
|
126
|
-
context.save()
|
|
127
|
-
context.translate(xCoord, yCoord)
|
|
128
|
-
context.fillStyle = this.fill
|
|
129
|
-
context.strokeStyle = this.stroke
|
|
130
|
-
context.lineWidth = this.strokeThickness
|
|
131
|
-
context.beginPath()
|
|
132
|
-
for (let i = 0; i < spikes; i++) {
|
|
133
|
-
context.lineTo(
|
|
134
|
-
Math.cos((i * 2 * Math.PI) / spikes) * outerRadius,
|
|
135
|
-
Math.sin((i * 2 * Math.PI) / spikes) * outerRadius
|
|
136
|
-
)
|
|
137
|
-
context.lineTo(
|
|
138
|
-
Math.cos(((i * 2 + 1) * Math.PI) / spikes) * innerRadius,
|
|
139
|
-
Math.sin(((i * 2 + 1) * Math.PI) / spikes) * innerRadius
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
context.closePath()
|
|
143
|
-
context.fill()
|
|
144
|
-
context.stroke()
|
|
145
|
-
context.restore()
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Line Point Marker
|
|
150
|
-
export class LinePointMarker extends CustomPointMarker {
|
|
151
|
-
draw(context: CanvasRenderingContext2D, renderableSeries: IRenderableSeries, xCoord: number, yCoord: number): void {
|
|
152
|
-
context.save()
|
|
153
|
-
context.translate(xCoord, yCoord)
|
|
154
|
-
context.strokeStyle = this.stroke
|
|
155
|
-
context.lineWidth = this.strokeThickness
|
|
156
|
-
context.beginPath()
|
|
157
|
-
context.moveTo(-this.width / 2, 0)
|
|
158
|
-
context.lineTo(this.width / 2, 0)
|
|
159
|
-
context.stroke()
|
|
160
|
-
context.restore()
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Dash Point Marker
|
|
165
|
-
export class DashPointMarker extends CustomPointMarker {
|
|
166
|
-
draw(context: CanvasRenderingContext2D, renderableSeries: IRenderableSeries, xCoord: number, yCoord: number): void {
|
|
167
|
-
context.save()
|
|
168
|
-
context.translate(xCoord, yCoord)
|
|
169
|
-
context.strokeStyle = this.stroke
|
|
170
|
-
context.lineWidth = this.strokeThickness
|
|
171
|
-
context.setLineDash([this.width / 4, this.width / 4])
|
|
172
|
-
context.beginPath()
|
|
173
|
-
context.moveTo(-this.width / 2, 0)
|
|
174
|
-
context.lineTo(this.width / 2, 0)
|
|
175
|
-
context.stroke()
|
|
176
|
-
context.restore()
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export function format(mask: string, value: number): string {
|
|
2
|
-
if (!mask || isNaN(+value)) {
|
|
3
|
-
return value.toString() // return as it is.
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
let isNegative: boolean,
|
|
7
|
-
result: string | RegExpMatchArray | null,
|
|
8
|
-
decimal: string,
|
|
9
|
-
group: string,
|
|
10
|
-
posLeadZero: number,
|
|
11
|
-
posTrailZero: number,
|
|
12
|
-
posSeparator: number,
|
|
13
|
-
part: string[],
|
|
14
|
-
szSep: string[],
|
|
15
|
-
integer: string,
|
|
16
|
-
// find prefix/suffix
|
|
17
|
-
len = mask.length,
|
|
18
|
-
start = mask.search(/[0-9\-\+#]/),
|
|
19
|
-
prefix = start > 0 ? mask.substring(0, start) : '',
|
|
20
|
-
// reverse string: not an ideal method if there are surrogate pairs
|
|
21
|
-
str = mask.split('').reverse().join(''),
|
|
22
|
-
end = str.search(/[0-9\-\+#]/),
|
|
23
|
-
offset = len - end,
|
|
24
|
-
substr = mask.substring(offset, offset + 1),
|
|
25
|
-
indx = offset + (substr === '.' || substr === ',' ? 1 : 0),
|
|
26
|
-
suffix = end > 0 ? mask.substring(indx, len) : '',
|
|
27
|
-
splittedMask: string[],
|
|
28
|
-
splittedValue: string[],
|
|
29
|
-
stringValue: string
|
|
30
|
-
|
|
31
|
-
// mask with prefix & suffix removed
|
|
32
|
-
mask = mask.substring(start, indx)
|
|
33
|
-
|
|
34
|
-
// convert any string to number according to formation sign.
|
|
35
|
-
value = mask.charAt(0) === '-' ? -value : +value
|
|
36
|
-
isNegative = value < 0 ? ((value = -value), true) : false // process only abs(), and turn on flag.
|
|
37
|
-
|
|
38
|
-
// search for separator for grp & decimal, anything not digit, not +/- sign, not #.
|
|
39
|
-
result = mask.match(/[^\d\-\+#]/g)
|
|
40
|
-
decimal = '.' // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함
|
|
41
|
-
group = (result && result[1] && result[0]) || ',' // treat the left most symbol as group separator
|
|
42
|
-
|
|
43
|
-
// split the decimal for the format string if any.
|
|
44
|
-
splittedMask = mask.split(decimal)
|
|
45
|
-
// Fix the decimal first, toFixed will auto fill trailing zero.
|
|
46
|
-
value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0))
|
|
47
|
-
stringValue = +value + '' // convert number to string to trim off *all* trailing decimal zero(es)
|
|
48
|
-
|
|
49
|
-
// fill back any trailing zero according to format
|
|
50
|
-
posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0 // look for last zero in format
|
|
51
|
-
part = stringValue.split('.')
|
|
52
|
-
// integer will get !part[1]
|
|
53
|
-
if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {
|
|
54
|
-
stringValue = (+value).toFixed(posTrailZero + 1)
|
|
55
|
-
}
|
|
56
|
-
szSep = splittedMask[0].split(group) // look for separator
|
|
57
|
-
splittedMask[0] = szSep.join('') // join back without separator for counting the pos of any leading 0.
|
|
58
|
-
|
|
59
|
-
posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0
|
|
60
|
-
if (posLeadZero > -1) {
|
|
61
|
-
while (part[0].length < splittedMask[0].length - posLeadZero) {
|
|
62
|
-
part[0] = '0' + part[0]
|
|
63
|
-
}
|
|
64
|
-
} else if (+part[0] === 0) {
|
|
65
|
-
part[0] = ''
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
splittedValue = stringValue.split('.')
|
|
69
|
-
splittedValue[0] = part[0]
|
|
70
|
-
|
|
71
|
-
// process the first group separator from decimal (.) only, the rest ignore.
|
|
72
|
-
// get the length of the last slice of split result.
|
|
73
|
-
posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0
|
|
74
|
-
if (posSeparator) {
|
|
75
|
-
integer = splittedValue[0]
|
|
76
|
-
str = ''
|
|
77
|
-
offset = integer.length % posSeparator
|
|
78
|
-
len = integer.length
|
|
79
|
-
for (indx = 0; indx < len; indx++) {
|
|
80
|
-
str += integer.charAt(indx) // ie6 only support charAt for sz.
|
|
81
|
-
// -posSeparator so that won't trail separator on full length
|
|
82
|
-
/* jshint -W018 */
|
|
83
|
-
if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {
|
|
84
|
-
str += group
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
splittedValue[0] = str
|
|
88
|
-
}
|
|
89
|
-
splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : ''
|
|
90
|
-
|
|
91
|
-
// remove negative sign if result is zero
|
|
92
|
-
result = splittedValue.join('')
|
|
93
|
-
if (result === '0' || result === '') {
|
|
94
|
-
// remove negative sign if result is zero
|
|
95
|
-
isNegative = false
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌
|
|
99
|
-
let fixedPlusSign: string
|
|
100
|
-
|
|
101
|
-
if (splittedMask[0].substring(0, 1) === '+') fixedPlusSign = isNegative ? '-' : '+'
|
|
102
|
-
else fixedPlusSign = isNegative ? '-' : ''
|
|
103
|
-
|
|
104
|
-
// put back any negation, combine integer and fraction, and add back prefix & suffix
|
|
105
|
-
return prefix + (fixedPlusSign + result) + suffix
|
|
106
|
-
}
|