You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/assets/js/dashboard/stats/bar.js

23 lines
467 B
JavaScript

import React from 'react';
function barWidth(count, all) {
let maxVal = all[0].count;
for (const entry of all) {
if (entry.count > maxVal) maxVal = entry.count
}
return count / maxVal * 100
}
export default function Bar({count, all, color}) {
color = color ? color : "blue"
const width = barWidth(count, all)
return (
<div className="bar">
<div className={`bar__fill bg-${color}`} style={{width: width + '%'}}></div>
</div>
)
}