Skip to content

Uncaught runtime errors; it happened sometimes (when I click for loading data quickly) #145

@yuniwahuni

Description

@yuniwahuni

Hi,

I made timeline chart for inpatient medicine.
chart data is loaded by sql server (node js)

sometimes rendering is well, but sometimes cause error when render chart.
how could I fix this problem?

when it caused error
timelines_error

when it worked well
timelines_medicine

this is my source

import { useState, useLayoutEffect } from 'react';
import fromKapsule from 'react-kapsule';
import moment from 'moment';
import TimelinesChart from 'timelines-chart';

const TimelinesChartComp = fromKapsule(TimelinesChart);

const useWindowSize = () => {
	const [size, setSize] = useState([0, 0]);
	useLayoutEffect(() => {
		function updateSize() {
			setSize([window.innerWidth, window.innerHeight]);
		}
		window.addEventListener('resize', updateSize);
		updateSize();
		return () => window.removeEventListener('resize', updateSize);
	}, []);
	return size;
};

export default function Timelines({ data }) {
	const [width, height] = useWindowSize();

	function xTickFnc(val) {
		return moment(val).format('YY.MM.DD A');
	}
	return (
		<>
			<div id='chart'>
				<div className='App'>
					<TimelinesChartComp
						zQualitative={true}
						width={width - 100}
						leftMargin={300}
						maxHeight={1000}
						maxLineHeight={40}
						xTickFormat={xTickFnc}
						data={data}
					/>
				</div>
			</div>
		</>
	);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions