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