简体   繁体   English

如果日期值小于当前日期,如何更改横条的背景颜色?

[英]How can I change the background color of horizontal bar if date value is less than to current date?

I want to change the background color of horizontal bar in highcharts(gantt chart) if the date value is less than to current date? 如果日期值小于当前日期,我想更改高图(甘特图)中水平条的背景颜色吗? Please take a look on the picture: https://ibb.co/3MNqJJy and this is the jsfiddle: https://jsfiddle.net/57n1cjyr/ 请看图片: https ://ibb.co/3MNqJJy,这是jsfiddle: https ://jsfiddle.net/57n1cjyr/

var today = new Date().getTime(),
  day = 1000 * 60 * 60 * 24;
var options = {
    title: {
      text: 'Visual Planner Chart with Navigation',
    },
    xAxis: currentDateIndicator: true,
    min: today - 3 * day,
    max: today + 18 * day
  },
  yAxis: {
    uniqueNames: true

  },
  series: [{
    name: 'Visual Planner',
    data: [],
    dataLabels: {
      enabled: true,
      format: '{point.owner}'
    }
  }]
}

var ganttChart = Highcharts.ganttChart('container-ganttChart', options)

ganttChart.series[0].addPoint({
  start: Date.UTC(2019, 01, 30),
  end: Date.UTC(2019, 03, 01),
  name: 'crewRank',
  owner: 'crewName'
})

Assuming you have start and today specified as in the code above, this seems to work (replace the last part with it, the other code is unmodified): 假设您已经按照上面的代码指定了starttoday ,似乎可以正常工作(用最后一部分代替它,其他代码未修改):

    var startDate=Date.UTC(2019, 01, 30)
    // call gantt chart then add series
    ganttChart.series[0].addPoint({
        start: startDate,
        end: Date.UTC(2019, 03, 01),
        name: 'crewRank',
        owner: 'crewName',
        color:  new Date(startDate).getTime() < today ? 'red' :'blue'
    }  

The color is red or blue depending on the current date value 颜色是红色还是蓝色,具体取决于当前日期值

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用jquery检查日期不能小于当前日期? - how to check date can not be less than current date using jquery? 如何在剑道日期选择器上显示小于最小日期或大于最大日期的日期 - How can I show a date on a kendo datepicker which is less than min date or greater than max date 如何将用户输入的日期与当前日期进行比较并更改字段的背景色? - how to compare a user entered date to the current date and change a fields background color? 如何使用angularjs检查所选日期和所选时间小于当前日期或大于当前日期和时间? - How to check selected date and selected time is less than current or greater than current date and time using angularjs? 如果数量列的数值小于10,如何更改表格行的背景颜色 - How to change background color of table row if quantity column has numeric value less than 10 较少如何在达到100%时更改进度栏背景颜色 - LESS How to change a progress bar background color when it reaches 100% 如何更改 FullCalendar 中所选日期的背景颜色 - How to change background color of selected date in FullCalendar 如果小于当前日期,则删除范围内的单元格 - Delete cells in range if less than current date 如果日期比当前日期少 15 分钟,那么做一些事情 - If Date is Less Than Current Date by 15mins then do something 如何在输入表单字段中插入当前日期作为值 - How can i insert current date as a value in an input form field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM