0

I am facing some issue in react-calendar-timeline . i create a calendar using this package:

https://www.npmjs.com/package/react-calendar-timeline

my code:

    this.state = {

      items: [],
      groups: [],

  componentDidMount() {

    var self = this;     
      axios
        .get(
          `http://localhost/v1/appointments`
        )
        .then(function(res){
           ....

          const itemsArray = items;
          const groupsArray = groups;
          self.setState({
            groups: groupsArray,
            items: itemsArray,
          });

        });



}


        <Timeline
           groups={this.state.groups}
           items={this.state.items}
          defaultTimeStart={moment().subtract(1, 'hour')}
          defaultTimeEnd={moment().add(3, 'hour').add(30, "minute")}
        />

enter image description here };

I want to current date vertical lines on calendar

expected output

enter image description here

What should i do? anyone tell me please?

1 Answer 1

1

You can define custom TimelineMarkers

import Timeline, {
  TimelineMarkers,
  CustomMarker,
  TodayMarker,
  CursorMarker
} from 'react-calendar-timeline'

const today = new Date()

<Timeline>
  <TimelineMarkers>
    <TodayMarker />
    <CustomMarker date={today} />
    <CustomMarker date={tomorrow}>
      {/* custom renderer for this marker */}
      {({ styles, date }) => {
        const customStyles = {
          ...styles,
          backgroundColor: 'deeppink',
          width: '4px'
        }
        return <div style={customStyles} onClick={someCustomHandler} />
      }}
    </CustomMarker>
    <CursorMarker />
  </TimelineMarkers>
</Timeline>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.