简体   繁体   中英

react calendar timeline issue

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")}
        />

在此处输入图像描述 };

I want to current date vertical lines on calendar

expected output

在此处输入图像描述

What should i do? anyone tell me please?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM