Amcharts:Gantt-浮动时间

时间:2018-08-22 12:35:02

标签: javascript amcharts

是否可以以浮点数for example, 0.89

输入持续时间

我的小提琴-https://jsfiddle.net/sachinpsingh/36xqwskf/1/

我尝试过,但似乎只接受整数值。

代码-

AmCharts.useUTC = true;
var chart = AmCharts.makeChart("chartdiv", {
  "type": "gantt",
  "theme": "light",
  "period": "fff",
  "dataDateFormat": "YYYY-MM-DD HH:NN:SS",
  "balloonDateFormat": "QQQ",
  "columnWidth": 0.5,
  "marginBottom": 30,
  "valueAxis": {
    "type": "date",
    "minPeriod": "fff",
    "ignoreAxisWidth": true
  },
  "brightnessStep": 10,
  "graph": {
    "fillAlphas": 1,
    "balloonText": "<b>[[task]]</b>: [[duration]]ms"
  },
  "rotate": true,
  "categoryField": "category",
  "segmentsField": "segments",
  "colorField": "color",
  "startDate": "2015-01-01 00:00:00",
  "startField": "start",
  "endField": "end",
  "durationField": "duration",
  "dataProvider": [{
    "category": "John",
    "segments": [{
      "start": 7,
      "duration": 2,
      "color": "#46615e",
      "task": "Task #1"
    }, {
      "duration": 2,
      "color": "#727d6f",
      "task": "Task #2"
    }, {
      "duration": 2,
      "color": "#8dc49f",
      "task": "Task #3"
    }]
  }, {
    "category": "Smith",
    "segments": [{
      "start": 10,
      "duration": 2,
      "color": "#727d6f",
      "task": "Task #2"
    }, {
      "duration": 1,
      "color": "#8dc49f",
      "task": "Task #3"
    }, {
      "duration": 4,
      "color": "#46615e",
      "task": "Task #1"
    }]
  }],
  "valueScrollbar": {
    "autoGridCount": true
  },
  "chartCursor": {
    "cursorColor": "#55bb76",
    "valueBalloonsEnabled": false,
    "cursorAlpha": 0,
    "valueLineAlpha": 0.5,
    "valueLineBalloonEnabled": true,
    "valueLineEnabled": true,
    "zoomable": false,
    "valueZoomable": true
  }
});

当我定义“持续时间”:4.88时,在图表中显示为“持续时间”:4(仅整数值)。

我希望它在图表中显示为4.88。

1 个答案:

答案 0 :(得分:0)

我想出了一个解决方案-

只需要将"type": "date",替换为"type": "time",

正如下-

"valueAxis": {
    "type": "time",
    "minPeriod": "fff",
    "ignoreAxisWidth": true
  }

有效!