Commit 67ff694a by AlasdairSwan

Chart and legend data ordered

parent 021bf1e6
...@@ -34,7 +34,7 @@ class CircleChart extends React.Component { ...@@ -34,7 +34,7 @@ class CircleChart extends React.Component {
let lastY = 0; let lastY = 0;
// Reverse a copy of the array so order start at 12 o'clock // Reverse a copy of the array so order start at 12 o'clock
return slices.map(({ value }, index) => { return slices.slice(0).reverse().map(({ value, sliceIndex }, index) => {
// Should we just draw a circle? // Should we just draw a circle?
if (value === total) { if (value === total) {
return ( return (
...@@ -77,10 +77,9 @@ class CircleChart extends React.Component { ...@@ -77,10 +77,9 @@ class CircleChart extends React.Component {
lastX = nextX; lastX = nextX;
lastY = nextY; lastY = nextY;
const sliceNumber = index + 1;
return <path d={d} return <path d={d}
className={`slice-${sliceNumber}`} className={`slice-${sliceIndex}`}
key={index} key={index}
stroke={strokeColor} stroke={strokeColor}
strokeWidth={strokeWidth} />; strokeWidth={strokeWidth} />;
...@@ -110,7 +109,7 @@ CircleChart.defaultProps = { ...@@ -110,7 +109,7 @@ CircleChart.defaultProps = {
CircleChart.propTypes = { CircleChart.propTypes = {
slices: PropTypes.array.isRequired, slices: PropTypes.array.isRequired,
centerHole: PropTypes.boolean, centerHole: PropTypes.bool,
sliceBorder: PropTypes.object sliceBorder: PropTypes.object
}; };
......
...@@ -10,14 +10,11 @@ class CircleChartLegend extends React.Component { ...@@ -10,14 +10,11 @@ class CircleChartLegend extends React.Component {
getList() { getList() {
const {data} = this.props; const {data} = this.props;
return data.map(({ value, label }) => { return data.map(({ value, label, sliceIndex }, index) => {
// const style = { const swatchClass = `swatch-${sliceIndex}`;
// backgroundColor: color
// }
return ( return (
<li className="legend-item"> <li className="legend-item" key={index}>
<div className="color-swatch" <div className={classNames('color-swatch', swatchClass)}
aria-hidden="true"></div> aria-hidden="true"></div>
<span className="label">{label}</span> <span className="label">{label}</span>
<span className="percentage">{this.getPercentage(value)}</span> <span className="percentage">{this.getPercentage(value)}</span>
......
...@@ -10,16 +10,17 @@ import Table from './Table'; ...@@ -10,16 +10,17 @@ import Table from './Table';
export function LearnerAnalyticsDashboard(props) { export function LearnerAnalyticsDashboard(props) {
console.log('props: ', props); console.log('props: ', props);
const {grading_policy} = props; const {grading_policy} = props;
const gradeBreakdown = grading_policy.GRADER.map(({type, weight}) => { const gradeBreakdown = grading_policy.GRADER.map(({type, weight}, index) => {
return { return {
value: weight, value: weight,
label: type label: type,
sliceIndex: index + 1
} }
}); }).sort((a, b) => a.value > b.value);
// const data = [ // const data = [
// { // {
// color: '#386F77', // color: '#386F77',
// value: 0.15, // value: 0.50,
// label: 'Chucky' // label: 'Chucky'
// }, // },
// { // {
...@@ -34,7 +35,7 @@ console.log('props: ', props); ...@@ -34,7 +35,7 @@ console.log('props: ', props);
// }, // },
// { // {
// color: '#73bde7', // color: '#73bde7',
// value: 0.3, // value: 0.15,
// label: 'Jason Vorhees' // label: 'Jason Vorhees'
// } // }
// ]; // ];
...@@ -83,7 +84,7 @@ console.log('props: ', props); ...@@ -83,7 +84,7 @@ console.log('props: ', props);
<h3>Graded Assessments</h3> <h3>Graded Assessments</h3>
<div className="graded-assessments-wrapper"> <div className="graded-assessments-wrapper">
<Table headings={tableHeadings} data={tableData} /> <Table headings={tableHeadings} data={tableData} />
<p class="footnote">*Calculated based on current average</p> <p className="footnote">*Calculated based on current average</p>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -10,9 +10,9 @@ class Table extends React.Component { ...@@ -10,9 +10,9 @@ class Table extends React.Component {
getTableBody() { getTableBody() {
const {data} = this.props; const {data} = this.props;
const rows = data.map(({label, user, passing, total}) => { const rows = data.map(({label, user, passing, total}, index) => {
return ( return (
<tr> <tr key={index}>
<td>{label}</td> <td>{label}</td>
<td>{user}/{total}</td> <td>{user}/{total}</td>
<td>{passing}/{total}</td> <td>{passing}/{total}</td>
...@@ -25,7 +25,7 @@ class Table extends React.Component { ...@@ -25,7 +25,7 @@ class Table extends React.Component {
getTableHead() { getTableHead() {
const {headings} = this.props; const {headings} = this.props;
const html = headings.map((title) => <th>{title}</th>); const html = headings.map((title, index) => <th key={index}>{title}</th>);
return ( return (
<thead className="table-head"> <thead className="table-head">
<tr> <tr>
......
$slices: #386F77, #1ABC9C, #386F77, #1ABC9C, #386F77, #1ABC9C; $slices: #386F77, #1ABC9C, #92C9D3, #397D1C, #A39D3D, #0E5AAA;
.content-wrapper { .content-wrapper {
.page-content.learner-analytics-dashboard-wrapper { .page-content.learner-analytics-dashboard-wrapper {
flex-direction: column; flex-direction: column;
...@@ -54,42 +53,30 @@ $slices: #386F77, #1ABC9C, #386F77, #1ABC9C, #386F77, #1ABC9C; ...@@ -54,42 +53,30 @@ $slices: #386F77, #1ABC9C, #386F77, #1ABC9C, #386F77, #1ABC9C;
height: 45px; height: 45px;
border-radius: 25%; border-radius: 25%;
margin-right: 20px; margin-right: 20px;
}
.percentage {
margin-left: auto;
}
&:nth-of-type(1) { &.swatch-1 {
.color-swatch {
background-color: nth($slices, 1); background-color: nth($slices, 1);
} }
} &.swatch-2 {
&:nth-of-type(2) {
.color-swatch {
background-color: nth($slices, 2); background-color: nth($slices, 2);
} }
} &.swatch-3 {
&:nth-of-type(3) {
.color-swatch {
background-color: nth($slices, 3); background-color: nth($slices, 3);
} }
} &.swatch-4 {
&:nth-of-type(4) {
.color-swatch {
background-color: nth($slices, 4); background-color: nth($slices, 4);
} }
} &.swatch-5 {
&:nth-of-type(5) {
.color-swatch {
background-color: nth($slices, 5); background-color: nth($slices, 5);
} }
} &.swatch-6 {
&:nth-of-type(6) {
.color-swatch {
background-color: nth($slices, 6); background-color: nth($slices, 6);
} }
} }
.percentage {
margin-left: auto;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment