-
Notifications
You must be signed in to change notification settings - Fork 14
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
Tooltip and chart styling fixes #535
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, files without components should start with lowercase and would end in Since |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const Colors = ['#60A3D1', '#81C284', '#F5D77F', '#ECAD6D', '#E8966D', '#EBEBEB', '#EBEBEB']; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ import React from 'react'; | |
import { ResponsivePie, PieTooltipProps } from '@nivo/pie'; | ||
|
||
import { GradesRaw } from '@peterportal/types'; | ||
import { Colors } from './Colors.tsx'; | ||
import { TooltipStyle } from './TooltipStyle.tsx'; | ||
|
||
const gradeScale = ['A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'D-']; | ||
const gpaScale = [4.0, 3.7, 3.3, 3.0, 2.7, 2.3, 2.0, 1.7, 1.3, 1.0, 0, 7]; | ||
|
@@ -27,7 +29,7 @@ export default class Pie extends React.Component<PieProps> { | |
averageGrade = ''; | ||
averagePNP = ''; | ||
|
||
getClassData = () => { | ||
getClassData = (): Slice[] => { | ||
let gradeACount = 0, | ||
gradeBCount = 0, | ||
gradeCCount = 0, | ||
|
@@ -102,7 +104,7 @@ export default class Pie extends React.Component<PieProps> { | |
id: 'A', | ||
label: 'A', | ||
value: gradeACount, | ||
color: '#60A3D1', | ||
color: '#54B058', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider using something like |
||
}, | ||
{ | ||
id: 'B', | ||
|
@@ -150,6 +152,16 @@ export default class Pie extends React.Component<PieProps> { | |
this.averageGrade = gradeScale[i]; | ||
} | ||
|
||
styleTooltip = (props: PieTooltipProps<Slice>) => { | ||
return ( | ||
<div style={TooltipStyle.tooltip?.container}> | ||
<strong> | ||
{props.datum.id}: {((props.datum.value / this.total) * 100).toFixed(2)}% | ||
</strong> | ||
</div> | ||
); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div style={{ width: '100%', position: 'relative' }}> | ||
|
@@ -165,24 +177,11 @@ export default class Pie extends React.Component<PieProps> { | |
enableArcLinkLabels={false} | ||
innerRadius={0.8} | ||
padAngle={2} | ||
colors={['#60A3D1', '#81C284', '#F5D77F', '#ECAD6D', '#E8966D', '#4AB486', '#E36436']} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the last two removed colors here are actually different from the other list. I think we should use the green and red for pass + no pass instead of making them gray |
||
colors={Colors} | ||
cornerRadius={3} | ||
borderWidth={1} | ||
borderColor={{ from: 'color', modifiers: [['darker', 0.2]] }} | ||
tooltip={(props: PieTooltipProps<Slice>) => ( | ||
<div | ||
style={{ | ||
color: '#FFFFFF', | ||
background: 'rgba(0,0,0,.87)', | ||
paddingLeft: '0.5em', | ||
paddingRight: '0.5em', | ||
}} | ||
> | ||
<strong> | ||
{props.datum.id}: {((props.datum.value / this.total) * 100).toFixed(2)}% | ||
</strong> | ||
</div> | ||
)} | ||
tooltip={this.styleTooltip} | ||
/> | ||
<div | ||
style={{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { type Theme } from '@nivo/core'; | ||
|
||
export const TooltipStyle: Theme = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as |
||
tooltip: { | ||
container: { | ||
background: 'rgba(0,0,0,.87)', | ||
color: '#ffffff', | ||
fontSize: '1.2rem', | ||
outline: 'none', | ||
margin: 0, | ||
padding: '0.25em 0.5em', | ||
borderRadius: '2px', | ||
paddingLeft: '0.5em', | ||
paddingRight: '0.5em', | ||
}, | ||
}, | ||
}; |
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 is an example file for the format of environment variables, not env variables themselves. It should not be deleted