甘特图蟒蛇机调度

问题描述 投票:1回答:1

我正在尝试用python从数据集中绘制甘特图时遇到一些不好的时间。我有一套机器可以在一段时间内处理不同的任务。我想制作一个甘特图,通过y轴显示机器,x轴显示每个任务所花费的时间。每台机器应该只在y轴上出现一次,以便更容易看到我希望每项任务都有相同颜色的任务。

我们的想法是检查一些奇怪的事情,例如将两台或多台机器一起处理相同的任务。

让我用一个小例子展示我的数据集:

machine   equipment   start   finish
  m1         e2       date1    date2
  m2         e2       date3    date4
  m1         e1       date5    date6
  m3         e3       date7    date8
  m3         e4       date9    date10

我试图使用matplotlib中的broken_barh,但我无法找到一种方法来有效地添加绘图数据。因为我有100台机器和400个任务。

Here is a picture显示输出应该如何。

当前代码如下:

import datetime as dt

machines = set(list(mydata["machine"]))
tasks = set(list(mydata["task"]))

fig, ax = plt.subplots(figsize=(20, 10))

yrange = 5 # y width of gantt bar
ymin = 0
orign = min(list(mydata["start"])) # time origin

for i in machines:

    stdur = [] # list of tuples (start, duration)
    ymin = index*6 # start y of gantt bar

    for index, row in mydata.iterrows():

        if row["machine"] == i:
            start = (row["start"] -  orign).total_seconds()/3600
            duration = (row["finish"] -  row["start"]).total_seconds()/3600

            stdur.append((start,duration))

    ax.broken_barh(stdur,(ymin,yrange))

ax.set_xlabel('Time')
ax.set_yticklabels(machines)

plt.show()
python matplotlib job-scheduling gantt-chart
1个回答
0
投票

Seimetz

如果您可以将整个数据传递给客户端并让JS Gantt做到这一点,那么RadiantQ jQuery Gantt Package将是一个更好的选择。这是一个类似的在线演示:http://demos.radiantq.com/jQueryGanttDemo/Samples/ServerStatusWithHugeData.htm

这就是它的样子:Server Status Sample

更多关于这里的产品:http://radiantq.com/products/jquery-gantt-package/jquery-gantt-package-features/

© www.soinside.com 2019 - 2024. All rights reserved.