Exemple #1
0
        private async Task DisplayPlacesStats()
        {
            chrtSets.Series.Clear();

            if (PlacesStats.Any())
            {
                List <CustomLabel> Labels = new List <CustomLabel>();
                chrtSets.ChartAreas[0].AxisX.Title = "Instalacja";
                chrtSets.ChartAreas[0].AxisY.Title = "Czas obsługi [min]";
                chrtSets.ChartAreas[0].AxisY.MajorGrid.LineColor     = Color.Gray;
                chrtSets.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
                chrtSets.ChartAreas[0].AxisX.MajorGrid.LineColor     = Color.Gray;
                chrtSets.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
                //chartProgress.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 14, FontStyle.Bold);

                //get unique actionTypes which will become series
                List <string> uniqueActions = GetUniqueActionTypes(PlacesStats);
                int           i             = 1;

                foreach (var action in uniqueActions)
                {
                    chrtSets.Series.Add(action);
                    chrtSets.Series[action].ChartType = SeriesChartType.StackedBar;
                    Color color    = Color.Empty;
                    bool  existent = RuntimeSettings.ProcessColors.TryGetValue(action, out color);
                    if (existent)
                    {
                        chrtSets.Series[action].Color = color;
                    }
                    chrtSets.Series[action].XValueType = ChartValueType.String;
                }
                foreach (var place in PlacesStats)
                {
                    string setName = place.SetName;
                    int    setId   = Convert.ToInt32(place.SetId.ToString());

                    foreach (var actionName in uniqueActions)
                    {
                        int actionLength = 0;
                        foreach (var action in place.Handlings)
                        {
                            if (action.Name == actionName)
                            {
                                actionLength = Convert.ToInt32(action.Length.ToString());
                                break;
                            }
                        }
                        int pos = chrtSets.Series[actionName].Points.AddXY(i, actionLength);
                        chrtSets.ChartAreas[0].AxisX.CustomLabels.Add(i - 0.5, i + 0.5, setName);
                    }

                    i++;
                }
                chrtSets.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;
                chrtSets.ChartAreas[0].AxisX.IsLabelAutoFit    = true;
            }
        }
Exemple #2
0
        public async Task LoadPlacesStats()
        {
            try
            {
                PlacesStats = await PlacesKeeper.GetPlacesStats(DateFrom, DateTo, 10);

                PlacesStats.Reverse();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wystąpił problem przy pobieraniu statystyk zgłoszeń wg instalacji", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }