D3 scale time ticks start and end time not included

Viewed 21

I have one doubt on scale time. It's not included start and end times on ticks. How do I include that in ticks?

What I have tried

import { scaleTime,} from "d3-scale";

  const now = moment().set({ hour: 8 }).valueOf();
  const days = moment().add(2, "days").set({ hour: 8 }).valueOf();

  const _ticks = scaleTime()
    .domain([now, days])
    .nice()
    .ticks(9)
    .map((e) => moment(e).format("l hh:mm"));

Output

[ "8/25/2022 06:00", "8/25/2022 12:00", "8/25/2022 06:00", "8/26/2022 12:00", "8/26/2022 06:00", "8/26/2022 12:00", "8/26/2022 06:00", "8/27/2022 12:00", "8/27/2022 06:00", "8/27/2022 12:00" ]

Is there any to include only the start end time exactly in ticks. Please give me a solution

0 Answers
Related