@evergis/charts 2.0.53 → 2.0.56

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.
@@ -1,5 +1,5 @@
1
1
  import * as d3 from 'd3';
2
- import { BarChartLinetData } from '../types';
2
+ import { BarChartLineData } from '../types';
3
3
  import { DrawLinesProps } from './types';
4
4
  export declare const barChartLinesClassNames: {
5
5
  barChartLinesGlobal: string;
@@ -8,7 +8,7 @@ export declare const barChartLinesClassNames: {
8
8
  barChartArea: string;
9
9
  };
10
10
  export declare const drawLines: ({ svg, lineData, min, yScale, xScale, curve, stackedLine, }: DrawLinesProps) => {
11
- areasSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLinetData, SVGGElement, unknown> | null;
12
- linesSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLinetData, SVGGElement, unknown> | null;
11
+ areasSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLineData, SVGGElement, unknown> | null;
12
+ linesSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLineData, SVGGElement, unknown> | null;
13
13
  area: d3.Area<[number, number]> | null;
14
14
  };
@@ -1,9 +1,9 @@
1
1
  import * as d3 from 'd3';
2
- import { BarChartProps, BarChartLinetData } from '../types';
2
+ import { BarChartProps, BarChartLineData } from '../types';
3
3
  export declare type DrawLinesProps = {
4
4
  min: number;
5
5
  svg: d3.Selection<SVGSVGElement, unknown, null, undefined>;
6
6
  yScale: d3.ScaleLinear<number, number>;
7
7
  xScale: d3.ScaleBand<string>;
8
- lineData: BarChartLinetData[];
8
+ lineData: BarChartLineData[];
9
9
  } & Pick<BarChartProps, 'stackedLine' | 'curve'>;
@@ -1,3 +1,3 @@
1
- import React from 'react';
1
+ import { FC } from 'react';
2
2
  import { BarChartProps } from './types';
3
- export declare const BarChart: React.FC<BarChartProps>;
3
+ export declare const BarChart: FC<BarChartProps>;
@@ -20,11 +20,18 @@ export declare type BarChartLabelSetTooltipPosition = (position: {
20
20
  top: number;
21
21
  svgWidth: number;
22
22
  }) => void;
23
+ export interface BarChartMarker {
24
+ label: string;
25
+ value: number;
26
+ color?: string;
27
+ className?: string;
28
+ }
23
29
  export declare type BarChartProps = {
24
30
  className?: string;
25
31
  style?: CSSProperties;
26
32
  data: BarChartData[];
27
- lineData?: BarChartLinetData[];
33
+ markers?: BarChartMarker[];
34
+ lineData?: BarChartLineData[];
28
35
  colors: BarChartColors;
29
36
  margin?: Margin;
30
37
  barWidth?: number;
@@ -50,11 +57,11 @@ export declare type BarChartProps = {
50
57
  bars: d3.Selection<Element | d3.EnterElement | Document | Window | SVGRectElement | null, BarChartMarshalledGroup, SVGGElement, BarChartMarshalledGroup[]> | d3.Transition<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartMarshalledGroup, SVGGElement, BarChartMarshalledGroup[]>;
51
58
  yScale: (value: number) => number;
52
59
  lines: null | {
53
- linesSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLinetData, SVGGElement, unknown> | null;
54
- areasSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLinetData, SVGGElement, unknown> | null;
60
+ linesSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLineData, SVGGElement, unknown> | null;
61
+ areasSelection: d3.Selection<Element | d3.EnterElement | Document | Window | SVGPathElement | null, BarChartLineData, SVGGElement, unknown> | null;
55
62
  area: d3.Area<[number, number]> | null;
56
63
  };
57
- lineData?: BarChartLinetData[];
64
+ lineData?: BarChartLineData[];
58
65
  marshalledData: BarChartMarshalledGroup[][];
59
66
  }) => void;
60
67
  minValue?: number;
@@ -81,7 +88,7 @@ export declare type BarChartProps = {
81
88
  formatTooltipValue?: (value: number) => number | string | ReactNode;
82
89
  tooltipYDomain?: ((data: {
83
90
  data: BarChartMarshalledGroup[][];
84
- lineData?: BarChartLinetData[];
91
+ lineData?: BarChartLineData[];
85
92
  yScale: (value: number) => number;
86
93
  }) => number[]) | null;
87
94
  marshalledMap?: (data: BarChartMarshalledGroup[][]) => BarChartMarshalledGroup[][];
@@ -96,7 +103,7 @@ export declare type BarChartProps = {
96
103
  marshalledData: BarChartMarshalledGroup[][];
97
104
  yScale: (value: number) => number;
98
105
  xScale: d3.ScaleBand<string>;
99
- lineData?: BarChartLinetData[];
106
+ lineData?: BarChartLineData[];
100
107
  }) => void;
101
108
  onLabelItem?: (data: BarChartMarshalledGroup[]) => BarChartMarshalledGroup[];
102
109
  isBarTooltip?: boolean;
@@ -104,7 +111,7 @@ export declare type BarChartProps = {
104
111
  tooltipRoot?: Element;
105
112
  tooltipClassName?: string;
106
113
  };
107
- export declare type BarChartMergedData = (BarChartMarshalledGroup & BarChartLinetData & {
114
+ export declare type BarChartMergedData = (BarChartMarshalledGroup & BarChartLineData & {
108
115
  groupName: string;
109
116
  })[];
110
117
  export declare type BarChartMarshaling = {
@@ -123,7 +130,7 @@ export declare type BarChartMarshalledGroup = {
123
130
  stackIndex: number;
124
131
  groupIndex: number;
125
132
  };
126
- export declare type BarChartLinetData = {
133
+ export declare type BarChartLineData = {
127
134
  lineType: 'line' | 'area';
128
135
  name: string;
129
136
  values: (number | null)[];
@@ -2473,6 +2473,7 @@ const draw$4 = (node, props) => {
2473
2473
  const {
2474
2474
  data,
2475
2475
  lineData = [],
2476
+ markers = [],
2476
2477
  barWidth: barWidthProp,
2477
2478
  barPadding,
2478
2479
  colors,
@@ -2622,6 +2623,14 @@ const draw$4 = (node, props) => {
2622
2623
  groups,
2623
2624
  barWidth
2624
2625
  });
2626
+ markers.forEach(marker => {
2627
+ if (!marker) {
2628
+ return;
2629
+ }
2630
+
2631
+ svg.append('line').style("stroke", marker.color || "inherit").style("stroke-width", 1).style("stroke-dasharray", "5, 3").attr("x1", width / data.length * marker.value + 1).attr("y1", 0).attr("x2", width / data.length * marker.value + 1).attr("y2", height - marginTop - marginBottom + marginBottom / 2);
2632
+ svg.append("text").attr("y", height).attr("x", width / data.length * marker.value + 1).attr('text-anchor', 'middle').attr("class", ["marker", marker.className].filter(Boolean).join(" ")).style("fill", (marker == null ? void 0 : marker.color) || "inherit").text(marker.label);
2633
+ });
2625
2634
  let lines = null;
2626
2635
 
2627
2636
  if (Array.isArray(lineData) && lineData.length > 0) {