mirror of
https://github.com/rybbit-io/rybbit.git
synced 2025-05-10 20:05:38 +02:00
refactor: improve dashed line display logic
• consolidate display conditions into shouldNotDisplay flag • use today and currentMonth for date comparisons
This commit is contained in:
parent
b91721d41f
commit
dd5b79c1c6
1 changed files with 11 additions and 4 deletions
|
@ -136,10 +136,17 @@ export function Chart({
|
||||||
})
|
})
|
||||||
.filter((e) => e !== null) || [];
|
.filter((e) => e !== null) || [];
|
||||||
|
|
||||||
const displayDashed = time.mode === "day" && // display dashed only if current mode it DAY
|
const currentDayStr = DateTime.now().toISODate();
|
||||||
time.day === DateTime.now().toISODate() && // display dashed only if day its TODAY
|
const currentMonthStr = DateTime.now().toFormat('yyyy-MM-01');
|
||||||
bucket === "hour" && // display dashed only if its by hours representation
|
const shouldNotDisplay = (
|
||||||
formattedData.length > 1; // display dashed only if there two and more datapoints
|
time.mode === 'all-time' || // do not display in all-time mode
|
||||||
|
time.mode === 'year' || // do not display in year mode
|
||||||
|
(time.mode === 'month' && time.month !== currentMonthStr) || // do not display in month mode if month is not current
|
||||||
|
(time.mode === 'day' && time.day !== currentDayStr) || // do not display in day mode if day is not current
|
||||||
|
(time.mode === 'range' && time.endDate !== currentDayStr) || // do not display in range mode if end date is not current day
|
||||||
|
(time.mode === 'day' && (bucket === 'minute' || bucket === 'five_minutes')) // do not display in day mode if bucket is minute or five_minutes
|
||||||
|
);
|
||||||
|
const displayDashed = formattedData.length >= 2 && !shouldNotDisplay;
|
||||||
|
|
||||||
const baseGradient = {
|
const baseGradient = {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue