small ts fixes

This commit is contained in:
gingervitis
2020-10-31 23:17:44 -07:00
parent 4acc58baf0
commit de44f8b99d
2 changed files with 39 additions and 32 deletions

View File

@@ -5,7 +5,8 @@ interface ToolTipProps {
active?: boolean,
payload?: object,
unit?: string
};
}
const defaultProps = {
active: false,
payload: {},
@@ -13,12 +14,16 @@ const defaultProps = {
};
interface ChartProps {
data: [{}],
data: [{
time: string,
}],
color: string,
unit: string,
dataCollections?: {},
dataCollections?: any,
}
function CustomizedTooltip(props: ToolTipProps) {
const { active, payload, unit } = props;
if (active && payload && payload[0]) {
@@ -40,15 +45,11 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps
return timeFormat("%I:%M")(new Date(tick));
};
let ticks = data.map((item) => item?.time);
if (dataCollections) {
var ticks = dataCollections[0].data?.map(function (collection) {
return collection?.time;
})
} else {
var ticks = data.map(function (item) {
return item?.time;
});
ticks = dataCollections[0].data?.map((collection) => collection?.time);
}
return (
<LineChart width={1200} height={400} data={data}>
<XAxis
@@ -90,3 +91,7 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps
</LineChart>
);
}
Chart.defaultProps = {
dataCollections: [],
};