Skip to content

Scale scatter chart into quadrants#14

Merged
ddbrendan merged 6 commits into
mainfrom
chart-quadrant-scaling
Jun 26, 2026
Merged

Scale scatter chart into quadrants#14
ddbrendan merged 6 commits into
mainfrom
chart-quadrant-scaling

Conversation

@ddbrendan

@ddbrendan ddbrendan commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Before:
image

After:
image

@ddbrendan ddbrendan self-assigned this Jun 17, 2026
@ddbrendan ddbrendan requested a review from rnestler June 17, 2026 13:46
@ddbrendan ddbrendan marked this pull request as draft June 18, 2026 08:26
@ddbrendan ddbrendan marked this pull request as ready for review June 18, 2026 11:49
@ddbrendan ddbrendan force-pushed the chart-quadrant-scaling branch from aacfa11 to 08437f2 Compare June 23, 2026 13:15
const data = {
datasets: [{
data: this.pointsValue.map((p) => ({ x: p.want, y: p.can, label: p.name })),
data: this.pointsValue.map((p) => ({ x: p.want - 3, y: p.can - 2.5, label: p.name })),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this in JS splits knowledge about how this values are scaled between the backend and the frontend. This is bad for maintenance. Can you do the conversion in the rails backend?

Comment on lines +23 to +25
// The four can levels; 0 carries no label — it only draws the centre line between them.
const canTickValues = [-1.5, -0.5, 0.5, 1.5]
const zeroLine = (ctx) => (ctx.tick?.value === 0 ? '#999999' : 'rgba(0, 0, 0, 0.1)')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusing naming: This calculates the gridColor, choosing a different color for the zero line. It sounds like it draws the zero line.

grid: { color: zeroLine },
afterBuildTicks: (axis) => {
// Add 0 so the centre line is drawn
axis.ticks = [...canTickValues, 0].sort((a, b) => a - b).map((value) => ({ value }))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add it to the canTickValues above?

@ddbrendan ddbrendan Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 isn't a level, it has no label and only draws the centre line. canTickValues is the index map for the labels, so adding 0 there would shift the lookup and mislabel the levels. That's why it's separated

@ddbrendan ddbrendan force-pushed the chart-quadrant-scaling branch from 08437f2 to 994d14f Compare June 25, 2026 15:01
@ddbrendan ddbrendan requested review from firemind and rnestler June 26, 2026 09:02
Comment thread app/views/tech_radar/index.html.erb Outdated
<% end %>

<% can_ticks = TechRadar::Rating.can_levels.keys.map { |key| t("tech_radar.rate.can.#{key}") } %>
<% want_ticks = TechRadar::Rating.want_levels.keys.map { |key| t("tech_radar.rate.want.#{key}") } %>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like the same thing you extracted to a helper here: https://github.com/renuo/redmine_techradar/pull/16/changes#diff-6e8ce091a1c35c5276d211ac6886d64aca48c3915694d246cf0e80e44f983d95R3-R13

use those helpers after rebasing

@ddbrendan ddbrendan force-pushed the chart-quadrant-scaling branch from 2206558 to bc11944 Compare June 26, 2026 12:18
@ddbrendan ddbrendan force-pushed the chart-quadrant-scaling branch from bc11944 to d7ae383 Compare June 26, 2026 12:22
@ddbrendan ddbrendan merged commit 3262357 into main Jun 26, 2026
1 check passed
@ddbrendan ddbrendan deleted the chart-quadrant-scaling branch June 26, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants