【问题标题】:How can I change the background color of horizontal bar if date value is less than to current date?如果日期值小于当前日期,如何更改水平条的背景颜色?
【发布时间】:2019-04-29 01:07:58
【问题描述】:

如果日期值小于当前日期,我想更改highcharts(甘特图)中水平条的背景颜色?请看图片: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'
})

【问题讨论】:

    标签: javascript highcharts gantt-chart


    【解决方案1】:

    假设您在上面的代码中指定了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'
        }  
    

    颜色为红色或蓝色,取决于当前日期值

    【讨论】:

      猜你喜欢
      • 2017-05-05
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 2021-02-22
      • 1970-01-01
      • 2015-03-11
      相关资源
      最近更新 更多