Skip to content

Commit

Permalink
Maintain assignment order from Canvas in all visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
joelostblom committed Sep 29, 2022
1 parent 775dc14 commit 2ab4899
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Note that major version zero (0.y.z) is for initial development and anything may
- Make hover highlighting more intuitive and better explained.
- Filter out unpublished assignment and those missing a max score.
- Put assignment titles on top of plots instead of to the left.
- Maintain assignment order from Canvas in all visualizations.

### Fixed
- Make rounding work with dfs containing None instead of NaN
Expand Down
9 changes: 6 additions & 3 deletions canvascli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ def plot_assignment_scores(self):
grader_order = assignment_score_df.groupby(
'Grader'
)['Score'].mean().sort_values().index.tolist()
# assignment_order is only needed because VL does not support maintaining
# the orignal order for facets https://github.com/vega/vega-lite/issues/6221
assignment_order = assignment_score_df['Assignment'].unique().tolist()
height = max(80, len(grader_order) * 20)

assignment_central_tendencies = alt.Chart(
Expand Down Expand Up @@ -630,7 +633,7 @@ def plot_assignment_scores(self):
anchor='middle',
dx=25
),
facet=alt.Facet('Assignment', title=''),
facet=alt.Facet('Assignment', title='', sort=assignment_order),
columns=1
), alt.Chart(
assignment_score_df.reset_index(),
Expand All @@ -646,7 +649,7 @@ def plot_assignment_scores(self):
anchor='middle',
dx=-40
),
facet=alt.Facet('Assignment', title=''),
facet=alt.Facet('Assignment', title='', sort=assignment_order),
columns=1
).resolve_scale(
y='independent', # Don't use the same y-axis ticks for each faceted boxplot
Expand Down Expand Up @@ -678,7 +681,7 @@ def plot_assignment_scores(self):
).mark_point(opacity=0).encode(
y=alt.Y('Score', scale=alt.Scale(zero=False), title='Assignment Score (%)'),
detail='User ID',
x=alt.X('Assignment', title=''),
x=alt.X('Assignment', title='', sort=assignment_order),
# Having the tooltip here instead of in the transformed chart
# makes it work with nearest,
# but significantly slows down the higlighting of the line
Expand Down

0 comments on commit 2ab4899

Please sign in to comment.