ng-prime-tools 1.0.94 → 1.0.95
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.
|
@@ -4093,6 +4093,228 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
4093
4093
|
}]
|
|
4094
4094
|
}] });
|
|
4095
4095
|
|
|
4096
|
+
const PT_CHART_DEFAULT_WIDTH = '100%';
|
|
4097
|
+
const PT_CHART_DEFAULT_HEIGHT = '100%';
|
|
4098
|
+
const PT_CHART_DEFAULT_RESIZE_DELAY = 100;
|
|
4099
|
+
const PT_CHART_DEFAULT_ANIMATION = {
|
|
4100
|
+
duration: 450,
|
|
4101
|
+
easing: 'easeOutQuart',
|
|
4102
|
+
};
|
|
4103
|
+
const PT_CHART_DEFAULT_LAYOUT_PADDING = {
|
|
4104
|
+
top: 12,
|
|
4105
|
+
right: 12,
|
|
4106
|
+
bottom: 8,
|
|
4107
|
+
left: 12,
|
|
4108
|
+
};
|
|
4109
|
+
const PT_CHART_LEGEND_LABELS = {
|
|
4110
|
+
usePointStyle: true,
|
|
4111
|
+
pointStyle: 'circle',
|
|
4112
|
+
boxWidth: 9,
|
|
4113
|
+
boxHeight: 9,
|
|
4114
|
+
padding: 18,
|
|
4115
|
+
};
|
|
4116
|
+
const PT_CHART_TOOLTIP_STYLE = {
|
|
4117
|
+
borderWidth: 1,
|
|
4118
|
+
cornerRadius: 10,
|
|
4119
|
+
caretSize: 7,
|
|
4120
|
+
caretPadding: 8,
|
|
4121
|
+
padding: 12,
|
|
4122
|
+
boxPadding: 6,
|
|
4123
|
+
usePointStyle: true,
|
|
4124
|
+
displayColors: true,
|
|
4125
|
+
};
|
|
4126
|
+
const PT_CHART_FONT_SIZES = {
|
|
4127
|
+
legend: 12,
|
|
4128
|
+
title: 16,
|
|
4129
|
+
tooltipTitle: 13,
|
|
4130
|
+
tooltipBody: 12,
|
|
4131
|
+
axisTicks: 11,
|
|
4132
|
+
axisTitle: 12,
|
|
4133
|
+
dataLabel: 11,
|
|
4134
|
+
};
|
|
4135
|
+
const PT_CHART_FONT_WEIGHTS = {
|
|
4136
|
+
regular: 400,
|
|
4137
|
+
medium: 500,
|
|
4138
|
+
semiBold: 600,
|
|
4139
|
+
bold: 'bold',
|
|
4140
|
+
};
|
|
4141
|
+
const PT_CHART_CARTESIAN_TYPES = [
|
|
4142
|
+
'bar',
|
|
4143
|
+
'line',
|
|
4144
|
+
'scatter',
|
|
4145
|
+
'bubble',
|
|
4146
|
+
];
|
|
4147
|
+
const PT_CHART_CIRCULAR_TYPES = [
|
|
4148
|
+
'pie',
|
|
4149
|
+
'doughnut',
|
|
4150
|
+
'polarArea',
|
|
4151
|
+
];
|
|
4152
|
+
const buildAxisTickFont = (fontFamily) => ({
|
|
4153
|
+
family: fontFamily,
|
|
4154
|
+
size: PT_CHART_FONT_SIZES.axisTicks,
|
|
4155
|
+
weight: PT_CHART_FONT_WEIGHTS.regular,
|
|
4156
|
+
});
|
|
4157
|
+
const isCartesianChartType = (chartType) => PT_CHART_CARTESIAN_TYPES.includes(chartType);
|
|
4158
|
+
const isCircularChartType = (chartType) => PT_CHART_CIRCULAR_TYPES.includes(chartType);
|
|
4159
|
+
const createDefaultChartOptions = (chartType, theme, config) => {
|
|
4160
|
+
const isCartesianChart = isCartesianChartType(chartType);
|
|
4161
|
+
const isCircularChart = isCircularChartType(chartType);
|
|
4162
|
+
const options = {
|
|
4163
|
+
responsive: true,
|
|
4164
|
+
maintainAspectRatio: false,
|
|
4165
|
+
resizeDelay: PT_CHART_DEFAULT_RESIZE_DELAY,
|
|
4166
|
+
interaction: {
|
|
4167
|
+
intersect: false,
|
|
4168
|
+
mode: isCartesianChart ? 'index' : 'nearest',
|
|
4169
|
+
},
|
|
4170
|
+
animation: PT_CHART_DEFAULT_ANIMATION,
|
|
4171
|
+
layout: {
|
|
4172
|
+
padding: PT_CHART_DEFAULT_LAYOUT_PADDING,
|
|
4173
|
+
},
|
|
4174
|
+
plugins: {
|
|
4175
|
+
legend: {
|
|
4176
|
+
display: true,
|
|
4177
|
+
position: 'bottom',
|
|
4178
|
+
align: 'center',
|
|
4179
|
+
labels: {
|
|
4180
|
+
color: theme.textColor,
|
|
4181
|
+
...PT_CHART_LEGEND_LABELS,
|
|
4182
|
+
font: {
|
|
4183
|
+
family: config.fontFamily,
|
|
4184
|
+
size: PT_CHART_FONT_SIZES.legend,
|
|
4185
|
+
weight: PT_CHART_FONT_WEIGHTS.medium,
|
|
4186
|
+
},
|
|
4187
|
+
},
|
|
4188
|
+
},
|
|
4189
|
+
title: {
|
|
4190
|
+
display: Boolean(config.medianTitle?.trim()),
|
|
4191
|
+
text: config.medianTitle?.trim() || '',
|
|
4192
|
+
align: 'start',
|
|
4193
|
+
color: theme.textColor,
|
|
4194
|
+
padding: {
|
|
4195
|
+
top: 4,
|
|
4196
|
+
bottom: 18,
|
|
4197
|
+
},
|
|
4198
|
+
font: {
|
|
4199
|
+
family: config.fontFamily,
|
|
4200
|
+
size: PT_CHART_FONT_SIZES.title,
|
|
4201
|
+
weight: PT_CHART_FONT_WEIGHTS.semiBold,
|
|
4202
|
+
},
|
|
4203
|
+
},
|
|
4204
|
+
tooltip: {
|
|
4205
|
+
enabled: true,
|
|
4206
|
+
backgroundColor: theme.tooltipBackgroundColor,
|
|
4207
|
+
titleColor: theme.tooltipTextColor,
|
|
4208
|
+
bodyColor: theme.tooltipTextColor,
|
|
4209
|
+
footerColor: theme.secondaryTextColor,
|
|
4210
|
+
borderColor: theme.tooltipBorderColor,
|
|
4211
|
+
...PT_CHART_TOOLTIP_STYLE,
|
|
4212
|
+
titleFont: {
|
|
4213
|
+
family: config.fontFamily,
|
|
4214
|
+
size: PT_CHART_FONT_SIZES.tooltipTitle,
|
|
4215
|
+
weight: PT_CHART_FONT_WEIGHTS.semiBold,
|
|
4216
|
+
},
|
|
4217
|
+
bodyFont: {
|
|
4218
|
+
family: config.fontFamily,
|
|
4219
|
+
size: PT_CHART_FONT_SIZES.tooltipBody,
|
|
4220
|
+
weight: PT_CHART_FONT_WEIGHTS.regular,
|
|
4221
|
+
},
|
|
4222
|
+
callbacks: {
|
|
4223
|
+
label: (context) => config.tooltipLabel(context, isCircularChart),
|
|
4224
|
+
},
|
|
4225
|
+
},
|
|
4226
|
+
datalabels: {
|
|
4227
|
+
display: isCircularChart,
|
|
4228
|
+
color: theme.textColor,
|
|
4229
|
+
anchor: isCircularChart ? 'center' : 'end',
|
|
4230
|
+
align: isCircularChart ? 'center' : 'top',
|
|
4231
|
+
clamp: true,
|
|
4232
|
+
clip: false,
|
|
4233
|
+
formatter: (value, context) => config.dataLabel(value, context, isCircularChart),
|
|
4234
|
+
font: {
|
|
4235
|
+
family: config.fontFamily,
|
|
4236
|
+
size: PT_CHART_FONT_SIZES.dataLabel,
|
|
4237
|
+
weight: PT_CHART_FONT_WEIGHTS.bold,
|
|
4238
|
+
},
|
|
4239
|
+
textStrokeColor: theme.surfaceColor,
|
|
4240
|
+
textStrokeWidth: isCircularChart ? 2 : 0,
|
|
4241
|
+
},
|
|
4242
|
+
},
|
|
4243
|
+
};
|
|
4244
|
+
if (isCartesianChart) {
|
|
4245
|
+
options.scales = {
|
|
4246
|
+
x: {
|
|
4247
|
+
display: true,
|
|
4248
|
+
beginAtZero: false,
|
|
4249
|
+
border: {
|
|
4250
|
+
display: false,
|
|
4251
|
+
},
|
|
4252
|
+
grid: {
|
|
4253
|
+
display: false,
|
|
4254
|
+
color: theme.gridColor,
|
|
4255
|
+
drawTicks: false,
|
|
4256
|
+
},
|
|
4257
|
+
ticks: {
|
|
4258
|
+
color: theme.secondaryTextColor,
|
|
4259
|
+
padding: 10,
|
|
4260
|
+
maxRotation: 0,
|
|
4261
|
+
autoSkip: true,
|
|
4262
|
+
font: buildAxisTickFont(config.fontFamily),
|
|
4263
|
+
},
|
|
4264
|
+
title: {
|
|
4265
|
+
display: Boolean(config.xAxisTitle?.trim()),
|
|
4266
|
+
text: config.xAxisTitle?.trim() || '',
|
|
4267
|
+
color: theme.textColor,
|
|
4268
|
+
padding: {
|
|
4269
|
+
top: 12,
|
|
4270
|
+
},
|
|
4271
|
+
font: {
|
|
4272
|
+
family: config.fontFamily,
|
|
4273
|
+
size: PT_CHART_FONT_SIZES.axisTitle,
|
|
4274
|
+
weight: PT_CHART_FONT_WEIGHTS.semiBold,
|
|
4275
|
+
},
|
|
4276
|
+
},
|
|
4277
|
+
},
|
|
4278
|
+
y: {
|
|
4279
|
+
display: true,
|
|
4280
|
+
beginAtZero: config.yAxisBeginAtZero ?? true,
|
|
4281
|
+
min: config.yAxisMin,
|
|
4282
|
+
max: config.yAxisMax,
|
|
4283
|
+
border: {
|
|
4284
|
+
display: false,
|
|
4285
|
+
},
|
|
4286
|
+
grid: {
|
|
4287
|
+
display: true,
|
|
4288
|
+
color: theme.gridColor,
|
|
4289
|
+
drawTicks: false,
|
|
4290
|
+
lineWidth: 1,
|
|
4291
|
+
},
|
|
4292
|
+
ticks: {
|
|
4293
|
+
color: theme.secondaryTextColor,
|
|
4294
|
+
padding: 10,
|
|
4295
|
+
stepSize: config.yAxisStepSize,
|
|
4296
|
+
font: buildAxisTickFont(config.fontFamily),
|
|
4297
|
+
},
|
|
4298
|
+
title: {
|
|
4299
|
+
display: Boolean(config.yAxisTitle?.trim()),
|
|
4300
|
+
text: config.yAxisTitle?.trim() || '',
|
|
4301
|
+
color: theme.textColor,
|
|
4302
|
+
padding: {
|
|
4303
|
+
bottom: 12,
|
|
4304
|
+
},
|
|
4305
|
+
font: {
|
|
4306
|
+
family: config.fontFamily,
|
|
4307
|
+
size: PT_CHART_FONT_SIZES.axisTitle,
|
|
4308
|
+
weight: PT_CHART_FONT_WEIGHTS.semiBold,
|
|
4309
|
+
},
|
|
4310
|
+
},
|
|
4311
|
+
},
|
|
4312
|
+
};
|
|
4313
|
+
}
|
|
4314
|
+
return options;
|
|
4315
|
+
};
|
|
4316
|
+
|
|
4317
|
+
// ng-prime-tools/projects/ng-prime-tools/src/lib/pt-chart/pt-chart.component.ts
|
|
4096
4318
|
class PTChartComponent {
|
|
4097
4319
|
constructor(document) {
|
|
4098
4320
|
this.document = document;
|
|
@@ -4107,6 +4329,7 @@ class PTChartComponent {
|
|
|
4107
4329
|
this.initializeChart();
|
|
4108
4330
|
this.observeContainerResize();
|
|
4109
4331
|
this.observeThemeChanges();
|
|
4332
|
+
this.scheduleChartResize();
|
|
4110
4333
|
}
|
|
4111
4334
|
ngOnChanges(changes) {
|
|
4112
4335
|
if (this.viewInitialized && changes['chartConfig'] && this.chartConfig) {
|
|
@@ -4121,8 +4344,8 @@ class PTChartComponent {
|
|
|
4121
4344
|
}
|
|
4122
4345
|
get chartContainerStyle() {
|
|
4123
4346
|
return {
|
|
4124
|
-
width: this.chartConfig?.chartWidth?.trim() ||
|
|
4125
|
-
height: this.chartConfig?.chartHeight?.trim() ||
|
|
4347
|
+
width: this.chartConfig?.chartWidth?.trim() || PT_CHART_DEFAULT_WIDTH,
|
|
4348
|
+
height: this.chartConfig?.chartHeight?.trim() || PT_CHART_DEFAULT_HEIGHT,
|
|
4126
4349
|
};
|
|
4127
4350
|
}
|
|
4128
4351
|
get chartAriaLabel() {
|
|
@@ -4137,6 +4360,7 @@ class PTChartComponent {
|
|
|
4137
4360
|
const configuration = this.buildChartConfiguration();
|
|
4138
4361
|
this.chart = new Chart(canvas, configuration);
|
|
4139
4362
|
this.currentChartType = this.chartConfig.type;
|
|
4363
|
+
this.scheduleChartResize();
|
|
4140
4364
|
}
|
|
4141
4365
|
updateChart() {
|
|
4142
4366
|
if (!this.viewInitialized || !this.chartConfig) {
|
|
@@ -4147,10 +4371,6 @@ class PTChartComponent {
|
|
|
4147
4371
|
return;
|
|
4148
4372
|
}
|
|
4149
4373
|
const requestedType = this.chartConfig.type;
|
|
4150
|
-
/*
|
|
4151
|
-
* Chart.js does not safely support changing the root chart type
|
|
4152
|
-
* dynamically. Recreate the chart when the requested type changes.
|
|
4153
|
-
*/
|
|
4154
4374
|
if (this.currentChartType !== requestedType) {
|
|
4155
4375
|
this.initializeChart();
|
|
4156
4376
|
return;
|
|
@@ -4161,6 +4381,7 @@ class PTChartComponent {
|
|
|
4161
4381
|
this.chart.options = configuration.options;
|
|
4162
4382
|
}
|
|
4163
4383
|
this.chart.update();
|
|
4384
|
+
this.scheduleChartResize();
|
|
4164
4385
|
}
|
|
4165
4386
|
buildChartConfiguration() {
|
|
4166
4387
|
const chartType = this.chartConfig.type;
|
|
@@ -4174,192 +4395,18 @@ class PTChartComponent {
|
|
|
4174
4395
|
};
|
|
4175
4396
|
}
|
|
4176
4397
|
buildDefaultOptions(chartType, theme) {
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
easing: 'easeOutQuart',
|
|
4190
|
-
},
|
|
4191
|
-
layout: {
|
|
4192
|
-
padding: {
|
|
4193
|
-
top: 12,
|
|
4194
|
-
right: 12,
|
|
4195
|
-
bottom: 8,
|
|
4196
|
-
left: 12,
|
|
4197
|
-
},
|
|
4198
|
-
},
|
|
4199
|
-
plugins: {
|
|
4200
|
-
legend: {
|
|
4201
|
-
display: true,
|
|
4202
|
-
position: 'bottom',
|
|
4203
|
-
align: 'center',
|
|
4204
|
-
labels: {
|
|
4205
|
-
color: theme.textColor,
|
|
4206
|
-
usePointStyle: true,
|
|
4207
|
-
pointStyle: 'circle',
|
|
4208
|
-
boxWidth: 9,
|
|
4209
|
-
boxHeight: 9,
|
|
4210
|
-
padding: 18,
|
|
4211
|
-
font: {
|
|
4212
|
-
family: this.resolveFontFamily(),
|
|
4213
|
-
size: 12,
|
|
4214
|
-
weight: 500,
|
|
4215
|
-
},
|
|
4216
|
-
},
|
|
4217
|
-
},
|
|
4218
|
-
title: {
|
|
4219
|
-
display: Boolean(this.chartConfig.medianTitle?.trim()),
|
|
4220
|
-
text: this.chartConfig.medianTitle?.trim() || '',
|
|
4221
|
-
align: 'start',
|
|
4222
|
-
color: theme.textColor,
|
|
4223
|
-
padding: {
|
|
4224
|
-
top: 4,
|
|
4225
|
-
bottom: 18,
|
|
4226
|
-
},
|
|
4227
|
-
font: {
|
|
4228
|
-
family: this.resolveFontFamily(),
|
|
4229
|
-
size: 16,
|
|
4230
|
-
weight: 600,
|
|
4231
|
-
},
|
|
4232
|
-
},
|
|
4233
|
-
tooltip: {
|
|
4234
|
-
enabled: true,
|
|
4235
|
-
backgroundColor: theme.tooltipBackgroundColor,
|
|
4236
|
-
titleColor: theme.tooltipTextColor,
|
|
4237
|
-
bodyColor: theme.tooltipTextColor,
|
|
4238
|
-
footerColor: theme.secondaryTextColor,
|
|
4239
|
-
borderColor: theme.tooltipBorderColor,
|
|
4240
|
-
borderWidth: 1,
|
|
4241
|
-
cornerRadius: 10,
|
|
4242
|
-
caretSize: 7,
|
|
4243
|
-
caretPadding: 8,
|
|
4244
|
-
padding: 12,
|
|
4245
|
-
boxPadding: 6,
|
|
4246
|
-
usePointStyle: true,
|
|
4247
|
-
displayColors: true,
|
|
4248
|
-
titleFont: {
|
|
4249
|
-
family: this.resolveFontFamily(),
|
|
4250
|
-
size: 13,
|
|
4251
|
-
weight: 600,
|
|
4252
|
-
},
|
|
4253
|
-
bodyFont: {
|
|
4254
|
-
family: this.resolveFontFamily(),
|
|
4255
|
-
size: 12,
|
|
4256
|
-
weight: 400,
|
|
4257
|
-
},
|
|
4258
|
-
callbacks: {
|
|
4259
|
-
label: (context) => {
|
|
4260
|
-
return this.buildTooltipLabel(context, isCircularChart);
|
|
4261
|
-
},
|
|
4262
|
-
},
|
|
4263
|
-
},
|
|
4264
|
-
datalabels: {
|
|
4265
|
-
display: isCircularChart,
|
|
4266
|
-
color: theme.textColor,
|
|
4267
|
-
anchor: isCircularChart ? 'center' : 'end',
|
|
4268
|
-
align: isCircularChart ? 'center' : 'top',
|
|
4269
|
-
clamp: true,
|
|
4270
|
-
clip: false,
|
|
4271
|
-
formatter: (value, context) => {
|
|
4272
|
-
return this.formatDataLabel(value, context.chart, context.datasetIndex, isCircularChart);
|
|
4273
|
-
},
|
|
4274
|
-
font: {
|
|
4275
|
-
family: this.resolveFontFamily(),
|
|
4276
|
-
size: 11,
|
|
4277
|
-
weight: 'bold',
|
|
4278
|
-
},
|
|
4279
|
-
textStrokeColor: theme.surfaceColor,
|
|
4280
|
-
textStrokeWidth: isCircularChart ? 2 : 0,
|
|
4281
|
-
},
|
|
4282
|
-
},
|
|
4283
|
-
};
|
|
4284
|
-
if (isCartesianChart) {
|
|
4285
|
-
options.scales = this.buildDefaultScales(theme);
|
|
4286
|
-
}
|
|
4287
|
-
return options;
|
|
4288
|
-
}
|
|
4289
|
-
buildDefaultScales(theme) {
|
|
4290
|
-
const commonTickFont = {
|
|
4291
|
-
family: this.resolveFontFamily(),
|
|
4292
|
-
size: 11,
|
|
4293
|
-
weight: 400,
|
|
4294
|
-
};
|
|
4295
|
-
return {
|
|
4296
|
-
x: {
|
|
4297
|
-
display: true,
|
|
4298
|
-
beginAtZero: false,
|
|
4299
|
-
border: {
|
|
4300
|
-
display: false,
|
|
4301
|
-
},
|
|
4302
|
-
grid: {
|
|
4303
|
-
display: false,
|
|
4304
|
-
color: theme.gridColor,
|
|
4305
|
-
drawTicks: false,
|
|
4306
|
-
},
|
|
4307
|
-
ticks: {
|
|
4308
|
-
color: theme.secondaryTextColor,
|
|
4309
|
-
padding: 10,
|
|
4310
|
-
maxRotation: 0,
|
|
4311
|
-
autoSkip: true,
|
|
4312
|
-
font: commonTickFont,
|
|
4313
|
-
},
|
|
4314
|
-
title: {
|
|
4315
|
-
display: Boolean(this.chartConfig.xAxisTitle?.trim()),
|
|
4316
|
-
text: this.chartConfig.xAxisTitle?.trim() || '',
|
|
4317
|
-
color: theme.textColor,
|
|
4318
|
-
padding: {
|
|
4319
|
-
top: 12,
|
|
4320
|
-
},
|
|
4321
|
-
font: {
|
|
4322
|
-
family: this.resolveFontFamily(),
|
|
4323
|
-
size: 12,
|
|
4324
|
-
weight: 600,
|
|
4325
|
-
},
|
|
4326
|
-
},
|
|
4327
|
-
},
|
|
4328
|
-
y: {
|
|
4329
|
-
display: true,
|
|
4330
|
-
beginAtZero: this.chartConfig.scales?.y?.ticks?.beginAtZero ?? true,
|
|
4331
|
-
min: this.chartConfig.scales?.y?.min,
|
|
4332
|
-
max: this.chartConfig.scales?.y?.max,
|
|
4333
|
-
border: {
|
|
4334
|
-
display: false,
|
|
4335
|
-
},
|
|
4336
|
-
grid: {
|
|
4337
|
-
display: true,
|
|
4338
|
-
color: theme.gridColor,
|
|
4339
|
-
drawTicks: false,
|
|
4340
|
-
lineWidth: 1,
|
|
4341
|
-
},
|
|
4342
|
-
ticks: {
|
|
4343
|
-
color: theme.secondaryTextColor,
|
|
4344
|
-
padding: 10,
|
|
4345
|
-
stepSize: this.chartConfig.scales?.y?.ticks?.stepSize,
|
|
4346
|
-
font: commonTickFont,
|
|
4347
|
-
},
|
|
4348
|
-
title: {
|
|
4349
|
-
display: Boolean(this.chartConfig.yAxisTitle?.trim()),
|
|
4350
|
-
text: this.chartConfig.yAxisTitle?.trim() || '',
|
|
4351
|
-
color: theme.textColor,
|
|
4352
|
-
padding: {
|
|
4353
|
-
bottom: 12,
|
|
4354
|
-
},
|
|
4355
|
-
font: {
|
|
4356
|
-
family: this.resolveFontFamily(),
|
|
4357
|
-
size: 12,
|
|
4358
|
-
weight: 600,
|
|
4359
|
-
},
|
|
4360
|
-
},
|
|
4361
|
-
},
|
|
4362
|
-
};
|
|
4398
|
+
return createDefaultChartOptions(chartType, theme, {
|
|
4399
|
+
medianTitle: this.chartConfig.medianTitle,
|
|
4400
|
+
xAxisTitle: this.chartConfig.xAxisTitle,
|
|
4401
|
+
yAxisTitle: this.chartConfig.yAxisTitle,
|
|
4402
|
+
yAxisBeginAtZero: this.chartConfig.scales?.y?.ticks?.beginAtZero,
|
|
4403
|
+
yAxisMin: this.chartConfig.scales?.y?.min,
|
|
4404
|
+
yAxisMax: this.chartConfig.scales?.y?.max,
|
|
4405
|
+
yAxisStepSize: this.chartConfig.scales?.y?.ticks?.stepSize,
|
|
4406
|
+
fontFamily: this.resolveFontFamily(),
|
|
4407
|
+
tooltipLabel: (context, includePercentage) => this.buildTooltipLabel(context, includePercentage),
|
|
4408
|
+
dataLabel: (value, context, isCircularChart) => this.formatDataLabel(value, context.chart, context.datasetIndex, isCircularChart),
|
|
4409
|
+
});
|
|
4363
4410
|
}
|
|
4364
4411
|
mergeChartOptions(defaultOptions, consumerOptions, chartType) {
|
|
4365
4412
|
const defaultPlugins = defaultOptions.plugins;
|
|
@@ -4395,10 +4442,6 @@ class PTChartComponent {
|
|
|
4395
4442
|
labels: {
|
|
4396
4443
|
...defaultPlugins?.legend?.labels,
|
|
4397
4444
|
...consumerPlugins?.legend?.labels,
|
|
4398
|
-
/*
|
|
4399
|
-
* Chart.js font options may be scriptable callbacks.
|
|
4400
|
-
* Keep the complete consumer value rather than spreading it.
|
|
4401
|
-
*/
|
|
4402
4445
|
font: consumerPlugins?.legend?.labels?.font ??
|
|
4403
4446
|
defaultPlugins?.legend?.labels?.font,
|
|
4404
4447
|
},
|
|
@@ -4428,7 +4471,7 @@ class PTChartComponent {
|
|
|
4428
4471
|
},
|
|
4429
4472
|
},
|
|
4430
4473
|
};
|
|
4431
|
-
if (
|
|
4474
|
+
if (isCartesianChartType(chartType)) {
|
|
4432
4475
|
mergedOptions.scales = this.mergeScales(defaultOptions.scales, consumerOptions.scales);
|
|
4433
4476
|
}
|
|
4434
4477
|
else if (consumerOptions.scales) {
|
|
@@ -4552,14 +4595,34 @@ class PTChartComponent {
|
|
|
4552
4595
|
if (typeof ResizeObserver === 'undefined') {
|
|
4553
4596
|
return;
|
|
4554
4597
|
}
|
|
4555
|
-
const
|
|
4556
|
-
|
|
4598
|
+
const canvas = this.canvasRef.nativeElement;
|
|
4599
|
+
const chartContainer = canvas.closest('.pt-chart');
|
|
4600
|
+
const canvasContainer = canvas.parentElement;
|
|
4601
|
+
const hostElement = chartContainer?.parentElement;
|
|
4602
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
4603
|
+
this.scheduleChartResize();
|
|
4604
|
+
});
|
|
4605
|
+
if (chartContainer) {
|
|
4606
|
+
this.resizeObserver.observe(chartContainer);
|
|
4607
|
+
}
|
|
4608
|
+
if (canvasContainer) {
|
|
4609
|
+
this.resizeObserver.observe(canvasContainer);
|
|
4610
|
+
}
|
|
4611
|
+
if (hostElement) {
|
|
4612
|
+
this.resizeObserver.observe(hostElement);
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
scheduleChartResize() {
|
|
4616
|
+
if (!this.chart) {
|
|
4557
4617
|
return;
|
|
4558
4618
|
}
|
|
4559
|
-
|
|
4560
|
-
this.chart
|
|
4619
|
+
requestAnimationFrame(() => {
|
|
4620
|
+
if (!this.chart) {
|
|
4621
|
+
return;
|
|
4622
|
+
}
|
|
4623
|
+
this.chart.resize();
|
|
4624
|
+
this.chart.update('none');
|
|
4561
4625
|
});
|
|
4562
|
-
this.resizeObserver.observe(container);
|
|
4563
4626
|
}
|
|
4564
4627
|
observeThemeChanges() {
|
|
4565
4628
|
const documentElement = this.document.documentElement;
|
|
@@ -4592,6 +4655,7 @@ class PTChartComponent {
|
|
|
4592
4655
|
this.chart.options = configuration.options;
|
|
4593
4656
|
}
|
|
4594
4657
|
this.chart.update('none');
|
|
4658
|
+
this.scheduleChartResize();
|
|
4595
4659
|
}
|
|
4596
4660
|
resolveTheme() {
|
|
4597
4661
|
const rootStyles = getComputedStyle(this.document.documentElement);
|
|
@@ -4664,28 +4728,17 @@ class PTChartComponent {
|
|
|
4664
4728
|
? value
|
|
4665
4729
|
: {};
|
|
4666
4730
|
}
|
|
4667
|
-
isCircularChart(chartType) {
|
|
4668
|
-
return (chartType === 'pie' ||
|
|
4669
|
-
chartType === 'doughnut' ||
|
|
4670
|
-
chartType === 'polarArea');
|
|
4671
|
-
}
|
|
4672
|
-
isCartesianChart(chartType) {
|
|
4673
|
-
return (chartType === 'bar' ||
|
|
4674
|
-
chartType === 'line' ||
|
|
4675
|
-
chartType === 'scatter' ||
|
|
4676
|
-
chartType === 'bubble');
|
|
4677
|
-
}
|
|
4678
4731
|
destroyChart() {
|
|
4679
4732
|
this.chart?.destroy();
|
|
4680
4733
|
this.chart = undefined;
|
|
4681
4734
|
this.currentChartType = undefined;
|
|
4682
4735
|
}
|
|
4683
4736
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: PTChartComponent, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4684
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: PTChartComponent, isStandalone: false, selector: "pt-chart", inputs: { chartConfig: "chartConfig" }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["chartCanvas"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"pt-chart\"\n [ngStyle]=\"chartContainerStyle\"\n role=\"img\"\n [attr.aria-label]=\"chartAriaLabel\"\n>\n <div class=\"pt-chart__canvas-container\">\n <canvas #chartCanvas></canvas>\n </div>\n</div>\n", styles: [":host{display:block;width:100%;min-width:0;
|
|
4737
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: PTChartComponent, isStandalone: false, selector: "pt-chart", inputs: { chartConfig: "chartConfig" }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["chartCanvas"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"pt-chart\"\n [ngStyle]=\"chartContainerStyle\"\n role=\"img\"\n [attr.aria-label]=\"chartAriaLabel\"\n>\n <div class=\"pt-chart__canvas-container\">\n <canvas #chartCanvas></canvas>\n </div>\n</div>\n", styles: [":host{display:block;width:100%;height:100%;min-width:0;min-height:0}.pt-chart{position:relative;display:block;width:100%;height:100%;min-width:0;min-height:0;box-sizing:border-box;overflow:hidden;color:var(--p-text-color, var(--text-color, #0f172a));background:linear-gradient(145deg,color-mix(in srgb,var(--p-content-background, var(--surface-card, #ffffff)) 97%,var(--p-primary-color, #3b82f6) 3%),var(--p-content-background, var(--surface-card, #ffffff)));border:1px solid var(--p-content-border-color, var(--surface-border, rgba(15, 23, 42, .1)));border-radius:var(--p-content-border-radius, .875rem);box-shadow:0 1px 2px #0f172a0a,0 8px 24px #0f172a0d;transition:background-color .18s ease,border-color .18s ease,box-shadow .18s ease}.pt-chart:before{position:absolute;top:0;right:12%;left:12%;z-index:0;height:1px;pointer-events:none;content:\"\";background:linear-gradient(90deg,transparent,color-mix(in srgb,var(--p-primary-color, #3b82f6) 45%,transparent),transparent)}.pt-chart__canvas-container{position:relative;z-index:1;width:100%;height:100%;min-width:0;min-height:0;padding:clamp(.75rem,1.5vw,1.25rem);box-sizing:border-box}.pt-chart canvas{display:block;width:100%!important;height:100%!important;max-width:none;max-height:none;outline:none}.pt-chart:focus-within{border-color:var(--p-primary-color, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--p-primary-color, #3b82f6) 18%,transparent),0 10px 30px #0f172a14}:host-context(.p-dark) .pt-chart,:host-context(.dark) .pt-chart,:host-context(.dark-mode) .pt-chart,:host-context([data-theme=\"dark\"]) .pt-chart{background:linear-gradient(145deg,color-mix(in srgb,var(--p-content-background, var(--surface-card, #0f172a)) 96%,var(--p-primary-color, #60a5fa) 4%),var(--p-content-background, var(--surface-card, #0f172a)));border-color:var( --p-content-border-color, var(--surface-border, rgba(148, 163, 184, .2)) );box-shadow:0 1px 2px #0000002e,0 12px 32px #00000038}@media(max-width:768px){.pt-chart{border-radius:.75rem}.pt-chart__canvas-container{padding:.75rem .625rem}}@media(max-width:480px){.pt-chart__canvas-container{padding:.625rem .375rem}}@media(prefers-reduced-motion:reduce){.pt-chart{transition:none}}@media print{.pt-chart{overflow:visible;background:#fff;border:1px solid #d1d5db;box-shadow:none}}\n"], dependencies: [{ kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] }); }
|
|
4685
4738
|
}
|
|
4686
4739
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: PTChartComponent, decorators: [{
|
|
4687
4740
|
type: Component,
|
|
4688
|
-
args: [{ selector: 'pt-chart', standalone: false, template: "<div\n class=\"pt-chart\"\n [ngStyle]=\"chartContainerStyle\"\n role=\"img\"\n [attr.aria-label]=\"chartAriaLabel\"\n>\n <div class=\"pt-chart__canvas-container\">\n <canvas #chartCanvas></canvas>\n </div>\n</div>\n", styles: [":host{display:block;width:100%;min-width:0;
|
|
4741
|
+
args: [{ selector: 'pt-chart', standalone: false, template: "<div\n class=\"pt-chart\"\n [ngStyle]=\"chartContainerStyle\"\n role=\"img\"\n [attr.aria-label]=\"chartAriaLabel\"\n>\n <div class=\"pt-chart__canvas-container\">\n <canvas #chartCanvas></canvas>\n </div>\n</div>\n", styles: [":host{display:block;width:100%;height:100%;min-width:0;min-height:0}.pt-chart{position:relative;display:block;width:100%;height:100%;min-width:0;min-height:0;box-sizing:border-box;overflow:hidden;color:var(--p-text-color, var(--text-color, #0f172a));background:linear-gradient(145deg,color-mix(in srgb,var(--p-content-background, var(--surface-card, #ffffff)) 97%,var(--p-primary-color, #3b82f6) 3%),var(--p-content-background, var(--surface-card, #ffffff)));border:1px solid var(--p-content-border-color, var(--surface-border, rgba(15, 23, 42, .1)));border-radius:var(--p-content-border-radius, .875rem);box-shadow:0 1px 2px #0f172a0a,0 8px 24px #0f172a0d;transition:background-color .18s ease,border-color .18s ease,box-shadow .18s ease}.pt-chart:before{position:absolute;top:0;right:12%;left:12%;z-index:0;height:1px;pointer-events:none;content:\"\";background:linear-gradient(90deg,transparent,color-mix(in srgb,var(--p-primary-color, #3b82f6) 45%,transparent),transparent)}.pt-chart__canvas-container{position:relative;z-index:1;width:100%;height:100%;min-width:0;min-height:0;padding:clamp(.75rem,1.5vw,1.25rem);box-sizing:border-box}.pt-chart canvas{display:block;width:100%!important;height:100%!important;max-width:none;max-height:none;outline:none}.pt-chart:focus-within{border-color:var(--p-primary-color, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--p-primary-color, #3b82f6) 18%,transparent),0 10px 30px #0f172a14}:host-context(.p-dark) .pt-chart,:host-context(.dark) .pt-chart,:host-context(.dark-mode) .pt-chart,:host-context([data-theme=\"dark\"]) .pt-chart{background:linear-gradient(145deg,color-mix(in srgb,var(--p-content-background, var(--surface-card, #0f172a)) 96%,var(--p-primary-color, #60a5fa) 4%),var(--p-content-background, var(--surface-card, #0f172a)));border-color:var( --p-content-border-color, var(--surface-border, rgba(148, 163, 184, .2)) );box-shadow:0 1px 2px #0000002e,0 12px 32px #00000038}@media(max-width:768px){.pt-chart{border-radius:.75rem}.pt-chart__canvas-container{padding:.75rem .625rem}}@media(max-width:480px){.pt-chart__canvas-container{padding:.625rem .375rem}}@media(prefers-reduced-motion:reduce){.pt-chart{transition:none}}@media print{.pt-chart{overflow:visible;background:#fff;border:1px solid #d1d5db;box-shadow:none}}\n"] }]
|
|
4689
4742
|
}], ctorParameters: () => [{ type: Document, decorators: [{
|
|
4690
4743
|
type: Inject,
|
|
4691
4744
|
args: [DOCUMENT]
|