Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/GanttChart.cs @ 5597

Last change on this file since 5597 was 5597, checked in by cneumuel, 13 years ago

#1233

  • extended jobview to show statelog as list with details or as ganttview
  • also a ganttview of all statelogs of all childjobs was implemented
File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using System.Windows.Forms;
5using System.Windows.Forms.DataVisualization.Charting;
6
7namespace HeuristicLab.Clients.Hive.Views.ExperimentManager {
8  public partial class GanttChart : UserControl {
9
10    private IDictionary<string, Color> categories = new Dictionary<string, Color>();
11
12    public GanttChart() {
13      InitializeComponent();
14    }
15
16    public void AddCategory(string name, Color color) {
17      categories[name] = color;
18      chart.Legends[0].CustomItems.Add(color, name);
19    }
20
21    public void AddData(int id, string category, DateTime start, DateTime end, string tooltip, bool showLabel = true) {
22      var point = CreateDataPoint(id, start, end, showLabel ? category : string.Empty, categories[category]);
23      point.ToolTip = tooltip;
24      chart.Series[0].Points.Add(point);
25    }
26
27    private static DataPoint CreateDataPoint(double x, DateTime start, DateTime end, string text, Color color) {
28      var point = new DataPoint(x, new double[] { start.ToOADate(), end.ToOADate() });
29      point.Color = color;
30      point.Label = text;
31      return point;
32    }
33
34    public void Reset() {
35      chart.Series[0].Points.Clear();
36      categories.Clear();
37      chart.Legends[0].CustomItems.Clear();
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.