I am trying to fill the colors to charts based on times, Here I may confusing to do this task. For this I tried below code.
Example: Assume have the below (Class) start and end time and shift start and end time:
In the chart there are <a href="https://ibb.co/f0RvyL5">3 Series</a>.
Work Time needs to fill with Green Color
Over time needs to fill Blue Color
Break time needs to fill with Red color.
The Validations are below.
if(AST < SST)
"Break Time".
else if(AET > SET)
"Over Time".
else
"Work Time".
Sample Chart Link
Above conditions are not working for me.
Can you please help on this?
Thank you.
What I have tried:
<dx:WebChartControl ID="WebChartControl1" runat="server"
ToolTipEnabled="False"
RenderFormat="Svg"
Height="500px" Width="900px">
<Legend Name="Default Legend"></Legend>
<SeriesSerializable>
</SeriesSerializable>
<SeriesTemplate ArgumentScaleType="Qualitative" ValueScaleType="DateTime">
<ViewSerializable>
<cc1:OverlappedGanttSeriesView>
<FillStyle FillMode="Gradient">
<OptionsSerializable>
<cc1:RectangleGradientFillOptions Color2="YellowGreen"
GradientMode="BottomToTop" />
</OptionsSerializable>
</FillStyle>
</cc1:OverlappedGanttSeriesView>
</ViewSerializable>
</SeriesTemplate>
</dx:WebChartControl>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["dummyCl"] = null;
GetTempWMCenterClasses();
BindCharts();
}
}
public class tempWMCenterClass
{
public string No { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
}
TimeSpan tempShiftStartTime;
TimeSpan tempShiftEndTime;
TimeSpan tempActualStartTime;
TimeSpan tempActualEndTime;
DateTime tempDtShiftStartTime;
DateTime tempDtShiftEndTime;
DateTime tempDtActualStartTime;
DateTime tempDtActualEndTime;
List<tempWMCenterClass> objTemp = new List<tempWMCenterClass>();
private List<tempWMCenterClass> GetTempWMCenterClasses()
{
if (Session["dummyCl"] == null)
{
objTemp.Add(new tempWMCenterClass { No = "DrillPress", StartTime = "10:00:00 AM", EndTime = "1:00:00 PM" });
objTemp.Add(new tempWMCenterClass { No = "DrillPress", StartTime = "2:00:00 PM", EndTime = "4:00:00 PM" });
objTemp.Add(new tempWMCenterClass { No = "DrillPress", StartTime = "5:00:00 PM", EndTime = "7:00:00 PM" });
objTemp.Add(new tempWMCenterClass { No = "PUMA", StartTime = "6:00:00 AM", EndTime = "11:02:00 AM" });
objTemp.Add(new tempWMCenterClass { No = "PUMA", StartTime = "2:00:00 PM", EndTime = "4:00:00 PM" });
objTemp.Add(new tempWMCenterClass { No = "PUMA", StartTime = "5:00:00 PM", EndTime = "7:00:00 PM" });
Session["dummyCl"] = objTemp;
}
else
objTemp = (List<tempWMCenterClass>)Session["dummyCl"];
return objTemp;
}
private void BindCharts()
{
if (Session["dummyCl"] != null)
objTemp = (List<tempWMCenterClass>)Session["dummyCl"];
WebChartControl1.Series.Add(new Series("Order Status Time", ViewType.Gantt));
WebChartControl1.Series[0].ValueScaleType = ScaleType.DateTime;
WebChartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
WebChartControl1.Series.Add(new Series("Order Status Time Empty", ViewType.Gantt));
WebChartControl1.Series[1].ValueScaleType = ScaleType.DateTime;
WebChartControl1.Series[1].ArgumentScaleType = ScaleType.Qualitative;
WebChartControl1.Series.Add(new Series("Order Status Time Over", ViewType.Gantt));
WebChartControl1.Series[2].ValueScaleType = ScaleType.DateTime;
WebChartControl1.Series[2].ArgumentScaleType = ScaleType.Qualitative;
int tempIndex = 0;
int lastIndex = 0;
var objDistrict = objTemp.Select(n => n.No).Distinct().ToList();
for (int i = 0; i < objDistrict.Count(); i++)
{
if (string.IsNullOrEmpty(objDistrict[i]))
return;
DateTime.TryParse("7:00:00 AM", out tempDtShiftStartTime);
DateTime.TryParse("4:00:00 PM", out tempDtShiftEndTime);
tempShiftStartTime = tempDtShiftStartTime.TimeOfDay;
tempShiftEndTime = tempDtShiftEndTime.TimeOfDay;
for (int j = 0; j < objTemp.Count(); j++)
{
if (objDistrict[i] == objTemp[j].No)
{
DateTime.TryParse(objTemp[j].StartTime, out tempDtActualStartTime);
DateTime.TryParse(objTemp[j].EndTime, out tempDtActualEndTime);
tempActualStartTime = tempDtActualStartTime.TimeOfDay;
tempActualEndTime = tempDtActualEndTime.TimeOfDay;
if (tempIndex == 0)
{
if (tempActualStartTime > tempShiftStartTime)
WebChartControl1.Series[1].Points.Add(new SeriesPoint(objDistrict[i], new DateTime[] { tempDtShiftStartTime, tempDtActualStartTime }));
else
WebChartControl1.Series[0].Points.Add(new SeriesPoint(objDistrict[i], new DateTime[] { tempDtActualStartTime, tempDtActualEndTime }));
}
else if (lastIndex == j)
{
if (tempActualEndTime > tempShiftEndTime)
WebChartControl1.Series[2].Points.Add(new SeriesPoint(objDistrict[i], new DateTime[] { tempDtShiftEndTime, tempDtActualEndTime }));
else
WebChartControl1.Series[0].Points.Add(new SeriesPoint(objDistrict[i], new DateTime[] { tempDtActualStartTime, tempDtActualEndTime }));
}
else
{
WebChartControl1.Series[0].Points.Add(new SeriesPoint(objDistrict[i], new DateTime[] { tempDtActualStartTime, tempDtShiftEndTime }));
}
lastIndex = objTemp.Count() - 1;
tempIndex++;
}
}
tempIndex = 0;
}
}