@hestia-earth/ui-components-charts 0.43.23 → 0.43.24

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/dist/index.d.mts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as chart_js from 'chart.js';
2
- import { ChartDataset, Chart, BarOptions, Plugin, ChartEvent, Color, Scale } from 'chart.js';
3
- import { IImpactAssessmentJSONLD } from '@hestia-earth/schema';
2
+ import { ChartDataset, Chart, BarOptions, Plugin, ChartEvent, Color, Scale, ActiveElement, ChartData, ChartConfiguration, ChartComponentLike } from 'chart.js';
3
+ import { Selection } from 'd3-selection';
4
+ import { AnnotationOptions } from 'chartjs-plugin-annotation';
5
+ import * as _hestia_earth_schema from '@hestia-earth/schema';
6
+ import { IImpactAssessmentJSONLD, ITermJSONLD, Term, TermTermType } from '@hestia-earth/schema';
7
+ import { HierarchyPointNode } from 'd3-hierarchy';
4
8
 
5
9
  interface BarChartDataItem {
6
10
  label?: string;
@@ -108,6 +112,18 @@ declare const defaultTicksFont: {
108
112
  * Maximum length of an axis label, past which the charts truncate it.
109
113
  */
110
114
  declare const chartLabelMaxLength = 50;
115
+ /** What every chart starts from: it fills its container, without Chart.js' own legend. */
116
+ declare const defaultChartSettings: Readonly<{
117
+ options: {
118
+ responsive: boolean;
119
+ maintainAspectRatio: boolean;
120
+ plugins: {
121
+ legend: {
122
+ display: boolean;
123
+ };
124
+ };
125
+ };
126
+ }>;
111
127
 
112
128
  interface ContributionChartDataItem {
113
129
  id?: string;
@@ -155,68 +171,7 @@ declare const sumValues: (values: number[]) => number;
155
171
  */
156
172
  declare const groupDataByCategory: (data: ContributionChartDataItem[], labels: string[], category: string, { emissionCategoryValue, categoryLabel }: IContributionCategory) => ContributionChartDataItem[];
157
173
 
158
- declare const escape: (value: string) => string;
159
- declare const toLine: (values: any[]) => string;
160
-
161
- interface IEmissionCategory {
162
- key: string;
163
- label: string;
164
- }
165
- declare const categoryLabel: (key: string) => string;
166
- /**
167
- * The list of all available categories.
168
- */
169
- declare const emissionCategories: IEmissionCategory[];
170
- /**
171
- * Return all possible values for a specific Category.
172
- *
173
- * @param category {string} The specific category
174
- * @returns List of all values possible for this Category.
175
- */
176
- declare const categoryValues: (category: string) => string[];
177
- /**
178
- * Return the different categories available for a single Emission.
179
- *
180
- * @param emissionId The `@id` of the Emission
181
- * @returns List of categories.
182
- */
183
- declare const emissionCategoriesOf: (emissionId: string) => string[];
184
- /**
185
- * Return the Category value for a specific Emission and Category.
186
- *
187
- * @param emissionId The `@id` of the Emission
188
- * @param category The Category
189
- * @returns The value
190
- */
191
- declare const emissionCategoryValue: (emissionId: string, category: string) => string;
192
-
193
- declare const defaultHorizontalBarConfig: Readonly<{
194
- options: {
195
- indexAxis: "y";
196
- scales: {
197
- x: {
198
- grid: {
199
- drawOnChartArea: false;
200
- };
201
- ticks: {
202
- callback: (this: chart_js.Scale, value: string | number) => number;
203
- };
204
- };
205
- y: {
206
- grid: {
207
- drawOnChartArea: false;
208
- };
209
- ticks: {
210
- crossAlign: "near";
211
- };
212
- };
213
- };
214
- };
215
- }>;
216
- /** The text of the tooltip on one bar: its label and value, or every item it groups. */
217
- declare const defaultHorizontalTooltip: ({ label, count, includedItems }: BarChartDataItem) => string;
218
- /** The chart's height for this many bars, kept between the two bounds. */
219
- declare const horizontalBarHeight: (minHeight: number, maxHeight: number, nbRows: number) => number;
174
+ type AnyObject = Record<string, any>;
220
175
 
221
176
  type placement = 'left' | 'right';
222
177
  type positionFn = (n: number, index: number, width: number, chart: Chart, data?: number | number[], placement?: placement) => number;
@@ -292,6 +247,401 @@ declare const lollipopChartPlugin: (settings?: LollipopPluginSettings) => Plugin
292
247
 
293
248
  declare const increaseScaleLimits: (scale: Scale, handleMinScaleZero?: boolean) => void;
294
249
 
250
+ declare const contributionBarHeight = 8;
251
+ declare const contributionHoverHeight = 10;
252
+ declare const defaultContributionSettings: Readonly<{
253
+ type: "bar";
254
+ options: {
255
+ indexAxis: "y";
256
+ responsive: true;
257
+ plugins: {
258
+ tooltip: {
259
+ enabled: false;
260
+ };
261
+ legend: {
262
+ display: false;
263
+ };
264
+ };
265
+ scales: {
266
+ x: {
267
+ stacked: true;
268
+ display: true;
269
+ grid: {
270
+ display: true;
271
+ drawOnChartArea: true;
272
+ };
273
+ ticks: {
274
+ font: {
275
+ family: string;
276
+ size: number;
277
+ };
278
+ callback: (this: chart_js.Scale, label: string | number) => string;
279
+ };
280
+ };
281
+ y: {
282
+ stacked: true;
283
+ display: true;
284
+ position: "left";
285
+ grid: {
286
+ display: true;
287
+ drawOnChartArea: false;
288
+ drawTicks: true;
289
+ tickLength: number;
290
+ offset: false;
291
+ };
292
+ ticks: {
293
+ color: string;
294
+ padding: number;
295
+ crossAlign: "center";
296
+ font: {
297
+ weight: number;
298
+ family: string;
299
+ size: number;
300
+ };
301
+ callback: (this: chart_js.Scale, value: string | number) => string;
302
+ };
303
+ };
304
+ };
305
+ };
306
+ }>;
307
+ /** The chart's height for this many stacks, kept between the two bounds. */
308
+ declare const contributionChartHeight: (minHeight: number, maxHeight: number, nbRows: number) => number;
309
+ /** The middle of a stack across the datasets drawn, where its tooltip opens. */
310
+ declare const datasetCenter: (chart: Chart, index: number) => number;
311
+ declare const contributionItemColor: (item: ContributionChartDataItem) => string;
312
+ /** Each item's value in one stack, with its own items, largest first, without the items it lacks. */
313
+ declare const dataAtIndex: (data: ContributionChartDataItem[], index: number, includeItems?: boolean) => {
314
+ value: number;
315
+ includedItems: {
316
+ value: number;
317
+ id?: string;
318
+ label: string;
319
+ values: number[];
320
+ color?: string;
321
+ backgroundColor?: string;
322
+ borderColor?: string;
323
+ includedItems?: ContributionChartDataItem[];
324
+ }[];
325
+ id?: string;
326
+ label: string;
327
+ values: number[];
328
+ color?: string;
329
+ backgroundColor?: string;
330
+ borderColor?: string;
331
+ }[];
332
+ declare const contributionCsv: (labels: string[], data: ContributionChartDataItem[]) => string;
333
+ declare const hasNegativeValues: (data?: ContributionChartDataItem[]) => boolean;
334
+ /** One stacked dataset per item, each keeping the items it groups for the tooltip. */
335
+ declare const contributionData: (data: ContributionChartDataItem[], labels: string[]) => {
336
+ datasets: {
337
+ label: string;
338
+ data: number[];
339
+ backgroundColor: string;
340
+ borderColor: string;
341
+ barThickness: number;
342
+ maxBarThickness: number;
343
+ includedItems: ContributionChartDataItem[];
344
+ }[];
345
+ labels: string[];
346
+ };
347
+ interface ContributionChartSettings {
348
+ onClick: (event: ChartEvent, activeElements: ActiveElement[], chart: Chart) => void;
349
+ /** Axis labels interactive, through the axis hover plugin. */
350
+ axis?: AxisHoverSettings;
351
+ /** The x axis title. */
352
+ label?: string;
353
+ hasNegativeValues: boolean;
354
+ /** Axes are hidden on a small screen. */
355
+ mobile: boolean;
356
+ }
357
+ /** The contribution chart's own configuration, to merge over `defaultContributionSettings`. */
358
+ declare const contributionChartConfig: ({ onClick, axis, label, hasNegativeValues: negative, mobile }: ContributionChartSettings) => {
359
+ options: {
360
+ onClick: (event: ChartEvent, activeElements: ActiveElement[], chart: Chart) => void;
361
+ plugins: any;
362
+ scales: {
363
+ x: {
364
+ display: boolean;
365
+ afterDataLimits: (scale: chart_js.Scale<chart_js.CoreScaleOptions>) => void;
366
+ title: {
367
+ display: boolean;
368
+ text: string;
369
+ };
370
+ grid: {
371
+ lineWidth: (context: chart_js.ScriptableScaleContext) => 0 | 1;
372
+ };
373
+ };
374
+ y: {
375
+ display: boolean;
376
+ };
377
+ };
378
+ };
379
+ plugins: (Plugin<keyof chart_js.ChartTypeRegistry, AnyObject> | {
380
+ id: string;
381
+ afterEvent: (chart: Chart, args: {
382
+ event: ChartEvent;
383
+ changed?: boolean;
384
+ }) => void;
385
+ beforeDraw: (chart: Chart) => void;
386
+ })[];
387
+ };
388
+
389
+ declare const escape: (value: string) => string;
390
+ declare const toLine: (values: any[]) => string;
391
+
392
+ declare const d3ellipse: <Datum>(selection: Selection<SVGTextElement, Datum, any, any>, maxWidth: number, ellipsisStr?: string) => void;
393
+ declare const d3wrap: <Datum>(t: Selection<SVGTextElement, Datum, any, any>, { maxWidth, maxLines, words, nHeight, lHeight, vcentre, ownLineWord }: {
394
+ maxWidth: number;
395
+ maxLines: number;
396
+ words: string[];
397
+ nHeight: number;
398
+ lHeight: number;
399
+ vcentre?: boolean;
400
+ ownLineWord?: string;
401
+ }) => void;
402
+
403
+ interface HistogramChartDataItem {
404
+ label: string;
405
+ values: number[];
406
+ color?: string;
407
+ backgroundColor?: string;
408
+ borderColor?: string;
409
+ }
410
+ declare const defaultDistributionSettings: Readonly<{
411
+ type: "line";
412
+ options: {
413
+ events: any[];
414
+ responsive: true;
415
+ plugins: {
416
+ tooltip: {
417
+ enabled: false;
418
+ };
419
+ legend: {
420
+ display: false;
421
+ align: "center";
422
+ };
423
+ };
424
+ scales: {
425
+ y: {
426
+ display: true;
427
+ position: "left";
428
+ grid: {
429
+ display: true;
430
+ };
431
+ beginAtZero: true;
432
+ ticks: {
433
+ crossAlign: "center";
434
+ };
435
+ };
436
+ };
437
+ };
438
+ }>;
439
+ /** What the distribution chart is given: samples to bin, or the parameters of a normal curve. */
440
+ interface DistributionChartInputs {
441
+ distribution?: number[];
442
+ value?: number;
443
+ label?: string;
444
+ nbBins?: number;
445
+ maxPercentile?: number;
446
+ mu?: number;
447
+ sd?: number;
448
+ intervalMin?: number;
449
+ intervalMax?: number;
450
+ minX?: number;
451
+ }
452
+ /** `sd` must be strictly positive: a zero or negative deviation makes the PDF a division by zero. */
453
+ declare const isParametric: ({ mu, sd }: DistributionChartInputs) => boolean;
454
+ /**
455
+ * The distribution chart's data and configuration: a histogram of the samples with the value marked, or
456
+ * the normal curve with its interval, mean and value, when only the parameters are known.
457
+ */
458
+ declare const distributionChart: (inputs: DistributionChartInputs) => {
459
+ data: ChartData<"bar" | "line">;
460
+ config: Readonly<{
461
+ type: "line";
462
+ options: {
463
+ events: any[];
464
+ responsive: true;
465
+ plugins: {
466
+ tooltip: {
467
+ enabled: false;
468
+ };
469
+ legend: {
470
+ display: false;
471
+ align: "center";
472
+ };
473
+ };
474
+ scales: {
475
+ y: {
476
+ display: true;
477
+ position: "left";
478
+ grid: {
479
+ display: true;
480
+ };
481
+ beginAtZero: true;
482
+ ticks: {
483
+ crossAlign: "center";
484
+ };
485
+ };
486
+ };
487
+ };
488
+ }> & {
489
+ options: {
490
+ plugins: {
491
+ annotation: {
492
+ annotations: Record<string, AnnotationOptions>;
493
+ };
494
+ };
495
+ scales: {
496
+ x: {
497
+ type: "linear";
498
+ display: true;
499
+ ticks: {
500
+ font: {
501
+ family: string;
502
+ size: number;
503
+ weight: number;
504
+ };
505
+ color: string;
506
+ callback: (this: chart_js.Scale, tick: string | number) => string;
507
+ };
508
+ title: {
509
+ display: true;
510
+ text: string;
511
+ };
512
+ };
513
+ y: {
514
+ ticks: {
515
+ display: false;
516
+ };
517
+ grid: {
518
+ display: false;
519
+ };
520
+ title: {
521
+ display: false;
522
+ };
523
+ };
524
+ };
525
+ };
526
+ };
527
+ } | {
528
+ data: ChartData<"bar" | "line">;
529
+ config: Readonly<{
530
+ type: "line";
531
+ options: {
532
+ events: any[];
533
+ responsive: true;
534
+ plugins: {
535
+ tooltip: {
536
+ enabled: false;
537
+ };
538
+ legend: {
539
+ display: false;
540
+ align: "center";
541
+ };
542
+ };
543
+ scales: {
544
+ y: {
545
+ display: true;
546
+ position: "left";
547
+ grid: {
548
+ display: true;
549
+ };
550
+ beginAtZero: true;
551
+ ticks: {
552
+ crossAlign: "center";
553
+ };
554
+ };
555
+ };
556
+ };
557
+ }> & {
558
+ options: {
559
+ scales: {
560
+ x: {
561
+ display: true;
562
+ grid: {
563
+ offset: true;
564
+ };
565
+ min: number;
566
+ ticks: {
567
+ callback: (this: chart_js.Scale, value: string | number) => string;
568
+ };
569
+ title: {
570
+ display: true;
571
+ text: string;
572
+ };
573
+ };
574
+ y: {
575
+ ticks: {
576
+ font: {
577
+ family: string;
578
+ size: number;
579
+ weight: number;
580
+ };
581
+ color: string;
582
+ };
583
+ title: {
584
+ display: true;
585
+ text: string;
586
+ };
587
+ };
588
+ };
589
+ };
590
+ };
591
+ };
592
+
593
+ /** Saves `url` as `fileName` through a temporary link, then frees an object URL it was given. */
594
+ declare const downloadFile: (url: string, fileName: string) => void;
595
+
596
+ interface IEmissionCategory {
597
+ key: string;
598
+ label: string;
599
+ }
600
+ declare const categoryLabel: (key: string) => string;
601
+ /**
602
+ * The list of all available categories.
603
+ */
604
+ declare const emissionCategories: IEmissionCategory[];
605
+ /**
606
+ * Return all possible values for a specific Category.
607
+ *
608
+ * @param category {string} The specific category
609
+ * @returns List of all values possible for this Category.
610
+ */
611
+ declare const categoryValues: (category: string) => string[];
612
+ /**
613
+ * Return the different categories available for a single Emission.
614
+ *
615
+ * @param emissionId The `@id` of the Emission
616
+ * @returns List of categories.
617
+ */
618
+ declare const emissionCategoriesOf: (emissionId: string) => string[];
619
+ /**
620
+ * Return the Category value for a specific Emission and Category.
621
+ *
622
+ * @param emissionId The `@id` of the Emission
623
+ * @param category The Category
624
+ * @returns The value
625
+ */
626
+ declare const emissionCategoryValue: (emissionId: string, category: string) => string;
627
+
628
+ interface ChartExportMetadata {
629
+ title?: string;
630
+ fileName?: string;
631
+ width?: number;
632
+ height?: number;
633
+ units?: string;
634
+ lollipopConfig?: Omit<LollipopPluginSettings, 'isMouseInsideLollipopFn'>;
635
+ afterBarDrawConfig?: AfterBarDrawSettings | AfterBarDrawSettings[];
636
+ }
637
+ declare const convertToSvg: (config: Partial<ChartConfiguration>, metadata?: ChartExportMetadata) => Promise<string>;
638
+ declare const exportAsSVG: (config: Partial<ChartConfiguration>, metadata: ChartExportMetadata) => Promise<void>;
639
+ declare const downloadSvg: (svgElement: HTMLElement) => void;
640
+ declare const downloadPng: (svgElement: HTMLElement, { width, height }?: {
641
+ width?: number;
642
+ height?: number;
643
+ }) => Promise<void>;
644
+
295
645
  /** How much each indicator, by its position on the node, contributes to each other indicator, per method. */
296
646
  type contributions = Record<string, Record<string, number>>;
297
647
  /** The contributions file the engine writes beside an ImpactAssessment. */
@@ -365,4 +715,255 @@ declare const breakdownScale: (values: IContributionLog[]) => {
365
715
  };
366
716
  };
367
717
 
368
- export { type AfterBarDrawSettings, type AxisHoverSettings, type AxisLabelEvent, type BarChartDataItem, ColorPalette, type ContributionChartDataItem, type ContributionTooltipData, type IContributionCategory, type IContributionLog, type IEmissionCategory, type INodeContributions, type LollipopPluginSettings, type RgbColor, afterBarDrawPlugin, axisHoverPlugin, axisLabelCursor, backgroundHoverPlugin, barDataset, breakdownBarText, breakdownBars, breakdownScale, breakdownTooltip, categoryLabel, categoryValues, chartBreakdownLabel, chartLabel, chartLabelMaxLength, colorToRgba, type contributions, defaultBarDatasets, defaultBarSettings, defaultHorizontalBarConfig, defaultHorizontalTooltip, defaultTicksFont, emissionCategories, emissionCategoriesOf, emissionCategoryValue, escape, getColor, groupDataByCategory, groupLogsById, hasNegativeContributions, hexToRgba, horizontalBarHeight, increaseScaleLimits, indicatorLogs, listColor, listColorContinuous, listColorWithAlpha, logToCsv, logsTotalValue, lollipopChartPlugin, namedContributors, nonZeroContributors, parseColor, parseContributions, sumValues, toLine, valueRatio, withOthers };
718
+ type termType = Partial<ITermJSONLD | Term>;
719
+ declare enum ChartNodeType {
720
+ midpoint = "midpoint",
721
+ category = "category",
722
+ emission = "emission",
723
+ endpoint = "endpoint",
724
+ input = "input",
725
+ operation = "operation",
726
+ root = "root"
727
+ }
728
+ declare const nodeBorderColours: {
729
+ endpoint: string;
730
+ midpoint: string;
731
+ category: string;
732
+ emission: string;
733
+ input: string;
734
+ operation: string;
735
+ };
736
+ declare const nodeColours: {
737
+ endpoint: string;
738
+ midpoint: string;
739
+ category: string;
740
+ emission: string;
741
+ input: string;
742
+ operation: string;
743
+ };
744
+ declare const legend: {
745
+ type: ChartNodeType;
746
+ text: string;
747
+ }[];
748
+ interface NodeDatum {
749
+ id?: string;
750
+ terms?: termType[];
751
+ modelId?: string;
752
+ modelName?: string;
753
+ modelDocs?: string;
754
+ label: string;
755
+ type: ChartNodeType;
756
+ value: number | null;
757
+ weightedValue?: number | null;
758
+ fraction?: number;
759
+ children?: NodeDatum[];
760
+ group?: boolean;
761
+ showBar?: boolean;
762
+ units: string;
763
+ }
764
+ interface IChartInputLog {
765
+ id: string;
766
+ label: string;
767
+ units: string;
768
+ weightedValue: number;
769
+ value: number;
770
+ operations: IChartInputLog[];
771
+ }
772
+ interface IChartData {
773
+ indicator: string;
774
+ category?: string;
775
+ categoryLabel?: string;
776
+ contributor: string;
777
+ coefficient: number;
778
+ value: number;
779
+ weightedValue: number;
780
+ modelId: string;
781
+ inputs?: IChartInputLog[];
782
+ }
783
+ /** A Term as the chart names it; a search result's score and fields may come along. */
784
+ type term = ITermJSONLD & {
785
+ _score?: number;
786
+ docs?: string;
787
+ };
788
+ interface ITermMapping {
789
+ [id: string]: term;
790
+ }
791
+ declare const getUnitsAndLabel: (terms: termType | termType[], fallbackLabel?: string) => {
792
+ label: string;
793
+ terms: termType[];
794
+ units: string;
795
+ };
796
+ interface IIndicatorsSum {
797
+ [indicator: string]: number;
798
+ }
799
+ declare const sumIndicators: (data: IChartData[]) => IIndicatorsSum;
800
+ declare const groupIndicators: (data: IChartData[], terms?: ITermMapping, totals?: IIndicatorsSum) => {
801
+ [id: string]: NodeDatum;
802
+ };
803
+
804
+ /** The terms the driver chart names: what contributes, what is contributed to, and the models. */
805
+ declare const hierarchyTermTypes: TermTermType[];
806
+ declare const defaultIndicatorsModelId = "defaultIndicatorsModelId";
807
+ declare const defaultIndicatorsModelName = "Default Indicators (multi-model)";
808
+ /** HESTIA's default model for an indicator, from the glossary. */
809
+ declare const defaultModelId: (indicatorId: string) => string;
810
+ /** What the chart cannot show as it should: a contribution naming a term it has not been given. */
811
+ declare const hierarchyWarnings: (logs: IChartData[], terms: {
812
+ [id: string]: term;
813
+ }) => string[];
814
+ /**
815
+ * The driver chart's data from the contributions file: one contribution per indicator, contributor and
816
+ * model, with the inputs and operations the contributor came from.
817
+ */
818
+ declare const hierarchyContributions: (impactAssessment: IImpactAssessmentJSONLD, stored: INodeContributions) => IChartData[];
819
+ /** The terms the contributions name that `terms` does not have yet, to look up. */
820
+ declare const missingTermIds: (logs: IChartData[], terms?: ITermMapping) => string[];
821
+ /** The models to choose from: HESTIA's default indicators first when any contribution uses one. */
822
+ declare const hierarchyModels: (logs: IChartData[], terms: ITermMapping) => Partial<ITermJSONLD>[];
823
+ /** The contributions of one model, each emission or resource use in its category when one is chosen. */
824
+ declare const hierarchyData: (logs: IChartData[], terms: ITermMapping, modelId: string, category?: string) => IChartData[];
825
+
826
+ declare const nonLCAIndicatorsId = "nonLCAIndicators";
827
+ type Indicators = ReturnType<typeof groupIndicators>;
828
+ /** Endpoints linked to their midpoints, and midpoints to any midpoint below them, each listed once. */
829
+ declare const linkIndicators: (indicators: Indicators) => {
830
+ children: NodeDatum[];
831
+ id?: string;
832
+ terms?: (Partial<_hestia_earth_schema.Term> | Partial<_hestia_earth_schema.ITermJSONLD>)[];
833
+ modelId?: string;
834
+ modelName?: string;
835
+ modelDocs?: string;
836
+ label: string;
837
+ type: ChartNodeType;
838
+ value: number | null;
839
+ weightedValue?: number | null;
840
+ fraction?: number;
841
+ group?: boolean;
842
+ showBar?: boolean;
843
+ units: string;
844
+ }[];
845
+ /**
846
+ * The tree's first layer: the endpoints, with the midpoints no endpoint covers under "Other
847
+ * indicators"; or, without endpoints, every indicator.
848
+ */
849
+ declare const hierarchyChildren: (data: IChartData[], terms: ITermMapping) => NodeDatum[];
850
+ /** The legend for the layers drawn, naming the category layer after the category chosen. */
851
+ declare const hierarchyLegend: (data: IChartData[], includedTypes: ChartNodeType[]) => {
852
+ type: ChartNodeType;
853
+ text: string;
854
+ }[];
855
+ /** The chart's data as CSV: a line per contribution, then its inputs and their operations. */
856
+ declare const hierarchyCsv: (data: IChartData[], terms: ITermMapping) => string;
857
+
858
+ /** Where a node's tooltip links to: the platform the chart is shown on. */
859
+ interface HierarchyUrls {
860
+ baseUrl: () => string;
861
+ schemaBaseUrl: () => string;
862
+ }
863
+ /** The tooltip each application draws itself, opened on a node with what it should say. */
864
+ interface HierarchyTooltip {
865
+ open: (tipData: HierarchyTipData, target: Element) => void;
866
+ close: () => void;
867
+ /** The tooltip's element while open, so that moving onto it keeps it open. */
868
+ element: () => Element | null;
869
+ }
870
+ interface HierarchyChartOptions {
871
+ data: IChartData[];
872
+ terms: ITermMapping;
873
+ tooltip: HierarchyTooltip;
874
+ urls: HierarchyUrls;
875
+ }
876
+ interface ChartNode extends HierarchyPointNode<NodeDatum> {
877
+ _children?: ChartNode[];
878
+ _groupChildren?: ChartNode[];
879
+ _open?: boolean;
880
+ _greyed?: boolean;
881
+ _groupOpen?: boolean;
882
+ _timeout?: ReturnType<typeof setTimeout>;
883
+ }
884
+ declare const generateTipData: (nodeDatum: ChartNode, { baseUrl, schemaBaseUrl }: HierarchyUrls) => {
885
+ hasWeightedValue: number;
886
+ weightedValueText: string;
887
+ valueKeyHref: string;
888
+ modelDocsHref: string;
889
+ valueValueText: string;
890
+ hasValue: number;
891
+ modelKeyHref: string;
892
+ modelValue: string;
893
+ modelValueHref: string;
894
+ termKeyHref: string;
895
+ terms: {
896
+ text: any;
897
+ href: string;
898
+ }[];
899
+ };
900
+ type HierarchyTipData = ReturnType<typeof generateTipData>;
901
+ /**
902
+ * Draws the platform's driver chart into `svgElement`: the endpoints, opening onto what drives them,
903
+ * down to the inputs and operations behind each emission. The tree is the chart's own state, kept here
904
+ * between clicks; the application gives the data, the terms, its tooltip and the platform's links.
905
+ *
906
+ * Give the svg, or an element around it, the class `hestia-hierarchy-chart`, and import
907
+ * `@hestia-earth/ui-components-charts/hierarchy-chart.css` once: only the nodes take the pointer.
908
+ *
909
+ * @returns The layers drawn, for a legend.
910
+ */
911
+ declare const drawHierarchyChart: (svgElement: SVGSVGElement, { data, terms, tooltip, urls }: HierarchyChartOptions) => {
912
+ includedTypes: ChartNodeType[];
913
+ };
914
+
915
+ declare const defaultHorizontalBarConfig: Readonly<{
916
+ options: {
917
+ indexAxis: "y";
918
+ scales: {
919
+ x: {
920
+ grid: {
921
+ drawOnChartArea: false;
922
+ };
923
+ ticks: {
924
+ callback: (this: chart_js.Scale, value: string | number) => number;
925
+ };
926
+ };
927
+ y: {
928
+ grid: {
929
+ drawOnChartArea: false;
930
+ };
931
+ ticks: {
932
+ crossAlign: "near";
933
+ };
934
+ };
935
+ };
936
+ };
937
+ }>;
938
+ /** The text of the tooltip on one bar: its label and value, or every item it groups. */
939
+ declare const defaultHorizontalTooltip: ({ label, count, includedItems }: BarChartDataItem) => string;
940
+ /** The chart's height for this many bars, kept between the two bounds. */
941
+ declare const horizontalBarHeight: (minHeight: number, maxHeight: number, nbRows: number) => number;
942
+
943
+ /** A line chart over time, a point a day. */
944
+ declare const defaultLineSettings: Readonly<{
945
+ type: "line";
946
+ options: {
947
+ scales: {
948
+ x: {
949
+ type: "time";
950
+ time: {
951
+ unit: "day";
952
+ };
953
+ ticks: {
954
+ font: {
955
+ family: string;
956
+ size: number;
957
+ };
958
+ };
959
+ };
960
+ };
961
+ };
962
+ }>;
963
+
964
+ /** A number at `precision` significant digits, with thousands separators; anything else as it is. */
965
+ declare const formatPrecision: (value: string | number | boolean, precision?: string | number, enableComma?: boolean) => string | number | boolean;
966
+
967
+ declare const registerChart: (items?: ChartComponentLike[]) => () => void;
968
+
969
+ export { type AfterBarDrawSettings, type AxisHoverSettings, type AxisLabelEvent, type BarChartDataItem, type ChartExportMetadata, ChartNodeType, ColorPalette, type ContributionChartDataItem, type ContributionChartSettings, type ContributionTooltipData, type DistributionChartInputs, type HierarchyChartOptions, type HierarchyTipData, type HierarchyTooltip, type HierarchyUrls, type HistogramChartDataItem, type IChartData, type IChartInputLog, type IContributionCategory, type IContributionLog, type IEmissionCategory, type INodeContributions, type ITermMapping, type LollipopPluginSettings, type NodeDatum, type RgbColor, afterBarDrawPlugin, axisHoverPlugin, axisLabelCursor, backgroundHoverPlugin, barDataset, breakdownBarText, breakdownBars, breakdownScale, breakdownTooltip, categoryLabel, categoryValues, chartBreakdownLabel, chartLabel, chartLabelMaxLength, colorToRgba, contributionBarHeight, contributionChartConfig, contributionChartHeight, contributionCsv, contributionData, contributionHoverHeight, contributionItemColor, type contributions, convertToSvg, d3ellipse, d3wrap, dataAtIndex, datasetCenter, defaultBarDatasets, defaultBarSettings, defaultChartSettings, defaultContributionSettings, defaultDistributionSettings, defaultHorizontalBarConfig, defaultHorizontalTooltip, defaultIndicatorsModelId, defaultIndicatorsModelName, defaultLineSettings, defaultModelId, defaultTicksFont, distributionChart, downloadFile, downloadPng, downloadSvg, drawHierarchyChart, emissionCategories, emissionCategoriesOf, emissionCategoryValue, escape, exportAsSVG, formatPrecision, getColor, getUnitsAndLabel, groupDataByCategory, groupIndicators, groupLogsById, hasNegativeContributions, hasNegativeValues, hexToRgba, hierarchyChildren, hierarchyContributions, hierarchyCsv, hierarchyData, hierarchyLegend, hierarchyModels, hierarchyTermTypes, hierarchyWarnings, horizontalBarHeight, increaseScaleLimits, indicatorLogs, isParametric, legend, linkIndicators, listColor, listColorContinuous, listColorWithAlpha, logToCsv, logsTotalValue, lollipopChartPlugin, missingTermIds, namedContributors, nodeBorderColours, nodeColours, nonLCAIndicatorsId, nonZeroContributors, parseColor, parseContributions, registerChart, sumIndicators, sumValues, type term, toLine, valueRatio, withOthers };