回复 8楼还没想好的帖子
现在将demo中的第一个series的第二段移到别的位置,目前调整做到如下程度:
1.在Task类里添加double[]类型的 value字段,代码参考:
- class Task
- {
- public double[] Value { get; set; }
- public string Name { get; set; }
- public DateTime[] Start { get; set; }
- public DateTime[] End { get; set; }
- public bool IsGroup { get; set; }
- public Task(string name, DateTime[] start, DateTime[] end, bool isGroup, double[] value)
- {
- Name = name;
- Start = start;
- End = end;
- IsGroup = isGroup;
- Value = value;
- }
- }
复制代码
2.GetTasks方法修改,代码参考:
- Task[] GetTasks()
- {
- DateTime start = new DateTime(2008, 1, 1, 1, 0, 0);
- DateTime end = new DateTime(2008, 1, 1, 3, 0, 0);
- DateTime[] startAlpha = new DateTime[] { start, start.AddHours(3) };
- DateTime[] endAlpha = new DateTime[] { end, end.AddHours(5) };
- double[] valueAlpha = new double[] {0.1,0.16 };
- DateTime[] startSpec = new DateTime[] { start.AddHours(1), start.AddHours(4) };
- DateTime[] endSpec = new DateTime[] { end.AddHours(1), end.AddHours(6) };
- double[] valueSpec = new double[] { 0.1, 0.2 };
- DateTime[] startPrototype = new DateTime[] { start.AddHours(2), start.AddHours(5) };
- DateTime[] endPrototype = new DateTime[] { end.AddHours(2), end.AddHours(8) };
- double[] valuePrototype = new double[] { 0.2, 0.3 };
- return new Task[]
- {
- new Task("Alpha", startAlpha, endAlpha,true,valueAlpha),
- new Task("Spec", startSpec,endSpec,true,valueSpec),
- new Task("Prototype", startPrototype, endPrototype, false,valuePrototype),
- };
- }
复制代码
3.在foreach的循环里添加如下代码进行值的绑定:
- ds.XValuesSource = task.Value;
复制代码
4.注销掉如下代码:
- //c1Chart1.Data.ItemNames = (from task in tasks select task.Name).ToArray();
复制代码 |