-
Notifications
You must be signed in to change notification settings - Fork 49
Add Chart component to GroupTable #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| interface GroupTableChartProps { | ||
| dataSource: RepeatableGroupTableRow[]; | ||
| linkIdX: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no sense to pass empty linkIdX and linkIdY.
This case should be handles in the parent component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
| return { | ||
| name: item.key, | ||
| x: item[linkIdX]?.formItem?.[0]?.value?.date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be dateTime or even Intger. Please handle this edge cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to abstract value getter
| axisLine={false} | ||
| /> | ||
| <CartesianGrid /> | ||
| {/*<CartesianAxis display={'none'} />*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useless comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
| import { RepeatableGroupTableRow } from './types'; | ||
|
|
||
| const getEnableChartExtension = compileAsFirst<QuestionnaireItem, Extension>( | ||
| `extension.where(url='https://emr-core.beda.software/StructureDefinition/enableChart')`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extensions should be defined here https://github.com/beda-software/beda-emr-core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| snapshotDataSource, | ||
| renderAsTable, | ||
| handleRenderTypeToggle, | ||
| enabledChart: !!extensionEnableChart, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag is not needed.
Use handleRenderTypeToggle as a flag if it is not defined it is just a Table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored approach
| import { RepeatableGroupTableRow } from './types'; | ||
|
|
||
| const getEnableChartExtension = compileAsFirst<QuestionnaireItem, Extension>( | ||
| `extension.where(url='https://emr-core.beda.software/StructureDefinition/enable-chart')`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexlipovka use extension function instead of where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not relevant, now data comes from first class extension fields
| }); | ||
|
|
||
| return ( | ||
| <ResponsiveContainer width="100%" height={'100%'}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ResponsiveContainer width="100%" height="100%">
| /> | ||
| </S.Item> | ||
| )} | ||
| {repeats && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show error if props are incorrect.
repeats is false or one of (both) chartLinkIdX,chartLinkIdY is not defined.
Provide user friendly error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| return Array.isArray(item) && item.every((item) => item !== undefined && item !== null && 'value' in item); | ||
| }; | ||
|
|
||
| const getValueFromAnswerValue = (answerValue: AnswerValue, questionnaireItemType: QuestionnaireItem['type']) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't it define under GroupTable pull request?
If it is a refactoring I don't see getValueFromAnswerValue removed from another file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, there we defined readonly rendering, but here we only need raw values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to use common functions
Ref: