@axdspub/axiom-charts 1.0.6 → 1.0.9
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/library/Libraries/axiom/index.js +122 -34
- package/library/Libraries/axiom/index.js.map +1 -1
- package/library/axiom-charts.d.ts +2 -0
- package/library/browser.js +122 -34
- package/library/browser.js.map +1 -1
- package/library/cjs.js +122 -34
- package/library/cjs.js.map +1 -1
- package/library/index.esm.js +122 -34
- package/library/index.esm.js.map +1 -1
- package/package.json +146 -146
- package/stats.html +1 -1
|
@@ -4012,7 +4012,7 @@ class AxiomScatter extends AxiomPlotRoot {
|
|
|
4012
4012
|
onLegendReady: { get: () => super.onLegendReady }
|
|
4013
4013
|
});
|
|
4014
4014
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4015
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
4015
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
4016
4016
|
const style = this.style !== undefined ? this.style : {};
|
|
4017
4017
|
const data = yield this.getData();
|
|
4018
4018
|
this.parsedData = (_a = data === null || data === void 0 ? void 0 : data.parsed) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -4063,26 +4063,62 @@ class AxiomScatter extends AxiomPlotRoot {
|
|
|
4063
4063
|
});
|
|
4064
4064
|
// .style?.strokeColor !== undefined ? settings.style.strokeColor :
|
|
4065
4065
|
// .style?.strokeWidth ||
|
|
4066
|
-
const pointW = style.radius !== undefined ? style.radius : 2;
|
|
4067
4066
|
/* ctx.save()
|
|
4068
4067
|
ctx.beginPath()
|
|
4069
4068
|
ctx.rect(this.chart.settings.margin.left - pointW, this.chart.settings.margin.top - pointW, this.xScale.range()[1] - pointW * 2, this.yScale.range()[0] - pointW * 2)
|
|
4070
4069
|
ctx.clip() */
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4070
|
+
const defaultPointW = style.radius !== undefined ? style.radius : style.size !== undefined ? style.size : 2;
|
|
4071
|
+
const defaultFill = style.fill !== undefined ? style.fill : '#666';
|
|
4072
|
+
const defaultStroke = style.strokeColor !== undefined ? style.strokeColor : '#FFF';
|
|
4073
|
+
const defaultStrokeWidth = (style.strokeWidth !== undefined || style.strokeColor !== undefined) ? ((style.strokeWidth !== undefined ? style.strokeWidth : 1) + defaultPointW) : 0;
|
|
4074
|
+
const colorAccessor = (_o = this.getStringAccessorAtAxis('color')) !== null && _o !== void 0 ? _o : this.getStringAccessorAtAxis('fill');
|
|
4075
|
+
const radiusAccessor = (_p = this.getAccessorAtAxis('radius')) !== null && _p !== void 0 ? _p : this.getAccessorAtAxis('size');
|
|
4076
|
+
const strokeWidthAccessor = this.getAccessorAtAxis('strokeWidth');
|
|
4077
|
+
const strokeColorAccessor = this.getStringAccessorAtAxis('strokeColor');
|
|
4078
|
+
ctx.strokeStyle = defaultStroke;
|
|
4079
|
+
ctx.lineWidth = defaultStrokeWidth;
|
|
4080
|
+
ctx.fillStyle = defaultFill;
|
|
4074
4081
|
visibleData.forEach(d => {
|
|
4075
4082
|
if (isDefined(d)) {
|
|
4076
4083
|
ctx.beginPath();
|
|
4077
|
-
|
|
4084
|
+
const r = radiusAccessor === null || radiusAccessor === void 0 ? void 0 : radiusAccessor(d);
|
|
4085
|
+
const radius = r !== undefined ? +r : defaultPointW;
|
|
4086
|
+
ctx.arc(xPosition(d), yPosition(d), radius, 0, 2 * Math.PI);
|
|
4087
|
+
if (colorAccessor !== undefined) {
|
|
4088
|
+
const color = colorAccessor.apply(this, [d]);
|
|
4089
|
+
if (color !== undefined && color !== null) {
|
|
4090
|
+
ctx.fillStyle = color.toString();
|
|
4091
|
+
}
|
|
4092
|
+
else if (ctx.fillStyle !== defaultFill) {
|
|
4093
|
+
ctx.fillStyle = defaultFill;
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
if (strokeColorAccessor !== undefined) {
|
|
4097
|
+
const sc = strokeColorAccessor.apply(this, [d]);
|
|
4098
|
+
if (sc !== undefined && sc !== null) {
|
|
4099
|
+
ctx.strokeStyle = sc.toString();
|
|
4100
|
+
}
|
|
4101
|
+
else if (ctx.strokeStyle !== defaultStroke) {
|
|
4102
|
+
ctx.strokeStyle = defaultStroke;
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
if (strokeWidthAccessor !== undefined) {
|
|
4106
|
+
const sw = strokeWidthAccessor.apply(this, [d]);
|
|
4107
|
+
if (sw !== undefined && sw !== null) {
|
|
4108
|
+
ctx.lineWidth = +sw;
|
|
4109
|
+
}
|
|
4110
|
+
else if (ctx.lineWidth !== defaultStrokeWidth) {
|
|
4111
|
+
ctx.lineWidth = defaultStrokeWidth;
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4078
4114
|
ctx.stroke();
|
|
4079
4115
|
ctx.fill();
|
|
4080
4116
|
}
|
|
4081
4117
|
});
|
|
4082
|
-
if (((
|
|
4118
|
+
if (((_q = this.axes) === null || _q === void 0 ? void 0 : _q.y) !== undefined && !((_r = this.legendSettings.hide) !== null && _r !== void 0 ? _r : false)) {
|
|
4083
4119
|
_super.onLegendReady.call(this, [{
|
|
4084
4120
|
id: this.axes.y.key,
|
|
4085
|
-
label: (
|
|
4121
|
+
label: (_s = chart.getAxisLabel(this.axes.y, 'y')) !== null && _s !== void 0 ? _s : this.axes.y.key,
|
|
4086
4122
|
style: {
|
|
4087
4123
|
backgroundColor: ctx.fillStyle,
|
|
4088
4124
|
border: `1px solid ${ctx.strokeStyle}`
|
|
@@ -4148,7 +4184,7 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4148
4184
|
onLegendReady: { get: () => super.onLegendReady }
|
|
4149
4185
|
});
|
|
4150
4186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4151
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
4187
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
4152
4188
|
const style = this.style !== undefined ? this.style : {};
|
|
4153
4189
|
const data = yield this.getData();
|
|
4154
4190
|
const parsedData = (_a = data === null || data === void 0 ? void 0 : data.parsed) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -4160,7 +4196,6 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4160
4196
|
const yAccessor = this.getAccessorAtAxis('y');
|
|
4161
4197
|
const y0Accessor = yAccessors.y0;
|
|
4162
4198
|
const y1Accessor = yAccessors.y1;
|
|
4163
|
-
const colorAccessor = this.getStringAccessorAtAxis('color');
|
|
4164
4199
|
const offset = {
|
|
4165
4200
|
x: ((_d = (_c = (_b = this === null || this === void 0 ? void 0 : this.axes) === null || _b === void 0 ? void 0 : _b.x) === null || _c === void 0 ? void 0 : _c.offset) === null || _d === void 0 ? void 0 : _d.x) !== undefined ? this.axes.x.offset.x : 0,
|
|
4166
4201
|
y: ((_g = (_f = (_e = this === null || this === void 0 ? void 0 : this.axes) === null || _e === void 0 ? void 0 : _e.y) === null || _f === void 0 ? void 0 : _f.offset) === null || _g === void 0 ? void 0 : _g.y) !== undefined ? this.axes.y.offset.y : 0
|
|
@@ -4193,12 +4228,12 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4193
4228
|
return p === undefined ? 0 : (p + offset);
|
|
4194
4229
|
};
|
|
4195
4230
|
};
|
|
4231
|
+
const xDataSpan = Math.abs(+xAxisScale.domain[1] - +xAxisScale.domain[0]);
|
|
4232
|
+
const yDataSpan = Math.abs(+yAxisScale.domain[1] - +yAxisScale.domain[0]);
|
|
4196
4233
|
ctx.save();
|
|
4197
4234
|
ctx.beginPath();
|
|
4198
4235
|
ctx.rect(this.chart.settings.margin.left, this.chart.settings.margin.top, xScale.range()[1], yScale.range()[0]);
|
|
4199
4236
|
ctx.clip();
|
|
4200
|
-
const defaultColor = style.fill !== undefined ? style.fill : '#EDEDED';
|
|
4201
|
-
ctx.fillStyle = defaultColor;
|
|
4202
4237
|
const rect = {};
|
|
4203
4238
|
if (x0Accessor !== undefined && x1Accessor !== undefined) {
|
|
4204
4239
|
rect.x0 = makePositionFn(x0Accessor, xScale, offset.x);
|
|
@@ -4225,7 +4260,6 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4225
4260
|
? x0Accessor(d) !== undefined && x0Accessor(d) !== null && x1Accessor(d) !== undefined && x1Accessor(d) !== null
|
|
4226
4261
|
: false;
|
|
4227
4262
|
};
|
|
4228
|
-
ctx.beginPath();
|
|
4229
4263
|
const isVert = !!(rect.x0 !== undefined && rect.x1 !== undefined);
|
|
4230
4264
|
const height = Math.abs(yAxisScale.range[1] - yAxisScale.range[0]);
|
|
4231
4265
|
const width = Math.abs(xAxisScale.range[1] - xAxisScale.range[0]);
|
|
@@ -4233,20 +4267,83 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4233
4267
|
const barSpacePercent = 20;
|
|
4234
4268
|
const visibleData = parsedData.filter(row => {
|
|
4235
4269
|
return isVert
|
|
4236
|
-
? +rect.y(row) >= yAxisScale.range[
|
|
4270
|
+
? +rect.y(row) >= yAxisScale.range[1] && +rect.y(row) <= yAxisScale.range[0]
|
|
4237
4271
|
: +rect.x(row) >= (xAxisScale.range[0] + offset.x) && +rect.x(row) <= (xAxisScale.range[1] + offset.x);
|
|
4238
4272
|
});
|
|
4239
|
-
const
|
|
4240
|
-
const
|
|
4241
|
-
|
|
4273
|
+
const colorAccessor = (_o = this.getStringAccessorAtAxis('color')) !== null && _o !== void 0 ? _o : this.getStringAccessorAtAxis('fill');
|
|
4274
|
+
const strokeWidthAccessor = this.getAccessorAtAxis('strokeWidth');
|
|
4275
|
+
const strokeColorAccessor = this.getStringAccessorAtAxis('strokeColor');
|
|
4276
|
+
const sizeAccessor = this.getAccessorAtAxis('size');
|
|
4277
|
+
const dataSpanAccessor = this.getAccessorAtAxis('dataSpan');
|
|
4278
|
+
const sizeOfVisibleData = visibleData.length > 0 ?
|
|
4279
|
+
isVert
|
|
4280
|
+
? rect.y(visibleData[0]) - rect.y(visibleData[visibleData.length - 1])
|
|
4281
|
+
: rect.x(visibleData[visibleData.length - 1]) - rect.x(visibleData[0])
|
|
4282
|
+
: 1;
|
|
4283
|
+
const defaultBarSize = (_q = (_p = this.style) === null || _p === void 0 ? void 0 : _p.barSize) !== null && _q !== void 0 ? _q : Math.round((sizeOfVisibleData - visibleData.length) / visibleData.length);
|
|
4284
|
+
const defaultFill = style.fill !== undefined ? style.fill : '#EDEDED';
|
|
4285
|
+
const defaultStrokeWidth = style.strokeWidth !== undefined ? style.strokeWidth : 0;
|
|
4286
|
+
const defaultStrokeColor = style.strokeColor !== undefined ? style.strokeColor : '#FFF';
|
|
4287
|
+
ctx.fillStyle = defaultFill;
|
|
4288
|
+
ctx.strokeStyle = defaultStrokeColor;
|
|
4289
|
+
ctx.lineWidth = defaultStrokeWidth;
|
|
4290
|
+
ctx.beginPath();
|
|
4242
4291
|
visibleData.forEach((row, i) => {
|
|
4292
|
+
var _a, _b;
|
|
4293
|
+
const s = (_a = sizeAccessor === null || sizeAccessor === void 0 ? void 0 : sizeAccessor.apply) === null || _a === void 0 ? void 0 : _a.call(sizeAccessor, this, [row]);
|
|
4294
|
+
const ds = s === undefined && dataSpanAccessor !== undefined
|
|
4295
|
+
? (_b = dataSpanAccessor === null || dataSpanAccessor === void 0 ? void 0 : dataSpanAccessor.apply) === null || _b === void 0 ? void 0 : _b.call(dataSpanAccessor, this, [row])
|
|
4296
|
+
: undefined;
|
|
4297
|
+
const dataSpanLength = ds !== undefined
|
|
4298
|
+
? isVert
|
|
4299
|
+
? yDataSpan / +ds
|
|
4300
|
+
: xDataSpan / +ds
|
|
4301
|
+
: undefined;
|
|
4302
|
+
const dataSize = dataSpanLength !== undefined
|
|
4303
|
+
? Math.round(((isVert ? height : width) - dataSpanLength) / dataSpanLength)
|
|
4304
|
+
: undefined;
|
|
4305
|
+
const sizeWithoutSpace = s !== undefined && s !== null
|
|
4306
|
+
? +s
|
|
4307
|
+
: dataSize !== undefined
|
|
4308
|
+
? dataSize
|
|
4309
|
+
: defaultBarSize;
|
|
4310
|
+
const size = Math.max(1, sizeWithoutSpace - sizeWithoutSpace * (barSpacePercent / 100));
|
|
4311
|
+
if (colorAccessor !== undefined) {
|
|
4312
|
+
const color = colorAccessor.apply(this, [row]);
|
|
4313
|
+
if (color !== undefined && color !== null) {
|
|
4314
|
+
ctx.fillStyle = color.toString();
|
|
4315
|
+
}
|
|
4316
|
+
else if (ctx.fillStyle !== defaultFill) {
|
|
4317
|
+
ctx.fillStyle = defaultFill;
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
if (strokeColorAccessor !== undefined) {
|
|
4321
|
+
const sc = strokeColorAccessor.apply(this, [row]);
|
|
4322
|
+
if (sc !== undefined && sc !== null) {
|
|
4323
|
+
ctx.strokeStyle = sc.toString();
|
|
4324
|
+
}
|
|
4325
|
+
else if (ctx.strokeStyle !== defaultStrokeColor) {
|
|
4326
|
+
ctx.strokeStyle = defaultStrokeColor;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
if (strokeWidthAccessor !== undefined) {
|
|
4330
|
+
const sw = strokeWidthAccessor.apply(this, [row]);
|
|
4331
|
+
if (sw !== undefined && sw !== null) {
|
|
4332
|
+
ctx.lineWidth = +sw;
|
|
4333
|
+
}
|
|
4334
|
+
else if (ctx.lineWidth !== defaultStrokeWidth) {
|
|
4335
|
+
ctx.lineWidth = defaultStrokeWidth;
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4243
4338
|
if (isVert) {
|
|
4244
4339
|
const xVal = rect.x0(row);
|
|
4245
4340
|
if (isDefined(row) && xVal !== undefined && xVal !== null) {
|
|
4246
4341
|
const xW = Math.abs(rect.x1(row) - xVal);
|
|
4247
4342
|
const yVal = rect.y(row);
|
|
4248
|
-
const yH =
|
|
4249
|
-
ctx.
|
|
4343
|
+
const yH = size;
|
|
4344
|
+
ctx.fillRect(xVal, yVal, xW, yH);
|
|
4345
|
+
ctx.strokeRect(xVal, yVal, xW, yH);
|
|
4346
|
+
//ctx.rect(xVal, yVal, xW, yH)
|
|
4250
4347
|
}
|
|
4251
4348
|
}
|
|
4252
4349
|
else {
|
|
@@ -4254,30 +4351,21 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
4254
4351
|
const y1 = rect.y1(row);
|
|
4255
4352
|
if (isDefined(row) && y0 !== undefined && y1 !== undefined) {
|
|
4256
4353
|
// make sure bar doesn't go outside of chart area
|
|
4257
|
-
const xVal = rect.x(row) -
|
|
4354
|
+
const xVal = rect.x(row) - size / 2;
|
|
4258
4355
|
// add per feature style option
|
|
4259
4356
|
// ctx.fillStyle = i % 2 === 0 ? '#FF0000' : '#006699'
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
if (color !== undefined && color !== null) {
|
|
4263
|
-
ctx.fillStyle = color.toString();
|
|
4264
|
-
hadFillColor = true;
|
|
4265
|
-
}
|
|
4266
|
-
else if (hadFillColor) {
|
|
4267
|
-
ctx.fillStyle = defaultColor;
|
|
4268
|
-
hadFillColor = false;
|
|
4269
|
-
}
|
|
4270
|
-
}
|
|
4271
|
-
ctx.fillRect(xVal, y0, defaultSize, y1 - y0);
|
|
4357
|
+
ctx.fillRect(xVal, y0, size, y1 - y0);
|
|
4358
|
+
ctx.strokeRect(xVal, y0, size, y1 - y0);
|
|
4272
4359
|
}
|
|
4273
4360
|
}
|
|
4274
4361
|
// ctx.rect(rect.x0(row),row.y0(row),)
|
|
4275
4362
|
});
|
|
4276
4363
|
ctx.fill();
|
|
4277
|
-
|
|
4364
|
+
ctx.stroke();
|
|
4365
|
+
if (((_r = this.axes) === null || _r === void 0 ? void 0 : _r.y) !== undefined && !((_s = this.legendSettings.hide) !== null && _s !== void 0 ? _s : false)) {
|
|
4278
4366
|
_super.onLegendReady.call(this, [{
|
|
4279
4367
|
id: this.axes.y.key,
|
|
4280
|
-
label: (
|
|
4368
|
+
label: (_t = chart.getAxisLabel(this.axes.y, 'y')) !== null && _t !== void 0 ? _t : this.axes.y.key,
|
|
4281
4369
|
style: { backgroundColor: ctx.fillStyle }
|
|
4282
4370
|
}]);
|
|
4283
4371
|
}
|