@limetech/lime-elements 40.21.1 → 40.23.0
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/cjs/language-s0bKUCvO.js +58 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-action-bar_3.cjs.entry.js +2 -2
- package/dist/cjs/limel-ai-avatar.cjs.entry.js +2 -2
- package/dist/cjs/limel-badge_7.cjs.entry.js +2 -2
- package/dist/cjs/limel-callout.cjs.entry.js +2 -2
- package/dist/cjs/limel-chart.cjs.entry.js +524 -76
- package/dist/cjs/limel-chip-set.cjs.entry.js +2 -2
- package/dist/cjs/limel-chip_2.cjs.entry.js +2 -2
- package/dist/cjs/limel-code-diff.cjs.entry.js +2 -2
- package/dist/cjs/limel-code-editor.cjs.entry.js +2 -2
- package/dist/cjs/limel-collapsible-section.cjs.entry.js +2 -2
- package/dist/cjs/limel-date-picker.cjs.entry.js +1 -1
- package/dist/cjs/limel-dock.cjs.entry.js +2 -2
- package/dist/cjs/limel-drag-handle_2.cjs.entry.js +2 -2
- package/dist/cjs/limel-email-viewer.cjs.entry.js +2 -2
- package/dist/cjs/limel-file-viewer.cjs.entry.js +2 -2
- package/dist/cjs/limel-file.cjs.entry.js +2 -2
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +2 -2
- package/dist/cjs/limel-form.cjs.entry.js +202 -15
- package/dist/cjs/limel-list-item.cjs.entry.js +2 -2
- package/dist/cjs/limel-pagination-jump.cjs.entry.js +2 -2
- package/dist/cjs/limel-pagination.cjs.entry.js +14 -26
- package/dist/cjs/limel-picker.cjs.entry.js +2 -2
- package/dist/cjs/limel-profile-picture.cjs.entry.js +2 -2
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +2 -2
- package/dist/cjs/limel-resize-handle.cjs.entry.js +2 -2
- package/dist/cjs/limel-side-panel.cjs.entry.js +2 -2
- package/dist/cjs/limel-slider.cjs.entry.js +2 -2
- package/dist/cjs/limel-snackbar.cjs.entry.js +2 -2
- package/dist/cjs/limel-table.cjs.entry.js +2 -2
- package/dist/cjs/limel-text-editor-link-menu.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{translations-CqJEWcfw.js → translations-JLP5icQ9.js} +1 -1
- package/dist/collection/components/chart/chart.js +116 -45
- package/dist/collection/components/chart/format.js +302 -0
- package/dist/collection/components/chart/options.js +26 -14
- package/dist/collection/components/chart/scale.js +132 -19
- package/dist/collection/components/form/filled-defaults.js +132 -0
- package/dist/collection/components/form/form.js +93 -15
- package/dist/collection/components/form/form.test-schemas.js +50 -0
- package/dist/collection/components/pagination/pagination.js +13 -25
- package/dist/collection/util/language.js +29 -0
- package/dist/esm/language-VamkUr90.js +55 -0
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-action-bar_3.entry.js +2 -2
- package/dist/esm/limel-ai-avatar.entry.js +2 -2
- package/dist/esm/limel-badge_7.entry.js +2 -2
- package/dist/esm/limel-callout.entry.js +2 -2
- package/dist/esm/limel-chart.entry.js +524 -76
- package/dist/esm/limel-chip-set.entry.js +2 -2
- package/dist/esm/limel-chip_2.entry.js +2 -2
- package/dist/esm/limel-code-diff.entry.js +2 -2
- package/dist/esm/limel-code-editor.entry.js +2 -2
- package/dist/esm/limel-collapsible-section.entry.js +2 -2
- package/dist/esm/limel-date-picker.entry.js +1 -1
- package/dist/esm/limel-dock.entry.js +2 -2
- package/dist/esm/limel-drag-handle_2.entry.js +2 -2
- package/dist/esm/limel-email-viewer.entry.js +2 -2
- package/dist/esm/limel-file-viewer.entry.js +2 -2
- package/dist/esm/limel-file.entry.js +2 -2
- package/dist/esm/limel-flatpickr-adapter.entry.js +2 -2
- package/dist/esm/limel-form.entry.js +202 -15
- package/dist/esm/limel-list-item.entry.js +2 -2
- package/dist/esm/limel-pagination-jump.entry.js +2 -2
- package/dist/esm/limel-pagination.entry.js +14 -26
- package/dist/esm/limel-picker.entry.js +2 -2
- package/dist/esm/limel-profile-picture.entry.js +2 -2
- package/dist/esm/limel-prosemirror-adapter.entry.js +2 -2
- package/dist/esm/limel-resize-handle.entry.js +2 -2
- package/dist/esm/limel-side-panel.entry.js +2 -2
- package/dist/esm/limel-slider.entry.js +2 -2
- package/dist/esm/limel-snackbar.entry.js +2 -2
- package/dist/esm/limel-table.entry.js +2 -2
- package/dist/esm/limel-text-editor-link-menu.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{translations-kct5Kybu.js → translations-D9ZGrMhe.js} +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-6e9eeb0a.entry.js → p-0a7cbdc3.entry.js} +1 -1
- package/dist/lime-elements/{p-d35d2859.entry.js → p-0f96e94d.entry.js} +1 -1
- package/dist/lime-elements/{p-a7be03e1.entry.js → p-1a0c5e45.entry.js} +1 -1
- package/dist/lime-elements/{p-5e408c27.entry.js → p-401d5c92.entry.js} +1 -1
- package/dist/lime-elements/{p-6d2d25b9.entry.js → p-430db3b9.entry.js} +1 -1
- package/dist/lime-elements/{p-a6c6a31b.entry.js → p-43b62587.entry.js} +1 -1
- package/dist/lime-elements/{p-958396b5.entry.js → p-48dccb83.entry.js} +1 -1
- package/dist/lime-elements/{p-814b4934.entry.js → p-5c918155.entry.js} +1 -1
- package/dist/lime-elements/{p-22e9e327.entry.js → p-66101ed6.entry.js} +1 -1
- package/dist/lime-elements/{p-d8559847.entry.js → p-7ab72b52.entry.js} +1 -1
- package/dist/lime-elements/{p-7af83877.entry.js → p-8d9a2a22.entry.js} +1 -1
- package/dist/lime-elements/{p-55fa19ae.entry.js → p-8de4f0f3.entry.js} +1 -1
- package/dist/lime-elements/p-8e80a884.entry.js +56 -0
- package/dist/lime-elements/{p-bffb5ed2.entry.js → p-99984c66.entry.js} +1 -1
- package/dist/lime-elements/{p-56e2fa48.entry.js → p-9d46f720.entry.js} +1 -1
- package/dist/lime-elements/{p-68bbb8dd.entry.js → p-9e2b426c.entry.js} +1 -1
- package/dist/lime-elements/{p-Dzp8dXTo.js → p-C9dBa_Im.js} +1 -1
- package/dist/lime-elements/p-VamkUr90.js +1 -0
- package/dist/lime-elements/{p-3ac39bd5.entry.js → p-b1c7033b.entry.js} +2 -2
- package/dist/lime-elements/{p-47fe76a8.entry.js → p-b5451350.entry.js} +1 -1
- package/dist/lime-elements/{p-9edd79a8.entry.js → p-c75f3b0d.entry.js} +1 -1
- package/dist/lime-elements/{p-4c080cd9.entry.js → p-ca4247c4.entry.js} +1 -1
- package/dist/lime-elements/{p-1a7d1d2b.entry.js → p-d53421af.entry.js} +1 -1
- package/dist/lime-elements/{p-6d9b89db.entry.js → p-d8901e39.entry.js} +1 -1
- package/dist/lime-elements/{p-933ffaa8.entry.js → p-d89553b3.entry.js} +1 -1
- package/dist/lime-elements/{p-496b2437.entry.js → p-d93b8ce0.entry.js} +1 -1
- package/dist/lime-elements/{p-23067836.entry.js → p-e97340c4.entry.js} +1 -1
- package/dist/lime-elements/{p-7b87e547.entry.js → p-ec0c113d.entry.js} +1 -1
- package/dist/lime-elements/{p-9f0575fd.entry.js → p-f197000b.entry.js} +4 -4
- package/dist/lime-elements/{p-07f3565b.entry.js → p-f6bc6658.entry.js} +1 -1
- package/dist/lime-elements/{p-9b2623fe.entry.js → p-f71fbc9e.entry.js} +1 -1
- package/dist/lime-elements/{p-7fcd48c6.entry.js → p-fa1aa440.entry.js} +1 -1
- package/dist/types/components/chart/chart.d.ts +32 -7
- package/dist/types/components/chart/chart.types.d.ts +15 -1
- package/dist/types/components/chart/format.d.ts +54 -0
- package/dist/types/components/chart/options.d.ts +3 -4
- package/dist/types/components/chart/scale.d.ts +39 -7
- package/dist/types/components/form/filled-defaults.d.ts +12 -0
- package/dist/types/components/form/form.d.ts +17 -0
- package/dist/types/components/form/form.test-schemas.d.ts +2 -0
- package/dist/types/components/pagination/pagination.d.ts +6 -12
- package/dist/types/components.d.ts +51 -8
- package/dist/types/util/language.d.ts +19 -0
- package/package.json +3 -3
- package/dist/cjs/language-v-MMS6ym.js +0 -28
- package/dist/esm/language-ChagAaNf.js +0 -26
- package/dist/lime-elements/p-7d6a12fe.entry.js +0 -56
- package/dist/lime-elements/p-ChagAaNf.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BlsqxTB1.js');
|
|
4
|
-
var translations = require('./translations-
|
|
4
|
+
var translations = require('./translations-JLP5icQ9.js');
|
|
5
5
|
var keyboardNavigation = require('./keyboard-navigation-VyqkMDKy.js');
|
|
6
|
-
require('./language-
|
|
6
|
+
var language = require('./language-s0bKUCvO.js');
|
|
7
7
|
require('./keycodes-BQ_AERli.js');
|
|
8
8
|
|
|
9
9
|
/*! *****************************************************************************
|
|
@@ -50174,8 +50174,9 @@ function install(registers) {
|
|
|
50174
50174
|
registers.registerPainter('svg', SVGPainter);
|
|
50175
50175
|
}
|
|
50176
50176
|
|
|
50177
|
-
const PERCENT = 100;
|
|
50177
|
+
const PERCENT$1 = 100;
|
|
50178
50178
|
const STEP_COUNT = 10;
|
|
50179
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
50179
50180
|
/**
|
|
50180
50181
|
* The most steps that an `axisIncrement` may divide a value axis into.
|
|
50181
50182
|
*/
|
|
@@ -50278,6 +50279,114 @@ function getAxisRange(items, maxValue, axisIncrement) {
|
|
|
50278
50279
|
: getNiceStep(span);
|
|
50279
50280
|
return roundOutwards(minRange, finalMaxRange, increment);
|
|
50280
50281
|
}
|
|
50282
|
+
/**
|
|
50283
|
+
* Whether `value` is a date in milliseconds that `Date` can hold. A date
|
|
50284
|
+
* in nanoseconds is not, and neither is a date given as text.
|
|
50285
|
+
* @param value - the value to check
|
|
50286
|
+
*/
|
|
50287
|
+
function isDate(value) {
|
|
50288
|
+
return (typeof value === 'number' && Number.isFinite(new Date(value).getTime()));
|
|
50289
|
+
}
|
|
50290
|
+
/**
|
|
50291
|
+
* The range of an axis of dates, in milliseconds: from the start of the
|
|
50292
|
+
* earliest day to the latest date, or to `maxValue` when that is set, as an
|
|
50293
|
+
* axis of numbers ends at `maxValue`. An end during a day is moved to the
|
|
50294
|
+
* end of that day. Unlike an axis of numbers, it does not reach down to
|
|
50295
|
+
* zero, which would be 1970, and values that are not dates are left out.
|
|
50296
|
+
* Its increment is a day, though `getDateTicks` decides what the axis
|
|
50297
|
+
* marks.
|
|
50298
|
+
* @param values - the dates on the axis
|
|
50299
|
+
* @param maxValue - the requested upper bound, if any
|
|
50300
|
+
*/
|
|
50301
|
+
function getDateRange(values, maxValue) {
|
|
50302
|
+
const dates = values.filter((value) => isDate(value));
|
|
50303
|
+
const start = new Date(dates.length > 0 ? Math.min(...dates) : Date.now());
|
|
50304
|
+
start.setHours(0, 0, 0, 0);
|
|
50305
|
+
const end = new Date(isDate(maxValue) ? maxValue : Math.max(start.getTime(), ...dates));
|
|
50306
|
+
if (end.getTime() <= start.getTime()) {
|
|
50307
|
+
end.setTime(addDays(start, 1).getTime());
|
|
50308
|
+
}
|
|
50309
|
+
else if (end.getTime() > startOfDay(end)) {
|
|
50310
|
+
end.setTime(addDays(new Date(startOfDay(end)), 1).getTime());
|
|
50311
|
+
}
|
|
50312
|
+
return {
|
|
50313
|
+
minValue: start.getTime(),
|
|
50314
|
+
maxValue: end.getTime(),
|
|
50315
|
+
totalRange: end.getTime() - start.getTime(),
|
|
50316
|
+
increment: DAY,
|
|
50317
|
+
};
|
|
50318
|
+
}
|
|
50319
|
+
const DAYS_IN_MONTH = 30.44;
|
|
50320
|
+
const DAYS_IN_YEAR = 365.25;
|
|
50321
|
+
const DATE_STEP_COUNT = 6;
|
|
50322
|
+
const dayStep = (count) => ({
|
|
50323
|
+
unit: 'day',
|
|
50324
|
+
days: count,
|
|
50325
|
+
first: (date) => date,
|
|
50326
|
+
next: (date) => addDays(date, count),
|
|
50327
|
+
});
|
|
50328
|
+
const weekStep = (count) => ({
|
|
50329
|
+
unit: 'day',
|
|
50330
|
+
days: 7 * count,
|
|
50331
|
+
first: (date) => addDays(date, (8 - date.getDay()) % 7),
|
|
50332
|
+
next: (date) => addDays(date, 7 * count),
|
|
50333
|
+
});
|
|
50334
|
+
const monthStep = (count) => ({
|
|
50335
|
+
unit: 'month',
|
|
50336
|
+
days: DAYS_IN_MONTH * count,
|
|
50337
|
+
first: (date) => {
|
|
50338
|
+
let month = date.getDate() === 1 ? date : getFirstOfMonth(date, 1);
|
|
50339
|
+
while (month.getMonth() % count !== 0) {
|
|
50340
|
+
month = getFirstOfMonth(month, 1);
|
|
50341
|
+
}
|
|
50342
|
+
return month;
|
|
50343
|
+
},
|
|
50344
|
+
next: (date) => getFirstOfMonth(date, count),
|
|
50345
|
+
});
|
|
50346
|
+
const yearStep = (count) => ({
|
|
50347
|
+
unit: 'year',
|
|
50348
|
+
days: DAYS_IN_YEAR * count,
|
|
50349
|
+
first: (date) => {
|
|
50350
|
+
let year = date.getFullYear();
|
|
50351
|
+
if (date.getTime() > createDate(year, 0, 1).getTime()) {
|
|
50352
|
+
year += 1;
|
|
50353
|
+
}
|
|
50354
|
+
return createDate(Math.ceil(year / count) * count, 0, 1);
|
|
50355
|
+
},
|
|
50356
|
+
next: (date) => createDate(date.getFullYear() + count, 0, 1),
|
|
50357
|
+
});
|
|
50358
|
+
const DATE_STEPS = [
|
|
50359
|
+
dayStep(1),
|
|
50360
|
+
dayStep(2),
|
|
50361
|
+
weekStep(1),
|
|
50362
|
+
weekStep(2),
|
|
50363
|
+
monthStep(1),
|
|
50364
|
+
monthStep(3),
|
|
50365
|
+
monthStep(6),
|
|
50366
|
+
yearStep(1),
|
|
50367
|
+
yearStep(2),
|
|
50368
|
+
yearStep(5),
|
|
50369
|
+
yearStep(10),
|
|
50370
|
+
];
|
|
50371
|
+
/**
|
|
50372
|
+
* The dates to mark on an axis of dates: days, Mondays, or the first days
|
|
50373
|
+
* of months, quarters, half years or years, whichever divides the axis
|
|
50374
|
+
* into at most about six steps. Dates take more room than numbers, so
|
|
50375
|
+
* they get fewer steps.
|
|
50376
|
+
* @param range - the range of the axis, from `getDateRange`
|
|
50377
|
+
* @returns the dates to mark, and whether they are days, months or years
|
|
50378
|
+
*/
|
|
50379
|
+
function getDateTicks(range) {
|
|
50380
|
+
var _a;
|
|
50381
|
+
const days = (range.maxValue - range.minValue) / DAY;
|
|
50382
|
+
const decades = days / DAYS_IN_YEAR / 10;
|
|
50383
|
+
const step = (_a = DATE_STEPS.find((candidate) => days / candidate.days <= DATE_STEP_COUNT)) !== null && _a !== void 0 ? _a : yearStep(10 * Math.ceil(decades / DATE_STEP_COUNT));
|
|
50384
|
+
const ticks = [];
|
|
50385
|
+
for (let date = step.first(new Date(range.minValue)); date.getTime() <= range.maxValue; date = step.next(date)) {
|
|
50386
|
+
ticks.push(date.getTime());
|
|
50387
|
+
}
|
|
50388
|
+
return { values: ticks, unit: step.unit };
|
|
50389
|
+
}
|
|
50281
50390
|
/**
|
|
50282
50391
|
* The range of a chart whose items are parts of one whole: `maxValue`
|
|
50283
50392
|
* when set, otherwise the combined item values or range extents. The value
|
|
@@ -50318,26 +50427,7 @@ function getScatterRanges(items) {
|
|
|
50318
50427
|
* @param whole - the range from `getWholeRange`
|
|
50319
50428
|
*/
|
|
50320
50429
|
function getShare(item, whole) {
|
|
50321
|
-
return (getValueSpan(item) / whole.totalRange) * PERCENT;
|
|
50322
|
-
}
|
|
50323
|
-
/**
|
|
50324
|
-
* The item's value as text: its `formattedValue` when set, otherwise its
|
|
50325
|
-
* value, range, or scatter point.
|
|
50326
|
-
* @param item - the item
|
|
50327
|
-
* @param type - the chart type
|
|
50328
|
-
*/
|
|
50329
|
-
function formatValue(item, type) {
|
|
50330
|
-
const { value, formattedValue } = item;
|
|
50331
|
-
if (formattedValue) {
|
|
50332
|
-
return formattedValue;
|
|
50333
|
-
}
|
|
50334
|
-
if (Array.isArray(value)) {
|
|
50335
|
-
if (type === 'scatter') {
|
|
50336
|
-
return `(${value[0]}, ${value[1]})`;
|
|
50337
|
-
}
|
|
50338
|
-
return `${value[0]} — ${value[1]}`;
|
|
50339
|
-
}
|
|
50340
|
-
return `${value}`;
|
|
50430
|
+
return (getValueSpan(item) / whole.totalRange) * PERCENT$1;
|
|
50341
50431
|
}
|
|
50342
50432
|
function isUsableStep(step, span) {
|
|
50343
50433
|
return step > 0 && span / step <= MAX_AXIS_STEPS;
|
|
@@ -50357,6 +50447,29 @@ function getZeroAnchoredRange(values) {
|
|
|
50357
50447
|
const maxValue = Math.max(0, ...values);
|
|
50358
50448
|
return roundOutwards(minValue, maxValue, getNiceStep(maxValue - minValue));
|
|
50359
50449
|
}
|
|
50450
|
+
function addDays(date, days) {
|
|
50451
|
+
return createDate(date.getFullYear(), date.getMonth(), date.getDate() + days);
|
|
50452
|
+
}
|
|
50453
|
+
function getFirstOfMonth(date, monthsLater) {
|
|
50454
|
+
return createDate(date.getFullYear(), date.getMonth() + monthsLater, 1);
|
|
50455
|
+
}
|
|
50456
|
+
/**
|
|
50457
|
+
* The start of a day in local time. Unlike `new Date(year, month, day)`, it
|
|
50458
|
+
* keeps the years 0 to 99 rather than reading them as 1900 to 1999, see
|
|
50459
|
+
* https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-makefullyear
|
|
50460
|
+
* @param year - the full year
|
|
50461
|
+
* @param month - the month, from 0 for January
|
|
50462
|
+
* @param day - the day of the month
|
|
50463
|
+
*/
|
|
50464
|
+
function createDate(year, month, day) {
|
|
50465
|
+
const date = new Date(0);
|
|
50466
|
+
date.setFullYear(year, month, day);
|
|
50467
|
+
date.setHours(0, 0, 0, 0);
|
|
50468
|
+
return date;
|
|
50469
|
+
}
|
|
50470
|
+
function startOfDay(date) {
|
|
50471
|
+
return new Date(date).setHours(0, 0, 0, 0);
|
|
50472
|
+
}
|
|
50360
50473
|
function roundOutwards(minValue, maxValue, increment) {
|
|
50361
50474
|
const lowerEnd = Math.floor(minValue / increment) * increment;
|
|
50362
50475
|
const upperEnd = Math.ceil(maxValue / increment) * increment;
|
|
@@ -50368,13 +50481,313 @@ function roundOutwards(minValue, maxValue, increment) {
|
|
|
50368
50481
|
};
|
|
50369
50482
|
}
|
|
50370
50483
|
|
|
50484
|
+
const FALLBACK_LOCALE = 'en';
|
|
50485
|
+
const PERCENT = 100;
|
|
50486
|
+
/**
|
|
50487
|
+
* The largest value on an axis from which its values are shortened,
|
|
50488
|
+
* such as `1.2M` for 1 200 000.
|
|
50489
|
+
*/
|
|
50490
|
+
const SHORTEN_FROM = 10000;
|
|
50491
|
+
/**
|
|
50492
|
+
* The most decimals `Intl` writes in every browser.
|
|
50493
|
+
*/
|
|
50494
|
+
const MAX_DECIMALS = 20;
|
|
50495
|
+
/**
|
|
50496
|
+
* The most significant digits `Intl` writes.
|
|
50497
|
+
*/
|
|
50498
|
+
const MAX_SIGNIFICANT_DIGITS = 21;
|
|
50499
|
+
/**
|
|
50500
|
+
* Up to three decimals, and six significant digits below one, so `0.0004`
|
|
50501
|
+
* is not written as `0`.
|
|
50502
|
+
*/
|
|
50503
|
+
const NUMBERS = {
|
|
50504
|
+
options: { maximumFractionDigits: 3 },
|
|
50505
|
+
small: { maximumSignificantDigits: 6 },
|
|
50506
|
+
smallBelow: 1,
|
|
50507
|
+
};
|
|
50508
|
+
/**
|
|
50509
|
+
* Up to one decimal, and two significant digits below 1 %, so `0.0004` is
|
|
50510
|
+
* written as `0.04%` rather than `0%`.
|
|
50511
|
+
*/
|
|
50512
|
+
const PERCENTAGES = {
|
|
50513
|
+
options: { style: 'percent', maximumFractionDigits: 1 },
|
|
50514
|
+
small: { style: 'percent', maximumSignificantDigits: 2 },
|
|
50515
|
+
smallBelow: 0.01,
|
|
50516
|
+
};
|
|
50517
|
+
const SHARE_OPTIONS = {
|
|
50518
|
+
style: 'percent',
|
|
50519
|
+
minimumFractionDigits: 2,
|
|
50520
|
+
maximumFractionDigits: 2,
|
|
50521
|
+
};
|
|
50522
|
+
/**
|
|
50523
|
+
* The ticks of an axis of dates that are not known, whose dates are all
|
|
50524
|
+
* written with their year.
|
|
50525
|
+
*/
|
|
50526
|
+
const UNKNOWN_DATE_TICKS = { values: [], unit: 'day' };
|
|
50527
|
+
const locales = new Map();
|
|
50528
|
+
const numberFormats = new Map();
|
|
50529
|
+
const currencyCodes = new Map();
|
|
50530
|
+
const dateFormats = new Map();
|
|
50531
|
+
/**
|
|
50532
|
+
* The item's value as text: its `formattedValue` when set, otherwise its
|
|
50533
|
+
* value, range, or scatter point, written in the chart's language and
|
|
50534
|
+
* value format.
|
|
50535
|
+
* @param item - the item
|
|
50536
|
+
* @param style - how the chart writes values
|
|
50537
|
+
*/
|
|
50538
|
+
function formatValue(item, style) {
|
|
50539
|
+
const { value, formattedValue } = item;
|
|
50540
|
+
if (formattedValue) {
|
|
50541
|
+
return formattedValue;
|
|
50542
|
+
}
|
|
50543
|
+
const write = getValueWriter(style);
|
|
50544
|
+
if (!Array.isArray(value)) {
|
|
50545
|
+
return write(value);
|
|
50546
|
+
}
|
|
50547
|
+
const [first, second] = value.map((part) => write(part));
|
|
50548
|
+
if (style.type === 'scatter') {
|
|
50549
|
+
return writePoint(first, second);
|
|
50550
|
+
}
|
|
50551
|
+
const [start, end] = [getMinimumValue(item), getMaximumValue(item)];
|
|
50552
|
+
if (style.valueFormat === 'date' && isDate(start) && isDate(end)) {
|
|
50553
|
+
return getDateFormat(style.language).formatRange(start, end);
|
|
50554
|
+
}
|
|
50555
|
+
return `${first} — ${second}`;
|
|
50556
|
+
}
|
|
50557
|
+
/**
|
|
50558
|
+
* Writes the values of an axis in the chart's language and value format,
|
|
50559
|
+
* with as many decimals as the step between them has. Amounts leave out
|
|
50560
|
+
* their currency, which the item values and tooltips show. On an axis
|
|
50561
|
+
* that reaches 10 000 or more, every number is shortened, such as `1.2M`,
|
|
50562
|
+
* so the values stay short and alike. Dates are written by what the axis
|
|
50563
|
+
* steps through: days, months or years, with the year on the first date
|
|
50564
|
+
* and on the first date of each new year.
|
|
50565
|
+
* @param range - the range of the axis
|
|
50566
|
+
* @param style - how the chart writes values
|
|
50567
|
+
* @param dates - the dates an axis of dates marks
|
|
50568
|
+
*/
|
|
50569
|
+
function getAxisValueFormatter(range, style, dates) {
|
|
50570
|
+
const locale = getLocale(style.language);
|
|
50571
|
+
if (style.valueFormat === 'date') {
|
|
50572
|
+
return getDateAxisFormatter(locale, dates);
|
|
50573
|
+
}
|
|
50574
|
+
if (style.valueFormat === 'percent') {
|
|
50575
|
+
const percentages = getNumberFormat(locale, {
|
|
50576
|
+
style: 'percent',
|
|
50577
|
+
maximumFractionDigits: countDecimals(range.increment * PERCENT),
|
|
50578
|
+
});
|
|
50579
|
+
return (value) => percentages.format(value);
|
|
50580
|
+
}
|
|
50581
|
+
const largest = Math.max(Math.abs(range.minValue), Math.abs(range.maxValue));
|
|
50582
|
+
const numbers = getNumberFormat(locale, largest >= SHORTEN_FROM
|
|
50583
|
+
? {
|
|
50584
|
+
notation: 'compact',
|
|
50585
|
+
maximumSignificantDigits: countSignificantDigits(largest, range.increment),
|
|
50586
|
+
}
|
|
50587
|
+
: { maximumFractionDigits: countDecimals(range.increment) });
|
|
50588
|
+
return (value) => numbers.format(value);
|
|
50589
|
+
}
|
|
50590
|
+
/**
|
|
50591
|
+
* An item's share of the whole as a percentage with two decimals, such as
|
|
50592
|
+
* `25.00%`, written in the chart's language.
|
|
50593
|
+
* @param share - the share, in percent
|
|
50594
|
+
* @param language - the language of the chart
|
|
50595
|
+
*/
|
|
50596
|
+
function formatShare(share, language) {
|
|
50597
|
+
return getNumberFormat(getLocale(language), SHARE_OPTIONS).format(share / PERCENT);
|
|
50598
|
+
}
|
|
50599
|
+
/**
|
|
50600
|
+
* Whether `currency` can be written as one: a three-letter code such as
|
|
50601
|
+
* `SEK`.
|
|
50602
|
+
* @param currency - the currency of the chart
|
|
50603
|
+
*/
|
|
50604
|
+
function isCurrencyCode(currency) {
|
|
50605
|
+
let valid = currencyCodes.get(currency);
|
|
50606
|
+
if (valid === undefined) {
|
|
50607
|
+
valid = canWriteAmountsIn(currency);
|
|
50608
|
+
currencyCodes.set(currency, valid);
|
|
50609
|
+
}
|
|
50610
|
+
return valid;
|
|
50611
|
+
}
|
|
50612
|
+
function canWriteAmountsIn(currency) {
|
|
50613
|
+
try {
|
|
50614
|
+
getNumberFormat(FALLBACK_LOCALE, { style: 'currency', currency });
|
|
50615
|
+
return true;
|
|
50616
|
+
}
|
|
50617
|
+
catch (_a) {
|
|
50618
|
+
return false;
|
|
50619
|
+
}
|
|
50620
|
+
}
|
|
50621
|
+
/**
|
|
50622
|
+
* Whether values can be written in `language`. When they cannot, they are
|
|
50623
|
+
* written in English.
|
|
50624
|
+
* @param language - the language of the chart
|
|
50625
|
+
*/
|
|
50626
|
+
function canWriteIn(language) {
|
|
50627
|
+
return findLocale(language) !== undefined;
|
|
50628
|
+
}
|
|
50629
|
+
function getValueWriter(style) {
|
|
50630
|
+
if (style.valueFormat === 'date') {
|
|
50631
|
+
const dates = getDateFormat(style.language);
|
|
50632
|
+
return (value) => (isDate(value) ? dates.format(value) : `${value}`);
|
|
50633
|
+
}
|
|
50634
|
+
const numbers = getValueFormat(style);
|
|
50635
|
+
return (value) => numbers.format(value);
|
|
50636
|
+
}
|
|
50637
|
+
/**
|
|
50638
|
+
* Writes the dates on an axis by what it steps through: day and month for
|
|
50639
|
+
* days and weeks, the month for months, and the year for years. The first
|
|
50640
|
+
* date, and the first date of each new year, also get their year, except
|
|
50641
|
+
* January among months, which is written as its year alone.
|
|
50642
|
+
* @param locale - the locale of the chart
|
|
50643
|
+
* @param ticks - the dates the axis marks
|
|
50644
|
+
*/
|
|
50645
|
+
function getDateAxisFormatter(locale, ticks = UNKNOWN_DATE_TICKS) {
|
|
50646
|
+
const years = getDateTimeFormat(locale, { year: 'numeric' });
|
|
50647
|
+
if (ticks.unit === 'year') {
|
|
50648
|
+
return (value) => years.format(value);
|
|
50649
|
+
}
|
|
50650
|
+
const parts = ticks.unit === 'month'
|
|
50651
|
+
? { month: 'short' }
|
|
50652
|
+
: { day: 'numeric', month: 'short' };
|
|
50653
|
+
const dates = getDateTimeFormat(locale, parts);
|
|
50654
|
+
const datesWithYear = getDateTimeFormat(locale, Object.assign(Object.assign({}, parts), { year: 'numeric' }));
|
|
50655
|
+
return (value) => {
|
|
50656
|
+
if (!isFirstOfItsYear(value, ticks.values)) {
|
|
50657
|
+
return dates.format(value);
|
|
50658
|
+
}
|
|
50659
|
+
return ticks.unit === 'month' && new Date(value).getMonth() === 0
|
|
50660
|
+
? years.format(value)
|
|
50661
|
+
: datesWithYear.format(value);
|
|
50662
|
+
};
|
|
50663
|
+
}
|
|
50664
|
+
/**
|
|
50665
|
+
* Whether `value` is the first of `ticks` in its year. A date that is not
|
|
50666
|
+
* one of them counts as the first, so that it gets its year.
|
|
50667
|
+
* @param value - the date
|
|
50668
|
+
* @param ticks - the dates an axis marks
|
|
50669
|
+
*/
|
|
50670
|
+
function isFirstOfItsYear(value, ticks) {
|
|
50671
|
+
const index = ticks.indexOf(value);
|
|
50672
|
+
return (index <= 0 ||
|
|
50673
|
+
new Date(ticks[index - 1]).getFullYear() !==
|
|
50674
|
+
new Date(value).getFullYear());
|
|
50675
|
+
}
|
|
50676
|
+
function getDateFormat(language) {
|
|
50677
|
+
return getDateTimeFormat(getLocale(language), { dateStyle: 'medium' });
|
|
50678
|
+
}
|
|
50679
|
+
function getValueFormat(style) {
|
|
50680
|
+
const locale = getLocale(style.language);
|
|
50681
|
+
if (style.valueFormat === 'percent') {
|
|
50682
|
+
return getNumberWriter(locale, PERCENTAGES);
|
|
50683
|
+
}
|
|
50684
|
+
if (style.valueFormat === 'currency' && isCurrencyCode(style.currency)) {
|
|
50685
|
+
return getNumberFormat(locale, {
|
|
50686
|
+
style: 'currency',
|
|
50687
|
+
currency: style.currency,
|
|
50688
|
+
trailingZeroDisplay: 'stripIfInteger',
|
|
50689
|
+
});
|
|
50690
|
+
}
|
|
50691
|
+
return getNumberWriter(locale, NUMBERS);
|
|
50692
|
+
}
|
|
50693
|
+
/**
|
|
50694
|
+
* The two values of a scatter point, separated by a semicolon when either
|
|
50695
|
+
* of them has a comma in it, such as `(1,5; 2,5)` in Swedish.
|
|
50696
|
+
* @param first - the first value, as text
|
|
50697
|
+
* @param second - the second value, as text
|
|
50698
|
+
*/
|
|
50699
|
+
function writePoint(first, second) {
|
|
50700
|
+
const separator = `${first}${second}`.includes(',') ? '; ' : ', ';
|
|
50701
|
+
return `(${first}${separator}${second})`;
|
|
50702
|
+
}
|
|
50703
|
+
function countDecimals(value) {
|
|
50704
|
+
if (!Number.isFinite(value)) {
|
|
50705
|
+
return 0;
|
|
50706
|
+
}
|
|
50707
|
+
return Math.min(MAX_DECIMALS, Math.max(0, -getLowestDigit(value)));
|
|
50708
|
+
}
|
|
50709
|
+
/**
|
|
50710
|
+
* How many significant digits the values of an axis need for every step
|
|
50711
|
+
* between them to show, such as four for `1.025M` on an axis that steps
|
|
50712
|
+
* by 25 000 up to 2 000 000.
|
|
50713
|
+
* @param largest - the largest value on the axis, ignoring its sign
|
|
50714
|
+
* @param increment - the step between the values
|
|
50715
|
+
*/
|
|
50716
|
+
function countSignificantDigits(largest, increment) {
|
|
50717
|
+
if (!Number.isFinite(increment)) {
|
|
50718
|
+
return MAX_SIGNIFICANT_DIGITS;
|
|
50719
|
+
}
|
|
50720
|
+
const digits = Math.floor(Math.log10(largest)) - getLowestDigit(increment);
|
|
50721
|
+
return Math.min(MAX_SIGNIFICANT_DIGITS, Math.max(1, digits + 1));
|
|
50722
|
+
}
|
|
50723
|
+
/**
|
|
50724
|
+
* The power of ten of the last digit of `value` that is not zero, such as
|
|
50725
|
+
* 3 for 25 000 and -2 for 0.25.
|
|
50726
|
+
* @param value - a finite number
|
|
50727
|
+
*/
|
|
50728
|
+
function getLowestDigit(value) {
|
|
50729
|
+
var _a, _b;
|
|
50730
|
+
const [digits, exponent] = Number(value.toPrecision(12))
|
|
50731
|
+
.toExponential()
|
|
50732
|
+
.split('e', 2);
|
|
50733
|
+
const decimals = (_b = (_a = digits.split('.', 2)[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
50734
|
+
return Number(exponent) - decimals;
|
|
50735
|
+
}
|
|
50736
|
+
function getNumberWriter(locale, style) {
|
|
50737
|
+
const numbers = getNumberFormat(locale, style.options);
|
|
50738
|
+
const small = getNumberFormat(locale, style.small);
|
|
50739
|
+
return {
|
|
50740
|
+
format: (value) => value !== 0 && Math.abs(value) < style.smallBelow
|
|
50741
|
+
? small.format(value)
|
|
50742
|
+
: numbers.format(value),
|
|
50743
|
+
};
|
|
50744
|
+
}
|
|
50745
|
+
/**
|
|
50746
|
+
* Making an `Intl.NumberFormat` costs far more than using one, and values
|
|
50747
|
+
* are written on every render, so each one is made once.
|
|
50748
|
+
* @param locale - the locale to write in
|
|
50749
|
+
* @param options - how to write the numbers
|
|
50750
|
+
*/
|
|
50751
|
+
function getNumberFormat(locale, options) {
|
|
50752
|
+
const key = `${locale} ${JSON.stringify(options)}`;
|
|
50753
|
+
let format = numberFormats.get(key);
|
|
50754
|
+
if (!format) {
|
|
50755
|
+
format = new Intl.NumberFormat(locale, options);
|
|
50756
|
+
numberFormats.set(key, format);
|
|
50757
|
+
}
|
|
50758
|
+
return format;
|
|
50759
|
+
}
|
|
50760
|
+
function getDateTimeFormat(locale, options) {
|
|
50761
|
+
const key = `${locale} ${JSON.stringify(options)}`;
|
|
50762
|
+
let format = dateFormats.get(key);
|
|
50763
|
+
if (!format) {
|
|
50764
|
+
format = new Intl.DateTimeFormat(locale, options);
|
|
50765
|
+
dateFormats.set(key, format);
|
|
50766
|
+
}
|
|
50767
|
+
return format;
|
|
50768
|
+
}
|
|
50769
|
+
/**
|
|
50770
|
+
* The locale to write values in: the chart's language when `Intl` can
|
|
50771
|
+
* write in it, otherwise English.
|
|
50772
|
+
* @param language - the language of the chart
|
|
50773
|
+
*/
|
|
50774
|
+
function getLocale(language) {
|
|
50775
|
+
var _a;
|
|
50776
|
+
return (_a = findLocale(language)) !== null && _a !== void 0 ? _a : FALLBACK_LOCALE;
|
|
50777
|
+
}
|
|
50778
|
+
function findLocale(language$1) {
|
|
50779
|
+
if (!locales.has(language$1)) {
|
|
50780
|
+
locales.set(language$1, language.getSupportedLocale(language$1));
|
|
50781
|
+
}
|
|
50782
|
+
return locales.get(language$1);
|
|
50783
|
+
}
|
|
50784
|
+
|
|
50371
50785
|
const DOT_SIZE = 8;
|
|
50372
50786
|
const LINE_DOT_SIZE = 6;
|
|
50373
50787
|
const CONNECTOR_WIDTH = 2;
|
|
50374
50788
|
const DIMMED_OPACITY = 0.4;
|
|
50375
50789
|
const AREA_OPACITY = 0.4;
|
|
50376
50790
|
const PADDING = 8;
|
|
50377
|
-
const PERCENT_DECIMALS = 2;
|
|
50378
50791
|
const NPS_MIN = -100;
|
|
50379
50792
|
const NPS_MAX = 100;
|
|
50380
50793
|
const NPS_START_ANGLE = 200;
|
|
@@ -50464,8 +50877,8 @@ function getItemLabel(settings, index) {
|
|
|
50464
50877
|
return item.text;
|
|
50465
50878
|
}
|
|
50466
50879
|
const whole = getWholeRange(settings.items, settings.maxValue);
|
|
50467
|
-
const share = getShare(item, whole).
|
|
50468
|
-
return `${item.text} (${share}
|
|
50880
|
+
const share = formatShare(getShare(item, whole), settings.language);
|
|
50881
|
+
return `${item.text} (${share})`;
|
|
50469
50882
|
}
|
|
50470
50883
|
/**
|
|
50471
50884
|
* The tooltip of an item, as HTML: its label and its value.
|
|
@@ -50477,7 +50890,7 @@ function getTooltip(settings, index) {
|
|
|
50477
50890
|
if (!item) {
|
|
50478
50891
|
return '';
|
|
50479
50892
|
}
|
|
50480
|
-
return [getItemLabel(settings, index), formatValue(item, settings
|
|
50893
|
+
return [getItemLabel(settings, index), formatValue(item, settings)]
|
|
50481
50894
|
.map((text) => encodeHTML(text))
|
|
50482
50895
|
.join('<br/>');
|
|
50483
50896
|
}
|
|
@@ -50506,12 +50919,17 @@ function drawSeries(settings, theme, itemSpace) {
|
|
|
50506
50919
|
}
|
|
50507
50920
|
function drawOnAxes(settings, theme, itemSpace) {
|
|
50508
50921
|
const { items, orientation } = settings;
|
|
50509
|
-
const range =
|
|
50922
|
+
const range = settings.valueFormat === 'date'
|
|
50923
|
+
? getDateRange(items.flatMap((item) => [
|
|
50924
|
+
getMinimumValue(item),
|
|
50925
|
+
getMaximumValue(item),
|
|
50926
|
+
]), settings.maxValue)
|
|
50927
|
+
: getAxisRange(items, settings.maxValue, settings.axisIncrement);
|
|
50510
50928
|
const itemTextAxis = getItemTextAxis(settings);
|
|
50511
50929
|
const categoryAxis = Object.assign(Object.assign(Object.assign({}, getCategoryAxis(settings)), { axisLabel: Object.assign({ show: settings.displayItemText, color: theme.textColor }, (itemTextAxis &&
|
|
50512
50930
|
itemSpace &&
|
|
50513
50931
|
getItemTextLayout(itemTextAxis, itemSpace))), axisTick: hidden, axisLine: { lineStyle: { color: theme.axisLineColor } } }), getAxisName(settings, settings.itemsLabel, theme));
|
|
50514
|
-
const valueAxis = getValueAxis(range, getAxisName(settings, settings.valuesLabel, theme), theme);
|
|
50932
|
+
const valueAxis = getValueAxis(range, getAxisName(settings, settings.valuesLabel, theme), settings, theme);
|
|
50515
50933
|
const { series, seriesIndex } = getAxisSeries(settings, theme);
|
|
50516
50934
|
const option = {
|
|
50517
50935
|
grid: getGrid(theme),
|
|
@@ -50674,10 +51092,15 @@ function getRangeStarts(items) {
|
|
|
50674
51092
|
}
|
|
50675
51093
|
function drawScatter(settings, theme) {
|
|
50676
51094
|
const { items } = settings;
|
|
50677
|
-
const ranges =
|
|
51095
|
+
const ranges = settings.valueFormat === 'date'
|
|
51096
|
+
? {
|
|
51097
|
+
x: getDateRange(items.map((item) => getXValue(item))),
|
|
51098
|
+
y: getDateRange(items.map((item) => getYValue(item))),
|
|
51099
|
+
}
|
|
51100
|
+
: getScatterRanges(items);
|
|
50678
51101
|
const landscape = settings.orientation === 'landscape';
|
|
50679
|
-
const firstAxis = getValueAxis(ranges.x, getAxisName(settings, settings.itemsLabel, theme), theme);
|
|
50680
|
-
const secondAxis = getValueAxis(ranges.y, getAxisName(settings, settings.valuesLabel, theme), theme);
|
|
51102
|
+
const firstAxis = getValueAxis(ranges.x, getAxisName(settings, settings.itemsLabel, theme), settings, theme);
|
|
51103
|
+
const secondAxis = getValueAxis(ranges.y, getAxisName(settings, settings.valuesLabel, theme), settings, theme);
|
|
50681
51104
|
const scatter = {
|
|
50682
51105
|
type: 'scatter',
|
|
50683
51106
|
symbolSize: theme.scatterItemSize,
|
|
@@ -50899,8 +51322,10 @@ function getGrid(theme) {
|
|
|
50899
51322
|
borderWidth: 0,
|
|
50900
51323
|
};
|
|
50901
51324
|
}
|
|
50902
|
-
function getValueAxis(range, name, theme) {
|
|
50903
|
-
|
|
51325
|
+
function getValueAxis(range, name, settings, theme) {
|
|
51326
|
+
const dates = settings.valueFormat === 'date' && getDateTicks(range);
|
|
51327
|
+
const ticks = dates && { customValues: dates.values };
|
|
51328
|
+
return Object.assign(Object.assign(Object.assign({ type: 'value', min: range.minValue, max: range.maxValue, interval: dates ? undefined : range.increment, axisLabel: Object.assign({ show: true, color: theme.textColor, formatter: getAxisValueFormatter(range, settings, dates || undefined) }, ticks) }, (ticks && { axisTick: ticks })), { axisLine: { lineStyle: { color: theme.axisLineColor } }, splitLine: { lineStyle: { color: theme.axisLineColor } } }), name);
|
|
50904
51329
|
}
|
|
50905
51330
|
function getAxisName(settings, name, theme) {
|
|
50906
51331
|
if (!settings.displayAxisLabels) {
|
|
@@ -50913,7 +51338,7 @@ function getAxisName(settings, name, theme) {
|
|
|
50913
51338
|
};
|
|
50914
51339
|
}
|
|
50915
51340
|
function getValueLabel(settings, theme) {
|
|
50916
|
-
return Object.assign(Object.assign({ show: settings.displayItemValue, position: settings.orientation === 'landscape' ? 'top' : 'right' }, getLabelStyle(theme)), { formatter: ({ dataIndex }) => formatValue(settings.items[dataIndex], settings
|
|
51341
|
+
return Object.assign(Object.assign({ show: settings.displayItemValue, position: settings.orientation === 'landscape' ? 'top' : 'right' }, getLabelStyle(theme)), { formatter: ({ dataIndex }) => formatValue(settings.items[dataIndex], settings) });
|
|
50917
51342
|
}
|
|
50918
51343
|
function getLabelStyle(theme) {
|
|
50919
51344
|
return { color: theme.textColor, textBorderWidth: 0 };
|
|
@@ -50924,7 +51349,7 @@ function getPointLabel(settings, item) {
|
|
|
50924
51349
|
parts.push(item.text);
|
|
50925
51350
|
}
|
|
50926
51351
|
if (settings.displayItemValue) {
|
|
50927
|
-
parts.push(formatValue(item, settings
|
|
51352
|
+
parts.push(formatValue(item, settings));
|
|
50928
51353
|
}
|
|
50929
51354
|
return parts.join(' ');
|
|
50930
51355
|
}
|
|
@@ -51100,8 +51525,8 @@ const Chart = class {
|
|
|
51100
51525
|
index.registerInstance(this, hostRef);
|
|
51101
51526
|
this.interact = index.createEvent(this, "interact", 7);
|
|
51102
51527
|
/**
|
|
51103
|
-
* Defines the language for translations
|
|
51104
|
-
*
|
|
51528
|
+
* Defines the language for translations, and for the way values are
|
|
51529
|
+
* written, such as `1 234,5` in Swedish.
|
|
51105
51530
|
*/
|
|
51106
51531
|
this.language = 'en';
|
|
51107
51532
|
/**
|
|
@@ -51141,6 +51566,16 @@ const Chart = class {
|
|
|
51141
51566
|
* Does not have any effect on chart types which generate circular forms.
|
|
51142
51567
|
*/
|
|
51143
51568
|
this.orientation = 'landscape';
|
|
51569
|
+
/**
|
|
51570
|
+
* Defines how values are written: as numbers, as percentages where
|
|
51571
|
+
* `0.25` is `25 %`, as amounts of `currency`, or as dates. With `date`,
|
|
51572
|
+
* each value is a date in milliseconds since 1970, and the value axis
|
|
51573
|
+
* steps through days, weeks, months or years. The axes, the values
|
|
51574
|
+
* shown with `displayItemValue`, the tooltips, and the screen reader
|
|
51575
|
+
* table all follow it, in the chart's `language`. An item's
|
|
51576
|
+
* `formattedValue` is shown as it is.
|
|
51577
|
+
*/
|
|
51578
|
+
this.valueFormat = 'number';
|
|
51144
51579
|
/**
|
|
51145
51580
|
* Indicates whether the chart is in a loading state.
|
|
51146
51581
|
*/
|
|
@@ -51150,6 +51585,7 @@ const Chart = class {
|
|
|
51150
51585
|
*/
|
|
51151
51586
|
this.focusedIndex = 0;
|
|
51152
51587
|
this.themeMayHaveChanged = false;
|
|
51588
|
+
this.warnings = new Map();
|
|
51153
51589
|
this.invalidColors = new Set();
|
|
51154
51590
|
this.setPlot = (element) => {
|
|
51155
51591
|
this.plot = element;
|
|
@@ -51214,9 +51650,14 @@ const Chart = class {
|
|
|
51214
51650
|
};
|
|
51215
51651
|
}
|
|
51216
51652
|
componentWillLoad() {
|
|
51217
|
-
this.warnAboutAxisIncrement();
|
|
51218
51653
|
this.warnAboutOldTypeName();
|
|
51219
51654
|
}
|
|
51655
|
+
componentWillRender() {
|
|
51656
|
+
this.warnOnChange('axisIncrement', this.getAxisIncrementWarning());
|
|
51657
|
+
this.warnOnChange('language', this.getLanguageWarning());
|
|
51658
|
+
this.warnOnChange('currency', this.getCurrencyWarning());
|
|
51659
|
+
this.warnOnChange('items', this.getDateWarning());
|
|
51660
|
+
}
|
|
51220
51661
|
connectedCallback() {
|
|
51221
51662
|
this.draw();
|
|
51222
51663
|
}
|
|
@@ -51233,25 +51674,60 @@ const Chart = class {
|
|
|
51233
51674
|
(_c = this.themeReader) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
51234
51675
|
this.themeReader = undefined;
|
|
51235
51676
|
}
|
|
51236
|
-
|
|
51237
|
-
|
|
51238
|
-
if (warning && warning !== this.axisIncrementWarning) {
|
|
51677
|
+
warnOnChange(prop, warning) {
|
|
51678
|
+
if (warning && warning !== this.warnings.get(prop)) {
|
|
51239
51679
|
console.warn(warning);
|
|
51240
51680
|
}
|
|
51241
|
-
this.
|
|
51681
|
+
this.warnings.set(prop, warning);
|
|
51242
51682
|
}
|
|
51243
51683
|
warnAboutOldTypeName() {
|
|
51244
51684
|
if (this.type === 'stacked-bar') {
|
|
51245
51685
|
console.warn('limel-chart: the type `stacked-bar` is now called `proportion-bar`. It draws the same chart, but please use the new name.');
|
|
51246
51686
|
}
|
|
51247
51687
|
}
|
|
51688
|
+
getLanguageWarning() {
|
|
51689
|
+
if (canWriteIn(this.language)) {
|
|
51690
|
+
return;
|
|
51691
|
+
}
|
|
51692
|
+
return `limel-chart: \`language\` must be one that this browser can write values in, such as \`sv\`, but was ${JSON.stringify(this.language)}. Writing the values in English instead.`;
|
|
51693
|
+
}
|
|
51694
|
+
getCurrencyWarning() {
|
|
51695
|
+
if (this.valueFormat !== 'currency' || isCurrencyCode(this.currency)) {
|
|
51696
|
+
return;
|
|
51697
|
+
}
|
|
51698
|
+
return `limel-chart: \`currency\` must be a three-letter code such as \`SEK\` when \`valueFormat\` is \`currency\`, but was ${JSON.stringify(this.currency)}. Writing the values as numbers instead.`;
|
|
51699
|
+
}
|
|
51700
|
+
getDateWarning() {
|
|
51701
|
+
var _a;
|
|
51702
|
+
if (this.valueFormat !== 'date') {
|
|
51703
|
+
return;
|
|
51704
|
+
}
|
|
51705
|
+
const wrong = ((_a = this.items) !== null && _a !== void 0 ? _a : [])
|
|
51706
|
+
.flatMap((item) => [item.value].flat())
|
|
51707
|
+
.find((value) => !isDate(value));
|
|
51708
|
+
if (wrong === undefined) {
|
|
51709
|
+
return;
|
|
51710
|
+
}
|
|
51711
|
+
const shown = typeof wrong === 'number' ? wrong : JSON.stringify(wrong);
|
|
51712
|
+
return `limel-chart: with \`valueFormat\` \`date\`, each value must be a date in milliseconds since 1970, as \`Date.getTime()\` gives, but was ${shown}. Showing it as it is.`;
|
|
51713
|
+
}
|
|
51714
|
+
get valueStyle() {
|
|
51715
|
+
return {
|
|
51716
|
+
type: this.chartType,
|
|
51717
|
+
language: this.language,
|
|
51718
|
+
valueFormat: this.valueFormat,
|
|
51719
|
+
currency: this.currency,
|
|
51720
|
+
};
|
|
51721
|
+
}
|
|
51248
51722
|
get chartType() {
|
|
51249
51723
|
return this.type === 'stacked-bar' ? 'proportion-bar' : this.type;
|
|
51250
51724
|
}
|
|
51251
51725
|
getAxisIncrementWarning() {
|
|
51252
51726
|
var _a;
|
|
51253
51727
|
const increment = this.axisIncrement;
|
|
51254
|
-
if (increment === undefined ||
|
|
51728
|
+
if (increment === undefined ||
|
|
51729
|
+
increment === null ||
|
|
51730
|
+
this.valueFormat === 'date') {
|
|
51255
51731
|
return;
|
|
51256
51732
|
}
|
|
51257
51733
|
if (increment <= 0 || Number.isNaN(increment)) {
|
|
@@ -51291,15 +51767,10 @@ const Chart = class {
|
|
|
51291
51767
|
renderItems() {
|
|
51292
51768
|
var _a, _b;
|
|
51293
51769
|
const tabStop = keyboardNavigation.findTabStop((_a = this.items) !== null && _a !== void 0 ? _a : [], this.focusedIndex);
|
|
51294
|
-
return (_b = this.items) === null || _b === void 0 ? void 0 : _b.map((item, index$1) => (index.h("tr", { "data-index": index$1, "aria-description": this.getRowDescription(index$1), tabIndex: index$1 === tabStop ? 0 : -1, role: item.clickable ? 'button' : null, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur }, index.h("td", null, item.text), index.h("td", null, formatValue(item, this.
|
|
51770
|
+
return (_b = this.items) === null || _b === void 0 ? void 0 : _b.map((item, index$1) => (index.h("tr", { "data-index": index$1, "aria-description": this.getRowDescription(index$1), tabIndex: index$1 === tabStop ? 0 : -1, role: item.clickable ? 'button' : null, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur }, index.h("td", null, item.text), index.h("td", null, formatValue(item, this.valueStyle)))));
|
|
51295
51771
|
}
|
|
51296
51772
|
getRowDescription(index) {
|
|
51297
|
-
const label = getItemLabel({
|
|
51298
|
-
items: this.items,
|
|
51299
|
-
type: this.chartType,
|
|
51300
|
-
maxValue: this.maxValue,
|
|
51301
|
-
displayItemPercentage: this.displayItemPercentage,
|
|
51302
|
-
}, index);
|
|
51773
|
+
const label = getItemLabel(Object.assign(Object.assign({}, this.valueStyle), { items: this.items, maxValue: this.maxValue, displayItemPercentage: this.displayItemPercentage }), index);
|
|
51303
51774
|
return label === this.items[index].text ? undefined : label;
|
|
51304
51775
|
}
|
|
51305
51776
|
draw() {
|
|
@@ -51422,25 +51893,13 @@ const Chart = class {
|
|
|
51422
51893
|
}
|
|
51423
51894
|
getSettings() {
|
|
51424
51895
|
var _a;
|
|
51425
|
-
return {
|
|
51426
|
-
items: ((_a = this.items) !== null && _a !== void 0 ? _a : []).map((item) => ({
|
|
51896
|
+
return Object.assign(Object.assign({ items: ((_a = this.items) !== null && _a !== void 0 ? _a : []).map((item) => ({
|
|
51427
51897
|
text: item.text,
|
|
51428
51898
|
value: item.value,
|
|
51429
51899
|
formattedValue: item.formattedValue,
|
|
51430
51900
|
color: item.color,
|
|
51431
51901
|
clickable: item.clickable,
|
|
51432
|
-
})),
|
|
51433
|
-
type: this.chartType,
|
|
51434
|
-
orientation: this.orientation,
|
|
51435
|
-
maxValue: this.maxValue,
|
|
51436
|
-
axisIncrement: this.axisIncrement,
|
|
51437
|
-
displayAxisLabels: this.displayAxisLabels,
|
|
51438
|
-
itemsLabel: this.itemsLabel,
|
|
51439
|
-
valuesLabel: this.valuesLabel,
|
|
51440
|
-
displayItemText: this.displayItemText,
|
|
51441
|
-
displayItemValue: this.displayItemValue,
|
|
51442
|
-
displayItemPercentage: this.displayItemPercentage,
|
|
51443
|
-
};
|
|
51902
|
+
})) }, this.valueStyle), { orientation: this.orientation, maxValue: this.maxValue, axisIncrement: this.axisIncrement, displayAxisLabels: this.displayAxisLabels, itemsLabel: this.itemsLabel, valuesLabel: this.valuesLabel, displayItemText: this.displayItemText, displayItemValue: this.displayItemValue, displayItemPercentage: this.displayItemPercentage });
|
|
51444
51903
|
}
|
|
51445
51904
|
withItemColors(settings, theme) {
|
|
51446
51905
|
return Object.assign(Object.assign({}, settings), { items: settings.items.map((item) => (Object.assign(Object.assign({}, item), { color: this.getItemColor(item, theme) }))) });
|
|
@@ -51515,18 +51974,7 @@ const Chart = class {
|
|
|
51515
51974
|
}
|
|
51516
51975
|
get host() { return index.getElement(this); }
|
|
51517
51976
|
static get watchers() { return {
|
|
51518
|
-
"axisIncrement": [{
|
|
51519
|
-
"warnAboutAxisIncrement": 0
|
|
51520
|
-
}],
|
|
51521
|
-
"items": [{
|
|
51522
|
-
"warnAboutAxisIncrement": 0
|
|
51523
|
-
}],
|
|
51524
|
-
"maxValue": [{
|
|
51525
|
-
"warnAboutAxisIncrement": 0
|
|
51526
|
-
}],
|
|
51527
51977
|
"type": [{
|
|
51528
|
-
"warnAboutAxisIncrement": 0
|
|
51529
|
-
}, {
|
|
51530
51978
|
"warnAboutOldTypeName": 0
|
|
51531
51979
|
}]
|
|
51532
51980
|
}; }
|