Skip to content

Commit

Permalink
✨ (discrete bar) hide horizontal axis (#4371)
Browse files Browse the repository at this point in the history
* ✨ (discrete bar) hide horizontal axis

* 🔨 remove relative mode from discrete bar chart configs

* 🤖 style: prettify code
  • Loading branch information
sophiamersmann authored Jan 3, 2025
1 parent 57ea52e commit 0fbc2ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class RemoveRelativeModeFromDiscreteBarCharts1735896576517
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
-- sql
update chart_configs
set
patch = json_remove(patch, '$.stackMode'),
full = json_remove(full, '$.stackMode')
where
chartType = 'DiscreteBar'
and full ->> '$.stackMode' = 'relative';
`)
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public async down(): Promise<void> {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ import {
GRAPHER_AREA_OPACITY_DEFAULT,
GRAPHER_FONT_SCALE_12,
} from "../core/GrapherConstants"
import {
HorizontalAxisComponent,
HorizontalAxisGridLines,
HorizontalAxisZeroLine,
} from "../axis/AxisViews"
import { HorizontalAxisZeroLine } from "../axis/AxisViews"
import { NoDataModal } from "../noDataModal/NoDataModal"
import { AxisConfig, AxisManager } from "../axis/AxisConfig"
import { ColorSchemes } from "../color/ColorSchemes"
Expand Down Expand Up @@ -305,7 +301,6 @@ export class DiscreteBarChart
@computed private get innerBounds(): Bounds {
return this.boundsWithoutColorLegend
.padLeft(Math.max(this.seriesLegendWidth, this.leftValueLabelWidth))
.padBottom(this.showHorizontalAxis ? this.yAxis.height : 0)
.padRight(this.rightValueLabelWidth)
}

Expand Down Expand Up @@ -350,10 +345,6 @@ export class DiscreteBarChart
return this.barPlacements.map((b) => b.width)
}

@computed private get showHorizontalAxis(): boolean | undefined {
return this.manager.isRelativeMode
}

private d3Bars(): Selection<
BaseType,
unknown,
Expand Down Expand Up @@ -504,7 +495,7 @@ export class DiscreteBarChart
}

renderChartArea(): React.ReactElement {
const { manager, boundsWithoutColorLegend, yAxis, innerBounds } = this
const { manager, yAxis, innerBounds } = this

const axisLineWidth = manager.isStaticAndSmall
? GRAPHER_AXIS_LINE_WIDTH_THICK
Expand All @@ -516,22 +507,6 @@ export class DiscreteBarChart
{this.showColorLegend && (
<HorizontalNumericColorLegend manager={this} />
)}
{this.showHorizontalAxis && (
<>
<HorizontalAxisComponent
bounds={boundsWithoutColorLegend}
axis={yAxis}
preferredAxisPosition={innerBounds.bottom}
labelColor={manager.secondaryColorInStaticCharts}
tickMarkWidth={axisLineWidth}
/>
<HorizontalAxisGridLines
horizontalAxis={yAxis}
bounds={innerBounds}
strokeWidth={axisLineWidth}
/>
</>
)}
{!this.isLogScale && (
<HorizontalAxisZeroLine
horizontalAxis={yAxis}
Expand Down

0 comments on commit 0fbc2ea

Please sign in to comment.