Hexastack / eazychart

EazyChart is a reactive chart library 📈, it allows you to easily add SVG charts in your React and Vue web applications.
https://eazychart.com
MIT License
23 stars 14 forks source link

🐛 [BUG] eazychart-[react & vue]- Warning about negative values #31

Closed marrouchi closed 2 years ago

marrouchi commented 2 years ago

Description

At the first render, I think the dimensions (width + height) are initial zerors, with padding, we would have negative values. We need to clamp the dimensions on calc.

Reproduction steps

const chartDimensions: Dimensions = useMemo(() => {
    const { top, right, bottom, left } = chartPadding;
    const legendHeight = legendRef.current
      ? Math.floor(legendRef.current.clientHeight)
      : 0;
    // It take the container dimensions and subsctract padding and legend height
    // @todo : clamp to min = zero to avoid negative values
    return {
      width: containerDimensions.width - left - right,
      height: containerDimensions.height - top - bottom - legendHeight,
    };
  }, [containerDimensions, chartPadding]);
AlanLes commented 2 years ago

Hello, can I take this one? ;) Can you please assign me to this?

marrouchi commented 2 years ago

Done ! note that the warnning are showing the browser debug console it's when you run yarn storybook.