Skip to content

Commit

Permalink
✨ (discrete bar) hide horizontal axis
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 2, 2025
1 parent 9319dae commit 8e382fc
Showing 1 changed file with 3 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ import {
GRAPHER_AREA_OPACITY_DEFAULT,

Check warning on line 37 in packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx

View workflow job for this annotation

GitHub Actions / eslint

'GRAPHER_AREA_OPACITY_DEFAULT' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 37 in packages/@ourworldindata/grapher/src/barCharts/DiscreteBarChart.tsx

View workflow job for this annotation

GitHub Actions / eslint

'GRAPHER_AREA_OPACITY_DEFAULT' is defined but never used. Allowed unused vars must match /^_/u
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 @@ -475,7 +466,6 @@ export class DiscreteBarChart
width={series.barWidth}
height={this.barHeight}
fill={barColor}
opacity={GRAPHER_AREA_OPACITY_DEFAULT}
style={{ transition: "height 200ms ease" }}
/>
)
Expand Down Expand Up @@ -504,7 +494,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,27 +506,12 @@ 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}
bounds={innerBounds}
strokeWidth={axisLineWidth}
align={HorizontalAlign.right}
/>
)}
{this.renderBars()}
Expand Down

0 comments on commit 8e382fc

Please sign in to comment.