Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fix legend color mismatch.

Mike Cao5f359b3cf156
diff --git a/components/metrics/BarChart.js b/components/metrics/BarChart.js
index 35e96c8da..e2617012f 100644
--- a/components/metrics/BarChart.js
+++ b/components/metrics/BarChart.js
@@ -6,10 +6,10 @@ import { formatLongNumber } from 'lib/format';
import { dateFormat } from 'lib/date';
import useLocale from 'hooks/useLocale';
import useTheme from 'hooks/useTheme';
+import useForceUpdate from 'hooks/useForceUpdate';
import { DEFAUL_CHART_HEIGHT, DEFAULT_ANIMATION_DURATION, THEME_COLORS } from 'lib/constants';
import styles from './BarChart.module.css';
import ChartTooltip from './ChartTooltip';
-import useForceUpdate from '../../hooks/useForceUpdate';
export default function BarChart({
chartId,
diff --git a/components/metrics/Legend.js b/components/metrics/Legend.js
index 37cb5b497..b919d80e9 100644
--- a/components/metrics/Legend.js
+++ b/components/metrics/Legend.js
@@ -1,9 +1,10 @@
import React from 'react';
+import tinycolor from 'tinycolor2';
import classNames from 'classnames';
import Dot from 'components/common/Dot';
import useLocale from 'hooks/useLocale';
+import useForceUpdate from 'hooks/useForceUpdate';
import styles from './Legend.module.css';
-import useForceUpdate from '../../hooks/useForceUpdate';
export default function Legend({ chart }) {
const { locale } = useLocale();
@@ -25,16 +26,20 @@ export default function Legend({ chart }) {
return (
<div className={styles.legend}>
- {chart.legend.legendItems.map(({ text, fillStyle, datasetIndex, hidden }) => (
- <div
- key={text}
- className={classNames(styles.label, { [styles.hidden]: hidden })}
- onClick={() => handleClick(datasetIndex)}
- >
- <Dot color={fillStyle} />
- <span className={locale}>{text}</span>
- </div>
- ))}
+ {chart.legend.legendItems.map(({ text, fillStyle, datasetIndex, hidden }) => {
+ const color = tinycolor(fillStyle);
+
+ return (
+ <div
+ key={text}
+ className={classNames(styles.label, { [styles.hidden]: hidden })}
+ onClick={() => handleClick(datasetIndex)}
+ >
+ <Dot color={color.setAlpha(color.getAlpha() + 0.2)} />
+ <span className={locale}>{text}</span>
+ </div>
+ );
+ })}
</div>
);
}