Browse Source

Merge pull request #2440 from Rubik-W/fixbug-#2439

fix: Gantt chart bug #2439
pull/2/head
xingchun-chen 5 years ago committed by GitHub
parent
commit
c4f44a62b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/_source/gantt.js

14
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/_source/gantt.js

@ -24,7 +24,7 @@ let Gantt = function () {
this.tasks = [] this.tasks = []
this.width = null this.width = null
this.height = null this.height = null
this.tasksName = [] this.taskNames = []
this.tickFormat = `%H:%M:%S` this.tickFormat = `%H:%M:%S`
this.margin = { this.margin = {
top: 10, top: 10,
@ -39,8 +39,12 @@ let Gantt = function () {
Gantt.prototype.init = function ({ el, tasks }) { Gantt.prototype.init = function ({ el, tasks }) {
this.el = el this.el = el
this.tasks = tasks this.tasks = tasks
this.tasksName = _.map(_.cloneDeep(tasks), v => v.taskName) this.taskNames = _.map(_.cloneDeep(tasks), v => v.taskName)
this.height = parseInt(this.tasksName.length * 30) this.taskNames = this.taskNames.reduce(function (prev, cur) {
prev.indexOf(cur) === -1 && prev.push(cur);
return prev;
},[])
this.height = parseInt(this.taskNames.length * 30)
this.width = $(this.el).width() - this.margin.right - this.margin.left - 5 this.width = $(this.el).width() - this.margin.right - this.margin.left - 5
this.x = d3.time.scale() this.x = d3.time.scale()
@ -49,7 +53,7 @@ Gantt.prototype.init = function ({ el, tasks }) {
.clamp(true) .clamp(true)
this.y = d3.scale.ordinal() this.y = d3.scale.ordinal()
.domain(this.tasksName) .domain(this.taskNames)
.rangeRoundBands([ 0, this.height - this.margin.top - this.margin.bottom ], 0.1) .rangeRoundBands([ 0, this.height - this.margin.top - this.margin.bottom ], 0.1)
this.xAxis = d3.svg.axis() this.xAxis = d3.svg.axis()
@ -98,7 +102,7 @@ Gantt.prototype.initializeXAxis = function () {
.clamp(true) .clamp(true)
this.y = d3.scale.ordinal() this.y = d3.scale.ordinal()
.domain(this.tasksName) .domain(this.taskNames)
.rangeRoundBands([ 0, this.height - this.margin.top - this.margin.bottom ], 0.1) .rangeRoundBands([ 0, this.height - this.margin.top - this.margin.bottom ], 0.1)
this.xAxis = d3.svg.axis() this.xAxis = d3.svg.axis()

Loading…
Cancel
Save