Skip to content

Commit

Permalink
add customizable axis labelt to GroupCurveChart (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
0qy authored Aug 7, 2022
1 parent 0135319 commit 47fd706
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/GroupCurveChart/GroupCurveChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Primary.args = {
scaleType: 'log',
xLimits: [1e-2, 10],
yLimits: [1e-6, 1],
xLabel: 'Acceleration(g)',
yLabel: 'Annual Probability of Exceedance',
gridColor: '#efefef',
backgroundColor: '#f3f6f4',
numTickX: 5,
Expand All @@ -42,6 +44,8 @@ Tooltip.args = {
scaleType: 'log',
xLimits: [1e-2, 10],
yLimits: [1e-6, 1],
xLabel: 'Acceleration(g)',
yLabel: 'Annual Probability of Exceedance',
gridColor: '#efefef',
backgroundColor: '#f3f6f4',
numTickX: 5,
Expand All @@ -60,6 +64,8 @@ Crosshair.args = {
scaleType: 'log',
xLimits: [1e-2, 10],
yLimits: [1e-6, 1],
xLabel: 'Acceleration(g)',
yLabel: 'Annual Probability of Exceedance',
gridColor: '#efefef',
backgroundColor: '#f3f6f4',
numTickX: 5,
Expand All @@ -78,6 +84,8 @@ TooltipWithCrosshair.args = {
scaleType: 'log',
xLimits: [1e-2, 10],
yLimits: [1e-6, 1],
xLabel: 'Acceleration(g)',
yLabel: 'Annual Probability of Exceedance',
gridColor: '#efefef',
backgroundColor: '#ffffff',
numTickX: 5,
Expand All @@ -96,6 +104,8 @@ UncertaintyFalse.args = {
scaleType: 'log',
xLimits: [1e-2, 10],
yLimits: [1e-6, 1],
xLabel: 'Acceleration(g)',
yLabel: 'Annual Probability of Exceedance',
gridColor: '#efefef',
backgroundColor: '#ffffff',
numTickX: 5,
Expand All @@ -113,6 +123,8 @@ UncertaintyFalse.args = {
SpectralAccelUncertaintyTrue.args = {
scaleType: 'linear',
yScaleType: 'linear',
xLabel: 'Period [s]',
yLabel: 'Shaking Intensity [g]',
xLimits: [-1, 6],
yLimits: [0, 4],
gridColor: '#efefef',
Expand All @@ -132,6 +144,8 @@ SpectralAccelUncertaintyTrue.args = {
SpectralAccelUncertaintyFalse.args = {
scaleType: 'linear',
yScaleType: 'linear',
xLabel: 'Period [s]',
yLabel: 'Shaking Intensity [g]',
xLimits: [-1, 6],
yLimits: [0, 4],
gridColor: '#efefef',
Expand Down
26 changes: 23 additions & 3 deletions src/GroupCurveChart/GroupCurveChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,27 @@ import PlotHeadings from '../common/PlotHeadings';
import { HazardColorScale } from '../types/hazardCharts.types';

const GroupCurveChart: React.FC<GroupCurveChartProps> = (props: GroupCurveChartProps) => {
const { spectral, scaleType, yScaleType, xLimits, yLimits, gridColor, backgroundColor, numTickX, numTickY, width, curves, tooltip, crosshair, heading, subHeading, poe, uncertainty } = props;
const {
spectral,
scaleType,
yScaleType,
xLabel,
yLabel,
xLimits,
yLimits,
gridColor,
backgroundColor,
numTickX,
numTickY,
width,
curves,
tooltip,
crosshair,
heading,
subHeading,
poe,
uncertainty,
} = props;
const height = width * 0.75;
const marginLeft = 50;
const marginRight = 50;
Expand Down Expand Up @@ -138,10 +158,10 @@ const GroupCurveChart: React.FC<GroupCurveChartProps> = (props: GroupCurveChartP
<rect x={0} y={0} width={width} height={height} fill={backgroundColor ?? '#ffffff'} rx={14} />
<PlotHeadings heading={heading} subHeading={subHeading} width={width} />
<text y={height - 15} x={xMax / 2} fontSize={10}>
Acceleration (g)
{xLabel}
</text>
<text y={15} x={-width / 2} transform="rotate(-90)" fontSize={10}>
Annual Probability of Exceedance
{yLabel}
</text>
<Group left={marginLeft} top={marginTop}>
<AxisBottom top={yMax} scale={xScale} numTicks={numTickX ?? 5} stroke={gridColor} tickLength={3} tickStroke={gridColor} />
Expand Down
2 changes: 2 additions & 0 deletions src/GroupCurveChart/groupCurveChart.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface GroupCurveChartProps {
spectral?: boolean;
scaleType: 'log' | 'linear';
yScaleType?: 'log' | 'linear';
xLabel?: string;
yLabel?: string;
xLimits: number[];
yLimits: number[];
gridColor?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/GroupCurveChartResponsive/GroupCurveChartResponsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface GroupCurveChartResponsiveProps {
yScaleType?: 'log' | 'linear';
xLimits: number[];
yLimits: number[];
xLabel?: string;
yLabel?: string;
gridColor?: string;
backgroundColor?: string;
numTickX?: number;
Expand Down

0 comments on commit 47fd706

Please sign in to comment.