@evergis/charts 3.0.20 → 3.0.22

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.
@@ -2052,6 +2052,13 @@ const useSelection = (node, props) => {
2052
2052
  const drawing = useRef(false);
2053
2053
  const startX = useRef(0);
2054
2054
  const selection = useRef();
2055
+ const clearSelection = useCallback(() => {
2056
+ if (node && selection.current) {
2057
+ drawing.current = false;
2058
+ node.removeChild(selection.current);
2059
+ selection.current = undefined;
2060
+ }
2061
+ }, [node]);
2055
2062
  const onStartDrawing = useCallback(e => {
2056
2063
  const isTouch = Boolean(e.touches);
2057
2064
  e.stopPropagation();
@@ -2059,6 +2066,7 @@ const useSelection = (node, props) => {
2059
2066
  if (node && e.which !== 3) {
2060
2067
  var _props$margin$bottom, _props$margin, _e$touches$;
2061
2068
 
2069
+ clearSelection();
2062
2070
  selection.current = document.createElement("div");
2063
2071
  selection.current.setAttribute("class", barChartClassNames.barChartSelection);
2064
2072
  selection.current.setAttribute("style", "height: calc(100% - " + ((_props$margin$bottom = (_props$margin = props.margin) == null ? void 0 : _props$margin.bottom) != null ? _props$margin$bottom : 0) + "px)");
@@ -2130,12 +2138,10 @@ const useSelection = (node, props) => {
2130
2138
  if (max - min > 0 && props.onSelect) {
2131
2139
  props.onSelect([min, max]);
2132
2140
  }
2133
-
2134
- drawing.current = false;
2135
- node.removeChild(selection.current);
2136
- selection.current = undefined;
2137
2141
  }
2138
- }, [node]);
2142
+
2143
+ clearSelection();
2144
+ }, [node, clearSelection]);
2139
2145
  useEffect(() => {
2140
2146
  if (node) {
2141
2147
  node.childNodes.forEach(child => {
@@ -2662,6 +2668,7 @@ const getBars = _ref => {
2662
2668
  return groups.selectAll('rect').data(item => item).join('rect').attr('x', item => item.x).attr('y', item => item.y).attr('width', barWidth).attr('height', item => item.height).style('fill', item => item.color);
2663
2669
  };
2664
2670
 
2671
+ const MIN_BAR_HEIGHT = 2;
2665
2672
  const draw$4 = (node, props) => {
2666
2673
  const {
2667
2674
  data,
@@ -2808,7 +2815,8 @@ const draw$4 = (node, props) => {
2808
2815
  drawGridX
2809
2816
  });
2810
2817
  xAxis.attr('transform', "translate(0, " + (yScale(yTicks[0]) + (xAxisPadding || 0)) + ")");
2811
- const gSvg = svg.append('g').attr('class', barChartClassNames.barChartBarGlobal);
2818
+ svg.append('defs').append('mask').attr('id', 'height-limit-mask').append('rect').attr('width', '100%').attr('height', height - marginBottom + MIN_BAR_HEIGHT).attr('fill', 'white');
2819
+ const gSvg = svg.append('g').attr('class', barChartClassNames.barChartBarGlobal).attr('mask', 'url(#height-limit-mask)');
2812
2820
  const groups = gSvg.selectAll('g').data(marshalledData).enter().append('g').attr('transform', (_, i) => "translate(" + Math.round(xScale(i)) + "," + -(marginTop || 0) + ")");
2813
2821
  const bars = drawBars ? drawBars({
2814
2822
  groups,
@@ -2825,13 +2833,19 @@ const draw$4 = (node, props) => {
2825
2833
  }
2826
2834
 
2827
2835
  if (marker.horizontal) {
2828
- svg.append('line').style("stroke", marker.color || "inherit").style("stroke-width", 1).style("stroke-dasharray", "5, 3").attr("x1", marginLeft + yAxisWidth).attr("y1", yScale(marker.value) + 1).attr("x2", width).attr("y2", yScale(marker.value) + 1);
2836
+ if (marker.line) {
2837
+ svg.append('line').style("stroke", marker.lineColor || marker.color || "inherit").style("stroke-width", 1).style("stroke-dasharray", "5, 3").attr("x1", marginLeft + yAxisWidth).attr("y1", yScale(marker.value) + 1).attr("x2", width).attr("y2", yScale(marker.value) + 1);
2838
+ }
2839
+
2829
2840
  svg.append("text").attr("y", yScale(marker.value) + 1).attr("x", marginLeft + yAxisWidth).attr('text-anchor', 'middle').attr("class", ["marker", marker.className].filter(Boolean).join(" ")).style("fill", (marker == null ? void 0 : marker.color) || "inherit").text(marker.label);
2830
2841
  return;
2831
2842
  }
2832
2843
 
2833
- 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);
2834
- 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);
2844
+ if (marker.line) {
2845
+ svg.append('line').style("stroke", marker.lineColor || 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);
2846
+ }
2847
+
2848
+ svg.append("text").attr("y", height - 3).attr("x", width / data.length * marker.value + 1).attr('text-anchor', marker.align === 'right' ? 'end' : marker.align === 'left' ? 'start' : 'middle').attr("class", ["marker", marker.className].filter(Boolean).join(" ")).style("fill", (marker == null ? void 0 : marker.color) || "inherit").text(marker.label);
2835
2849
  });
2836
2850
  let lines = null;
2837
2851