Giter Club home page Giter Club logo

Comments (3)

vasturiano avatar vasturiano commented on May 27, 2024

@yuniwahuni in order to better help you with debugging, could you make a simple repro example on https://codepen.io/ ?

from timelines-chart.

yuniwahuni avatar yuniwahuni commented on May 27, 2024

@yuniwahuni in order to better help you with debugging, could you make a simple repro example on https://codepen.io/ ?

@vasturiano
Sure, thanks for your reply on my question,
I will make source for codepen. please wait a moment.

Up to now, the cause that i think is Asynchronous responce of backend.
I used Apollo graphql bewteen backend and frontend for API.

If I don't use backend, the error is not happen. but when I use backend and get data asynchronous, it happen somtimes.


import { useEffect, useState } from 'react';
import { GET_TIME_LINE_LIST } from './api/gql/devConf';
import { useQuery } from '@apollo/client';
import Timelines from './Timelines';
import moment from 'moment';
import Tabs from './component/Tab';

function makePeriodFromDaylist(group, dates) {
	//... make date period from data
}

function configRangeData(group, orderRecord) {
       //.. make data for timelinechart
	return [
		{
			label: '',
			data: makePeriodFromDaylist(group, orderDayList),
		},
	];
}

function makeGroupData(data) {
	const uniqueOrderName = [...new Set(data.map((item) => item.orderName))];
	const resultData = uniqueOrderName.map((orderName) => ({
		group: orderName,
		data: configRangeData(
			orderName,
			data.filter((v) => v.orderName === orderName)
		),
	}));
	return resultData;
}

export default function App() {
	const [category, setCategory] = useState({ categoryKey: 3, categoryName: 'medicine' });
	const { loading, error, data } = useQuery(GET_TIME_LINE_LIST, {
		fetchPolicy: 'network-only',
		variables: {
			chartNo: '00-0000001',
			category: category.categoryKey,
			inDate: '',
		},
	});

	function makeCategoryTab(categoryList) {
		function onSetCategory(cat) {
			setCategory(cat);
		}
		return <Tabs data={categoryList} category={category} onSetCategory={onSetCategory} />;
	}

	if (loading) return <>{'Loading...'}</>;
	if (error) return <>{'Error ${error.message'}}</>;
	if (data) {
		const timelineList = data?.getTimelineList?.timelineList;
		if (timelineList.length > 0) {
			return (
				<>
					<div className='Tabs'>
						<span className='TitleCaption'>{'Medicine TimeLine'}</span>
						<ul className='nav'>{makeCategoryTab()}</ul>
					</div>
					<Timelines data={makeGroupData(timelineList)} />
				</>
			);
		} else {
			return <></>;
		}
	}

	return <></>;
}

from timelines-chart.

Maarc avatar Maarc commented on May 27, 2024

Hi! Thank you for opening this issue. I have the same error using timelines-chart with vue.js, while refreshing too quickly.

from timelines-chart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.