Skip to content

Commit

Permalink
fix group curve chart threshold display error (#78)
Browse files Browse the repository at this point in the history
* fix group curve chart threshold display error
* fix typo
  • Loading branch information
0qy authored Aug 4, 2022
1 parent d3424bd commit 926bf2e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/GroupCurveChart/GroupCurveChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import PlotHeadings from '../common/PlotHeadings';
import { HazardColorScale } from '../types/hazardCharts.types';

const GroupCurveChart: React.FC<GroupCurveChartProps> = (props: GroupCurveChartProps) => {
const { scaleType, yScaleType, xLimits, yLimits, gridColor, backgroundColor, numTickX, numTickY, width, curves, tooltip, crosshair, heading, subHeading, poe, uncertainty } = props;
const { spectral, scaleType, yScaleType, 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 @@ -165,7 +165,7 @@ const GroupCurveChart: React.FC<GroupCurveChartProps> = (props: GroupCurveChartP
/>
))}
<Threshold<number[]>
id={`uncertianty-area-${index}`}
id={spectral ? `uncertainty-area-spectral-${index}` : `uncertainty-area-${index}`}
data={getAreaData(curves[key])}
x={(d) => xScale(d[0])}
y0={(d) => yScale(d[2])}
Expand Down Expand Up @@ -195,7 +195,7 @@ const GroupCurveChart: React.FC<GroupCurveChartProps> = (props: GroupCurveChartP
))}
</>
)}
{poe && <LinePath role="POE" data={poeLine} x={(d) => xScale(d.x)} y={(d) => yScale(d.y)} stroke="#989C9C" />}
{poe && !spectral && <LinePath role="POE" data={poeLine} x={(d) => xScale(d.x)} y={(d) => yScale(d.y)} stroke="#989C9C" />}
</Group>
{crosshair && tooltipOpen && (
<g>
Expand Down
1 change: 1 addition & 0 deletions src/GroupCurveChart/groupCurveChart.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface GroupCurveChartProps {
spectral?: boolean;
scaleType: 'log' | 'linear';
yScaleType?: 'log' | 'linear';
xLimits: number[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';

import GroupCurveChartResponsive from '.';
import { curveGroup2, curveGroup1 } from '../__tests__/testData/uncertaintyTestData';
import spectralAccelUncertaintyTestData from '../__tests__/testData/spectralAccelUncertaintyTestData';

export default {
title: 'Charts/GroupCurveChartResponsive',
Expand All @@ -12,6 +13,8 @@ export default {
const Template: ComponentStory<typeof GroupCurveChartResponsive> = (args) => <GroupCurveChartResponsive {...args} />;

export const Primary = Template.bind({});
export const SpectralAccelUncertaintyTrue = Template.bind({});
export const SpectralAccelUncertaintyFalse = Template.bind({});

Primary.args = {
scaleType: 'log',
Expand All @@ -28,3 +31,39 @@ Primary.args = {
subHeading: 'WLG 250',
poe: 0.02,
};

SpectralAccelUncertaintyTrue.args = {
scaleType: 'linear',
yScaleType: 'linear',
xLimits: [-1, 6],
yLimits: [0, 4],
gridColor: '#efefef',
backgroundColor: '#ffffff',
numTickX: 5,
numTickY: 5,
curves: spectralAccelUncertaintyTestData,
tooltip: true,
crosshair: true,
heading: 'Spectra with Uncertainty',
subHeading: 'WLG 400m/s',
poe: undefined,
uncertainty: true,
};

SpectralAccelUncertaintyFalse.args = {
scaleType: 'linear',
yScaleType: 'linear',
xLimits: [-1, 6],
yLimits: [0, 4],
gridColor: '#efefef',
backgroundColor: '#ffffff',
numTickX: 5,
numTickY: 5,
curves: spectralAccelUncertaintyTestData,
tooltip: true,
crosshair: true,
heading: 'Sepectra without Uncertainty',
subHeading: 'WLG 400m/s',
poe: undefined,
uncertainty: false,
};

0 comments on commit 926bf2e

Please sign in to comment.