Skip to content
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

🎉 (slope) feature parity with line charts / TAS-708 #4192

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c4f2545
✨ (slope) show selected entities only
sophiamersmann Nov 20, 2024
a681846
✨ (slope) support relative mode
sophiamersmann Nov 20, 2024
018e132
✨ (slope) only allow selection using the entity selector
sophiamersmann Nov 20, 2024
33c00cc
✨ (slope) drop support for color dim and focus state
sophiamersmann Nov 20, 2024
a9d26c8
✨ (slope) support multiple y-dimensions
sophiamersmann Nov 20, 2024
9e61bc3
✨ (slope) drop non-positive values in log mode
sophiamersmann Nov 20, 2024
7d228b9
✨ (slope) use line legend instead of custom labels
sophiamersmann Nov 20, 2024
198a26f
✨ (slope) add support for entity name annotations
sophiamersmann Nov 20, 2024
d33eebd
✨ (grapher) disallow switching to a slope chart for projections
sophiamersmann Nov 20, 2024
5c9727e
✨ (slope) add tooltips
sophiamersmann Nov 20, 2024
f82ca07
✨ (slope) refactor
sophiamersmann Nov 21, 2024
f808447
🔨 (slope) remove color dimension
sophiamersmann Nov 21, 2024
e1491a3
✨ (slope) allow to hide legend
sophiamersmann Nov 21, 2024
6774410
🐛 (slope) fix start/end time selection
sophiamersmann Nov 21, 2024
3fc555a
🐛 (slope) error out when start and end time are the same
sophiamersmann Nov 21, 2024
9714ebe
🐛 (slope) fix No Data section when missing data strategy is hide
sophiamersmann Nov 22, 2024
932cc9d
🐛 (slope) fix tabs for line chart that turned into discrete bar
sophiamersmann Nov 22, 2024
940355b
🐛 (slope) fix entity selector title
sophiamersmann Nov 22, 2024
5193feb
🔨 (slope) cleanup
sophiamersmann Nov 22, 2024
d909066
🧪 (slope) fix tests
sophiamersmann Nov 22, 2024
02b2b60
✨ (slope) visual changes
sophiamersmann Nov 22, 2024
c489683
🔨 always apply transforms of the main chart type for the entity selec…
sophiamersmann Nov 27, 2024
187203d
✨ (slope) add Change in to title in relative mode
sophiamersmann Nov 27, 2024
4bdfcc1
✨ (admin) show relative toggle for slope charts
sophiamersmann Nov 27, 2024
864e6f6
🔨 migrate slope charts
sophiamersmann Nov 25, 2024
f201085
✨ (slope) improve tooltip in relative mode
sophiamersmann Nov 27, 2024
3167772
✨ (slope) improve No Data section
sophiamersmann Nov 27, 2024
b5f5b08
✨ nicer entity/column labels
sophiamersmann Nov 27, 2024
2414e5b
🔨 (slope) clean up code
sophiamersmann Nov 27, 2024
b71988d
🔨 update slope migration
sophiamersmann Nov 28, 2024
9cd9f30
🧪 (slope) add tests
sophiamersmann Nov 28, 2024
26bfa86
✨ (slope) drop entities from selector if time selection disabled
sophiamersmann Nov 28, 2024
322f4ee
🐛 (slope) fix relative value calculation
sophiamersmann Nov 28, 2024
cf81efe
🐛 (slope) hide relative toggle for log scale
sophiamersmann Nov 28, 2024
f322692
🐛 (line) use startTime for relative mode calculation
sophiamersmann Nov 28, 2024
a2a6a89
🔨 update slope migration after feedback
sophiamersmann Nov 28, 2024
06ddf6c
🔨 (slope) drop non-numeric data in any case
sophiamersmann Nov 28, 2024
1ed2a96
🐛 (slope) show correct label for relative toggle
sophiamersmann Nov 28, 2024
8f13554
🔨 use current chart instance for table for selection
sophiamersmann Nov 29, 2024
f52dac5
🐛 (slope) only drop entities if start and end time are different
sophiamersmann Nov 29, 2024
d9cdcb4
🐛 hide slope chart tab if line chart really is a bar chart
sophiamersmann Nov 29, 2024
f3b4993
✨ automatically adjust handles when switching from line to slope
sophiamersmann Nov 29, 2024
a617f44
🐛 (slope) only add entity name if necessary
sophiamersmann Nov 29, 2024
687c486
🎉 enable timeline animation for slope charts
sophiamersmann Nov 29, 2024
17e4cf9
🔨 (slope) update comments
sophiamersmann Nov 29, 2024
7e583e0
🔨 remove accidental commits
sophiamersmann Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions adminSiteClient/EditorBasicTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DimensionSlotView<
const { selection } = grapher
const { availableEntityNames, availableEntityNameSet } = selection

if (grapher.isScatter || grapher.isSlopeChart || grapher.isMarimekko) {
if (grapher.isScatter || grapher.isMarimekko) {
// chart types that display all entities by default shouldn't select any by default
selection.clearSelection()
} else if (
Expand Down Expand Up @@ -372,8 +372,8 @@ export class EditorBasicTab<
grapher.stackMode = StackMode.relative
}

// Give scatterplots and slope charts a default color dimension if they don't have one
if (grapher.isScatter || grapher.isSlopeChart) {
// Give scatterplots a default color and size dimensions
if (grapher.isScatter) {
const hasColor = grapher.dimensions.find(
(d) => d.property === DimensionProperty.color
)
Expand All @@ -382,10 +382,7 @@ export class EditorBasicTab<
variableId: CONTINENTS_INDICATOR_ID,
property: DimensionProperty.color,
})
}

// Give scatterplots a default size dimension if they don't have one
if (grapher.isScatter) {
const hasSize = grapher.dimensions.find(
(d) => d.property === DimensionProperty.size
)
Expand Down
8 changes: 5 additions & 3 deletions adminSiteClient/EditorFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class EditorFeatures {
@computed get hideLegend() {
return (
this.grapher.isLineChart ||
this.grapher.isSlopeChart ||
this.grapher.isStackedArea ||
this.grapher.isStackedDiscreteBar
)
Expand All @@ -77,6 +78,7 @@ export class EditorFeatures {
this.grapher.isStackedBar ||
this.grapher.isStackedDiscreteBar ||
this.grapher.isLineChart ||
this.grapher.isSlopeChart ||
this.grapher.isScatter ||
this.grapher.isMarimekko
)
Expand Down Expand Up @@ -118,9 +120,9 @@ export class EditorFeatures {
return true
}

// for line charts, specifying a missing data strategy only makes sense
// for line and slope charts, specifying a missing data strategy only makes sense
// if there are multiple entities
if (this.grapher.isLineChart) {
if (this.grapher.isLineChart || this.grapher.isSlopeChart) {
return (
this.grapher.canChangeEntity ||
this.grapher.canSelectMultipleEntities
Expand All @@ -132,7 +134,7 @@ export class EditorFeatures {

@computed get showChangeInPrefixToggle() {
return (
this.grapher.isLineChart &&
(this.grapher.isLineChart || this.grapher.isSlopeChart) &&
(this.grapher.isRelativeMode || this.grapher.canToggleRelativeMode)
)
}
Expand Down
2 changes: 1 addition & 1 deletion baker/updateChartEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const obtainAvailableEntitiesForGrapherConfig = async (

// In these chart types, an unselected entity is still shown
const chartTypeShowsUnselectedEntities =
grapher.isScatter || grapher.isSlopeChart || grapher.isMarimekko
grapher.isScatter || grapher.isMarimekko

if (canChangeEntities || chartTypeShowsUnselectedEntities)
return grapher.tableForSelection.availableEntityNames as string[]
Expand Down
32 changes: 32 additions & 0 deletions db/migration/1732195571407-RemoveColorDimensionFromSlopeCharts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class RemoveColorDimensionFromSlopeCharts1732195571407
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// remove color dimension for all slope charts
// the y-dimension always comes first and the color dimension second,
// so it's safe to keep the first dimension only
await queryRunner.query(`
-- sql
UPDATE chart_configs
SET
patch = JSON_REPLACE(patch, '$.dimensions', JSON_ARRAY(patch -> '$.dimensions[0]')),
full = JSON_REPLACE(full, '$.dimensions', JSON_ARRAY(full -> '$.dimensions[0]'))
WHERE
chartType = 'SlopeChart'
`)

// remove the color dimension for slope charts from the chart_dimensions table
await queryRunner.query(`
-- sql
DELETE cd FROM chart_dimensions cd
JOIN charts c ON c.id = cd.chartId
JOIN chart_configs cc ON c.configId = cc.id
WHERE cc.chartType = 'SlopeChart' AND cd.property = 'color'
`)
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public async down(): Promise<void> {}
}
Loading