Esempio n. 1
0
        /// <summary> Клик по описанию графика </summary>
        public void Click(LegendCell cell = null)
        {
            if (cell == null)
            {
                return;
            }
            switch (cell.CellType)
            {
            case LegendCellType.Text:
            case LegendCellType.SeriesSymbol:
                //Прямоугольник выделения
                foreach (var item in Legend.CustomItems)
                {
                    if (!(item is CheckboxLegend))
                    {
                        continue;
                    }

                    item.Cells[1].BackColor = Color.Transparent;
                    item.Cells[2].BackColor = Color.Transparent;
                }
                Cells[1].BackColor = Color.FromArgb(50, Color.Blue);
                Cells[2].BackColor = Color.FromArgb(50, Color.Blue);
                OnSelectedLegendChanged(new LegendSelectedEventArgs(_series));
                break;

            case LegendCellType.Image:
                _series.Enabled = !_series.Enabled;
                Cells[0].Image  = _series.Enabled ? _checkboxCheckedPath : _checkboxUncheckedPath;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 2
0
        private void ChartMouseDownHandler(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                OnActivated(EventArgs.Empty);
                DoDragDrop(Index, DragDropEffects.Move);
            }

            else if (e.Button == MouseButtons.Right)
            {
                if (chart_.Legends.Count == 0)
                {
                    return;
                }

                HitTestResult result = chart_.HitTest(e.X, e.Y);
                if (result.ChartElementType == ChartElementType.LegendItem)
                {
                    LegendCell cell = result.SubObject as LegendCell;
                    if (cell != null)
                    {
                        RemoveElement(cell.Text);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a LegendCell
        /// </summary>
        /// <param name="text">The text, as string in the cell </param>
        /// <returns>The LegendCell with the text</returns>
        private LegendCell createLegendCell(string text)
        {
            LegendCell lc = new LegendCell(text);

            System.Drawing.Font font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 10F);
            lc.Font = font;
            return(lc);
        }
        private void GenerateLegends()
        {
            foreach (var s in GraphInformation.SeriesData)
            {
                Chart1.Series.Add(new Series(s.SeriesName));

                var imageLocation = s.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + s.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(s.SeriesName);

                var legendCell2Colour = seriesHidden ? MarsColours.ChartLegendValuesHidden : s.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell {
                    Name      = "Cell2",
                    Text      = s.SeriesName,
                    ForeColor = legendCell2Colour
                };
                legendItem.Cells.Add(legendCell);

                var valuesShown = GraphInformation.ShowLabelSeriesNames.Contains(s.SeriesName);

                var legendCell3Colour = !valuesShown || seriesHidden ? MarsColours.ChartLegendValuesHidden : MarsColours.ChartLegendValuesShown;

                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell3Colour,
                    Font          = new Font("Tahoma", 9),
                    PostBackValue = "LegendShowLabels/" + s.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                Chart1.Legends["Legend2"].CustomItems.Add(legendItem);
            }
        }
Esempio n. 5
0
        private LegendCell CreateNewLegendCell(LegendCellType cellType, System.Drawing.Font cellFont, string text, System.Drawing.ContentAlignment cellAlignment)
        {
            LegendCell legendCell = new LegendCell();

            legendCell.CellType  = cellType;
            legendCell.Font      = cellFont;
            legendCell.Text      = text;
            legendCell.Alignment = cellAlignment;
            legendCell.ToolTip   = Resources.lang.ChartZoomFeature;

            return(legendCell);
        }
        /// <summary>
        /// Create series instance in the editor
        /// </summary>
        /// <param name="itemType">Item type.</param>
        /// <returns>Newly created item.</returns>
        protected override object CreateInstance(Type itemType)
        {
            if (Context != null && Context.Instance != null)
            {
                LegendItem legendItem = Context.Instance as LegendItem;
                if (legendItem != null)
                {
                    int    itemCount = legendItem.Cells.Count + 1;
                    string itemName  = "Cell" + itemCount.ToString(System.Globalization.CultureInfo.InvariantCulture);

                    // Check if this name already in use
                    bool itemFound = true;
                    while (itemFound)
                    {
                        itemFound = false;
                        foreach (LegendCell cell in legendItem.Cells)
                        {
                            if (cell.Name == itemName)
                            {
                                itemFound = true;
                            }
                        }

                        if (itemFound)
                        {
                            ++itemCount;
                            itemName = "Cell" + itemCount.ToString(System.Globalization.CultureInfo.InvariantCulture);
                        }
                    }

                    // Create new legend cell
                    LegendCell legendCell = new LegendCell();
                    legendCell.Name = itemName;
                    return(legendCell);
                }
            }
            return(base.CreateInstance(itemType));
        }
Esempio n. 7
0
        /// <summary>Добавление ячеек с нужными элементами</summary>
        private void AddCells()
        {
            //Изображение чекбокса
            var imageCell = new LegendCell
            {
                CellType = LegendCellType.Image,
                Image    = _series.Enabled ? _checkboxCheckedPath : _checkboxUncheckedPath
            };
            //Название графика
            var seriesCell = new LegendCell(LegendCellType.Text, _series.Name);

            seriesCell.Alignment = ContentAlignment.MiddleLeft;

            //Цвет графика
            var typeCell = new LegendCell
            {
                CellType = LegendCellType.SeriesSymbol
            };

            Cells.Add(imageCell);
            Cells.Add(typeCell);
            Cells.Add(seriesCell);
        }
        private void BuildTotalCylinderChart()
        {
            var ca = new ChartArea {
                Name = "Total Fleet Area"
            };

            ca.AxisX.MajorGrid.Enabled = false;
            ca.AxisX.Interval          = 1;
            ca.AxisY.MajorGrid.Enabled = false;
            chrtHistoricalTrend.ChartAreas.Add(ca);
            if (GraphInformation.SeriesData == null)
            {
                return;
            }

            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType = SeriesChartType.Line, Color = cd.GraphColour
                };
                //cs["DrawingStyle"] = "Cylinder";

                cs.IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName);
                cs.LabelFormat         = "#,#";
                for (int i = 0; i < cd.Xvalue.Count; i++)
                {
                    cs.Points.AddXY(cd.Xvalue[i], cd.Yvalue[i]);
                }
                chrtHistoricalTrend.Series.Add(cs);

                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(cd.SeriesName);

                var legendCell2Colour = seriesHidden ? MarsColours.ChartLegendValuesHidden : cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour
                };
                legendItem.Cells.Add(legendCell);

                var valuesShown = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName);

                var legendCell3Colour = !valuesShown || seriesHidden ? MarsColours.ChartLegendValuesHidden : MarsColours.ChartLegendValuesShown;

                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell3Colour,
                    Font          = new Font("Tahoma", 9),
                    PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                chrtHistoricalTrend.Legends["RightLegend"].CustomItems.Add(legendItem);

                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }
        }
        /// <summary>
        /// Handles the PostPaint event of the mainChart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs"/> instance containing the event data.</param>
        private void mainChart_PostPaint(object sender, ChartPaintEventArgs e)
        {
            // Check if the sender is a cell of the Legend
            if (sender is LegendCell)
            {
                // Get the LegendCell
                LegendCell legendCell = sender as LegendCell;

                // Ensure it's one of the items created by this class
                if (legendCell.Name.IndexOf("ActivityItem") > -1)
                {
                    // Get the index out of the cell's name
                    index = Convert.ToInt32(legendCell.Name.Substring(12));

                    // Set the line color
                    Color lineColor = myAlternateLineColors.FirstColor;

                    // Set the alternate line colors up if necessary
                    if (myAlternateLineColors.Enabled == true)
                    {
                        if (index % 2 != 0)
                        {
                            lineColor = myAlternateLineColors.SecondColor;
                        }
                    }

                    // Check if this series is using Indexed x values
                    bool isIndexed = (mySeries[mySeriesAssignment[index]].IsXValueIndexed == true);

                    // Get the AxisType for X and Y axes
                    AxisName myYAxisName;
                    if (mySeries[mySeriesAssignment[index]].YAxisType == AxisType.Primary)
                    {
                        myYAxisName = AxisName.Y;
                    }
                    else
                    {
                        myYAxisName = AxisName.Y2;
                    }

                    // The first point of the horizontal line is the end of the legend cell (left aligned),
                    // or beginning of legend cell (right aligned)
                    PointF firstPoint = new PointF();
                    if (myLegend.Docking == Docking.Right)
                    {
                        firstPoint.X = e.Position.X - myLeftPadding;
                        firstPoint.Y = e.Position.Y + (e.Position.Height / 2);
                    }
                    else
                    {
                        firstPoint.X = e.Position.X + e.ChartGraphics.GetRelativeSize((e.ChartGraphics.Graphics.MeasureString(legendCell.Text, mySecondCellFont))).Width + 1;
                        firstPoint.Y = e.Position.Y + (e.Position.Height / 2);
                    }

                    // The second point of the horizontal line is straight to the right of the first point, on
                    // top of the desired point
                    PointF secondPoint = new PointF();
                    if (isIndexed)
                    {
                        secondPoint.X = (float)e.ChartGraphics.GetPositionFromAxis(mySeries[mySeriesAssignment[index]].ChartArea, AxisName.X, myPointIndex[index] + 1);
                    }
                    else
                    {
                        secondPoint.X = (float)e.ChartGraphics.GetPositionFromAxis(mySeries[mySeriesAssignment[index]].ChartArea, AxisName.X, mySeries[mySeriesAssignment[index]].Points[myPointIndex[index]].XValue);
                    }
                    secondPoint.Y = firstPoint.Y;

                    // Convert first and second point of horizontal line to absolute co-ordinates
                    firstPoint  = e.ChartGraphics.GetAbsolutePoint(firstPoint);
                    secondPoint = e.ChartGraphics.GetAbsolutePoint(secondPoint);

                    // Draw the first line
                    e.ChartGraphics.Graphics.DrawLine(new Pen(lineColor, myLineThickness), firstPoint, secondPoint);

                    // The first point of the vertical line is the second point of the horizontal line.
                    // The second point of the vertical line is the datapoint itself
                    PointF thirdPoint = new PointF();
                    if (isIndexed)
                    {
                        thirdPoint.X = (float)e.ChartGraphics.GetPositionFromAxis(mySeries[mySeriesAssignment[index]].ChartArea, AxisName.X, myPointIndex[index] + 1);
                    }
                    else
                    {
                        thirdPoint.X = (float)e.ChartGraphics.GetPositionFromAxis(mySeries[mySeriesAssignment[index]].ChartArea, AxisName.X, mySeries[mySeriesAssignment[index]].Points[myPointIndex[index]].XValue);
                    }
                    thirdPoint.Y = (float)e.ChartGraphics.GetPositionFromAxis(mySeries[mySeriesAssignment[index]].ChartArea, myYAxisName, mySeries[mySeriesAssignment[index]].Points[myPointIndex[index]].YValues[0]);

                    // Convert to the third point to absolute co-ordinates
                    thirdPoint = e.ChartGraphics.GetAbsolutePoint(thirdPoint);

                    // Draw the vertical line
                    e.ChartGraphics.Graphics.DrawLine(new Pen(lineColor, myLineThickness), secondPoint, thirdPoint);

                    // Fill the circle
                    Brush myFillBrush = new SolidBrush(mySeries[mySeriesAssignment[index]].Color);
                    e.ChartGraphics.Graphics.FillEllipse(myFillBrush, new RectangleF(thirdPoint.X - myCirclePointRadius, thirdPoint.Y - myCirclePointRadius, myCirclePointRadius * 2, myCirclePointRadius * 2));

                    // Draw the circle
                    e.ChartGraphics.Graphics.DrawEllipse(new Pen(myCircleOutlineColor, myCircleOutlineThickness), thirdPoint.X - myCirclePointRadius, thirdPoint.Y - myCirclePointRadius, myCirclePointRadius * 2, myCirclePointRadius * 2);
                }
                else if (legendCell.Name.IndexOf("ActivityLeftPadding") > -1)
                {
                    // Store the left cell's width incase the legend is right-docked
                    myLeftPadding = e.Position.Width;
                }
            }
        }
        private void BuildLineChart()
        {
            var ca = new ChartArea {
                Name = "Forecasted Fleet Size"
            };

            ca.AxisX.MajorGrid.Enabled   = false;
            ca.AxisX.Interval            = 1;
            ca.AxisY.MajorGrid.Enabled   = true;
            ca.AxisY.MajorGrid.LineColor = Color.LightGray;
            ca.AxisX.MajorGrid.Enabled   = true;
            ca.AxisX.MajorGrid.LineColor = Color.LightGray;
            ca.AxisX.MajorGrid.LineWidth = 1;

            chrtForecastedFleetSize.ChartAreas.Add(ca);

            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType           = ValuesChart ? SeriesChartType.Line : SeriesChartType.Column,
                    Color               = cd.GraphColour,
                    BorderWidth         = 2,
                    XValueType          = ChartValueType.Int32,
                    IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName),
                    ToolTip             = "#SERIESNAME - #VALY{#,0}",
                    LabelFormat         = "#,0"
                };
                if (!ValuesChart)
                {
                    cs["DrawingStyle"] = "Cylinder";
                }

                for (var i = 0; i < cd.Xvalue.Count; i++)
                {
                    cs.Points.AddXY(cd.Xvalue[i], cd.Yvalue[i]);
                }

                chrtForecastedFleetSize.Series.Add(cs);

                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(cd.SeriesName);

                var legendCell2Colour = seriesHidden ? MarsColours.ChartLegendValuesHidden : cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour,
                    Alignment = ContentAlignment.MiddleLeft
                };
                legendItem.Cells.Add(legendCell);

                var valuesShown = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName);

                var legendCell3Colour = !valuesShown || seriesHidden ? MarsColours.ChartLegendValuesHidden : MarsColours.ChartLegendValuesShown;


                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell3Colour,
                    Font          = new Font("Tahoma", 9),
                    Alignment     = ContentAlignment.MiddleRight,
                    PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                chrtForecastedFleetSize.Legends["RightLegend"].CustomItems.Add(legendItem);

                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }

            var slideLegendItem = new LegendItem {
                Name = "SlideButton"
            };
            var slideLegendCell = new LegendCell
            {
                Name          = "Cell4",
                Alignment     = ContentAlignment.TopRight,
                PostBackValue = ShowLegend ? "HideLegend" : "ShowLegend",
                CellType      = LegendCellType.Image,
                Image         = ShowLegend ? "~/App.Images/hideRightIcon.gif" : "~/App.Images/hideLeftIcon.gif",
            };

            slideLegendItem.Cells.Add(slideLegendCell);
            chrtForecastedFleetSize.Legends["SlideLegend"].CustomItems.Add(slideLegendItem);
        }
Esempio n. 11
0
        private void BuildWaterfallChart()
        {
            var ca = new ChartArea {
                Name = "Total Fleet Area"
            };
            var pos = new ElementPosition {
                Width = ShowLegend ? 70 : 90, Height = 90, X = 0, Y = 5
            };



            ca.Position = pos;

            ca.AxisX.MajorGrid.Enabled = false;

            //ca.AxisX.CustomLabels.Add(new CustomLabel());


            ca.AxisX.Interval = 2;
            //ca.AxisX.LabelStyle.Angle = -45;

            ca.AxisY.MajorGrid.Enabled = true;
            var ls = new LabelStyle {
                Format = "#,#"
            };

            ca.AxisY.LabelStyle          = ls;
            ca.AxisY.MajorGrid.LineColor = Color.LightGray;
            //ca.InnerPlotPosition.Width = 55;



            chrtFleetStatus.ChartAreas.Add(ca);
            var totalFleet = 0.0;

            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType         = SeriesChartType.RangeColumn
                    , Color           = cd.GraphColour
                    , XValueType      = ChartValueType.String
                    , YValuesPerPoint = 2
                };
                //cs["DrawSideBySide"] = "false";
                cs["DrawingStyle"] = "Emboss";

                if (TodaysData)
                {
                    cs.PostBackValue = "BarClick/" + cd.SeriesName;
                }

                cs.IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName);
                cs.LabelFormat         = "#,#";
                //cs.Label = cd.SeriesName;
                //cs.LabelAngle = -45;

                cs.ToolTip = "#SERIESNAME #CUSTOMPROPERTY(SIZE)";

                cs.Points.AddXY(cd.SeriesName, cd.Yvalue.Cast <object>().ToArray());
                //cs.Label = string.Format("{0:#,#}", cd.Yvalue[0] - cd.Yvalue[1]);
                //cs.LabelAngle = -45;
                cs.AxisLabel = cd.SeriesName;
                //cs.Points.AddXY(cd.SeriesName, cd.Yvalue[0]);
                var size = cd.Yvalue[0] - cd.Yvalue[1];


                var availTopic = TopicTranslation.GetAvailabilityTopicFromDescription(cd.SeriesName);
                if (availTopic == AvailabilityTopic.TotalFleet)
                {
                    totalFleet = cd.Yvalue[0];
                }

                cs.Points[0]["SIZE"]  = string.Format("{0:#,#}", size);
                cs["PixelPointWidth"] = "400";

                chrtFleetStatus.Series.Add(cs);


                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(cd.SeriesName);

                var legendCell2Colour = cd.GraphColour;//seriesHidden ? MarsColours.ChartLegendValuesHidden : cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour,
                    Alignment = ContentAlignment.MiddleLeft
                };
                legendItem.Cells.Add(legendCell);


                legendCell = new LegendCell
                {
                    Name      = "Cell3",
                    Text      = string.Format("{0:#,0}", size),
                    ForeColor = legendCell2Colour,
                    Font      = new Font("Tahoma", 9),
                    Alignment = ContentAlignment.MiddleRight,
                    //PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };

                legendItem.Cells.Add(legendCell);

                legendCell = new LegendCell
                {
                    Name      = "Cell4",
                    Text      = string.Format("{0:p}", (size / totalFleet)),
                    ForeColor = legendCell2Colour,
                    Font      = new Font("Tahoma", 9),
                    Alignment = ContentAlignment.MiddleRight,
                };

                legendItem.Cells.Add(legendCell);

                chrtFleetStatus.Legends["RightLegend"].CustomItems.Add(legendItem);

                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }

            var slideLegendItem = new LegendItem {
                Name = "SlideButton"
            };
            var slideLegendCell = new LegendCell
            {
                Name          = "Cell4",
                Alignment     = ContentAlignment.TopRight,
                PostBackValue = ShowLegend ? "HideLegend" : "ShowLegend",
                CellType      = LegendCellType.Image,
                Image         = ShowLegend ? "~/App.Images/hideRightIcon.gif" : "~/App.Images/hideLeftIcon.gif",
            };

            slideLegendItem.Cells.Add(slideLegendCell);
            chrtFleetStatus.Legends["SlideLegend"].CustomItems.Add(slideLegendItem);
        }
Esempio n. 12
0
        private void BuildColumnChart()
        {
            var ca = new ChartArea {
                Name = "Comparison Chart"
            };

            ca.AxisX.MajorGrid.Enabled = false;
            ca.AxisX.Interval          = 1;
            ca.AxisX.IntervalType      = DateTimeIntervalType.Days;

            ca.AxisY.MajorGrid.Enabled   = true;
            ca.AxisY.MajorGrid.LineColor = Color.LightGray;

            var percentTypeSelected = (PercentageDivisorType)Enum.Parse(typeof(PercentageDivisorType), hfPercentageValues.Value);

            //bool.Parse(hfPercentageCalculation.Value);


            chrtComparison.ChartAreas.Add(ca);
            chrtComparison.ChartAreas[0].AxisX.LabelStyle.Angle  = -45;
            chrtComparison.ChartAreas[0].AxisY.LabelStyle.Format =
                percentTypeSelected == PercentageDivisorType.Values ? "#,0" : "P";


            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType  = SeriesChartType.Column,
                    Color      = cd.GraphColour,
                    XValueType = ChartValueType.Date,

                    IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName),
                    ToolTip             = "#SERIESNAME - #VALY{" + (percentTypeSelected == PercentageDivisorType.Values ? "#,0" : "P") + "}",
                    LabelFormat         = percentTypeSelected == PercentageDivisorType.Values ? "#,0" : "P"
                };
                cs["DrawingStyle"] = "Emboss";          //LightToDark, Cylinder, Emboss, Wedge
                cs["LabelStyle"]   = "Top";
                for (var i = 0; i < cd.Xvalue.Count; i++)
                {
                    cs.Points.AddXY(cd.Xvalue[i], cd.Yvalue[i]);
                }



                chrtComparison.Series.Add(cs);


                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var legendCell2Colour = cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour,
                    Alignment = ContentAlignment.MiddleLeft
                };
                legendItem.Cells.Add(legendCell);


                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell2Colour,
                    Font          = new Font("Tahoma", 9),
                    Alignment     = ContentAlignment.MiddleRight,
                    PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                chrtComparison.Legends["RightLegend"].CustomItems.Add(legendItem);
                //


                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }

            var slideLegendItem = new LegendItem {
                Name = "SlideButton"
            };
            var slideLegendCell = new LegendCell
            {
                Name          = "Cell4",
                Alignment     = ContentAlignment.TopRight,
                PostBackValue = ShowLegend ? "HideLegend" : "ShowLegend",
                CellType      = LegendCellType.Image,
                Image         = ShowLegend ? "~/App.Images/hideRightIcon.gif" : "~/App.Images/hideLeftIcon.gif",
            };

            slideLegendItem.Cells.Add(slideLegendCell);
            chrtComparison.Legends["SlideLegend"].CustomItems.Add(slideLegendItem);
        }
Esempio n. 13
0
        public MainForm()
        {
            InitializeComponent();

            fileSystemWatcher1.EnableRaisingEvents = false;

            // For convenience.
            charts.Add(HeatersChart);
            charts.Add(RFChart);
            charts.Add(CavityChart);
            charts.Add(PowerInputChart);
            charts.Add(PowerSuppliesChart);
            charts.Add(HydrogenChart);
            charts.Add(IonPumpsChart);
            charts.Add(PllChart);
            charts.Add(TemperatureChart);

            foreach (Chart c in charts)
            {
                //c.ChartAreas[0].CursorX.LineColor = Color.Red;
                c.ChartAreas[0].CursorX.SelectionColor         = Color.Red;
                c.ChartAreas[0].CursorX.IsUserEnabled          = true;
                c.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                c.ChartAreas[0].CursorX.IntervalType           = DateTimeIntervalType.Hours;
                c.ChartAreas[0].AxisX.ScaleView.Zoomable       = false;

                c.SelectionRangeChanged += C_SelectionRangeChanged;

                for (int i = 0; i < c.Series.Count; i++)
                {
                    c.Series[i].Color = palette[i];
                    // Below - test
                    c.Series[i].IsVisibleInLegend = false;

                    LegendItem l = new LegendItem(c.Series[i].Name, c.Series[i].Color, "");
                    l.Cells.Add(new LegendCell(LegendCellType.SeriesSymbol, ""));
                    LegendCell lc = new LegendCell(LegendCellType.Text, c.Series[i].Name);
                    lc.Font = c.Legends[0].Font;
                    l.Cells.Add(lc);

                    l.ImageStyle = LegendImageStyle.Line;
                    c.Legends[0].CustomItems.Add(l);
                }
            }

            statusLabel.Text = string.Format("Updated {0}", DateTime.UtcNow.ToLongTimeString());

            var     parser  = new FileIniDataParser();
            IniData iniData = parser.ReadFile("EFOS.ini");

            plotPath            = iniData["EfosView"]["plot-path"];
            logPath             = iniData["EfosMon"]["data-path"];
            logfilePrefix       = iniData["EfosMon"]["filename-prefix"];
            exportPlots         = bool.Parse(iniData["EfosView"]["export-plots"]);
            exportHistoricPlots = bool.Parse(iniData["EfosView"]["export-historic-plots"]);

            d           = new DataLoader(logPath);
            d.filenames = String.Format("{0} 20*.csv", logfilePrefix);

            // Run exportcharts in the background
            //if (exportPlots) {
            //    Task.Run(() => ExportCharts());

            //    // Wait untill ExportCharts has copied the charts
            //    doneCopyingCharts.WaitOne();
            //}

            var data = GetData(DateTime.UtcNow.AddHours(-span), DateTime.UtcNow, true);

            BindData(data, true);

            fileSystemWatcher1.Path   = logPath;
            fileSystemWatcher1.Filter = d.filenames;
            fileSystemWatcher1.EnableRaisingEvents = true;
        }
Esempio n. 14
0
        protected void GenerateChart(System.Data.DataTable dataValues, int dateRangeValue, string logic)
        {
            int rowCount = dataValues.Rows.Count;

            if (rowCount >= 1)
            {
                this.AvailibilityChartHistoricalTrend.Visible = true;
                this.EmptyDataTemplateHistoricalTrend.Visible = false;
            }
            else
            {
                this.EmptyDataTemplateHistoricalTrend.Visible = true;
                this.AvailibilityChartHistoricalTrend.Visible = false;
            }
            Dundas.Charting.WebControl.Chart ChartHistoricalTrend = (Dundas.Charting.WebControl.Chart) this.AvailibilityChartHistoricalTrend.FindControl("DundasChartAvailability");
            ChartHistoricalTrend.Series.Clear();
            ChartHistoricalTrend.Legends.Clear();
            ChartHistoricalTrend.Legends.Add("Default");
            ChartHistoricalTrend.Legends["Default"].LegendStyle = LegendStyle.Column;
            ChartHistoricalTrend.Visible = true;

            //reset chart title
            ChartHistoricalTrend.Titles.Clear();
            Dundas.Charting.WebControl.Title ctitle = new Dundas.Charting.WebControl.Title();
            ctitle.Text      = Resources.lang.HistoricalTrend;
            ctitle.Font      = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold);
            ctitle.Alignment = System.Drawing.ContentAlignment.TopLeft;
            ChartHistoricalTrend.Titles.Add(ctitle);

            //Add a item to reset zoom
            Dundas.Charting.WebControl.Title resetZoomTitle = new Dundas.Charting.WebControl.Title();
            resetZoomTitle.Font              = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold);
            resetZoomTitle.Alignment         = System.Drawing.ContentAlignment.BottomRight;
            resetZoomTitle.Docking           = Docking.Bottom;
            resetZoomTitle.ToolTip           = Resources.lang.ChartZoomFeature;
            resetZoomTitle.DockOffset        = 1;
            resetZoomTitle.MapAreaAttributes = "onclick=\"" + ChartHistoricalTrend.CallbackManager.GetCallbackEventReference("ResetZoom", "ResetZoom") + "\"";
            resetZoomTitle.Text              = Resources.lang.ChartZoomText;
            resetZoomTitle.BackImage         = "~/App.Images/reset_zoom.png";
            resetZoomTitle.BackImageMode     = ChartImageWrapMode.Unscaled;
            resetZoomTitle.BackImageAlign    = ChartImageAlign.BottomRight;
            ChartHistoricalTrend.Titles.Add(resetZoomTitle);

            //Declare chart series
            // remove carsales, gold and predelivery from the dataview
            Series series1 = ChartHistoricalTrend.Series.Add("TOTAL FLEET");
            //Series series2 = ChartHistoricalTrend.Series.Add("CARSALES"); // removed to protect the innocent
            Series series3  = ChartHistoricalTrend.Series.Add("CU");
            Series series4  = ChartHistoricalTrend.Series.Add("HA");
            Series series5  = ChartHistoricalTrend.Series.Add("HL");
            Series series6  = ChartHistoricalTrend.Series.Add("LL");
            Series series7  = ChartHistoricalTrend.Series.Add("NC");
            Series series8  = ChartHistoricalTrend.Series.Add("PL");
            Series series9  = ChartHistoricalTrend.Series.Add("TC");
            Series series10 = ChartHistoricalTrend.Series.Add("SV");
            Series series11 = ChartHistoricalTrend.Series.Add("WS");
            Series series12 = ChartHistoricalTrend.Series.Add("OPERATIONAL FLEET");
            Series series13 = ChartHistoricalTrend.Series.Add("BD");
            Series series14 = ChartHistoricalTrend.Series.Add("MM");
            Series series15 = ChartHistoricalTrend.Series.Add("TW");
            Series series16 = ChartHistoricalTrend.Series.Add("TB");
            Series series17 = ChartHistoricalTrend.Series.Add("FS");
            Series series18 = ChartHistoricalTrend.Series.Add("RL");
            Series series19 = ChartHistoricalTrend.Series.Add("RP");
            Series series20 = ChartHistoricalTrend.Series.Add("TN");
            Series series21 = ChartHistoricalTrend.Series.Add("AVAILABLE FLEET");
            Series series22 = ChartHistoricalTrend.Series.Add("RT");
            Series series23 = ChartHistoricalTrend.Series.Add("SU");
            //Series series24 = ChartHistoricalTrend.Series.Add("GOLD");
            //Series series25 = ChartHistoricalTrend.Series.Add("PREDELIVERY");
            Series series26 = ChartHistoricalTrend.Series.Add("OVERDUE");
            Series series27 = ChartHistoricalTrend.Series.Add("ON RENT");

            string xAxisValue = "REP_DATE"; // set to default

            if (dateRangeValue < -30 && dateRangeValue >= -90)
            {
                xAxisValue = "REP_WEEK_OF_YEAR";
            }
            if (dateRangeValue < -90)
            {
                xAxisValue = "REP_MONTH";
            }

            // Initializes a new instance of the DataView class
            System.Data.DataView firstView = new System.Data.DataView(dataValues);

            // Since the DataView implements IEnumerable, pass the reader directly into
            // the DataBind method with the name of the Columns selected in the query
            //Set series properties
            int index = 0;

            foreach (Series chartSeries in ChartHistoricalTrend.Series)
            {
                chartSeries.Points.DataBindXY(firstView, xAxisValue, firstView, chartSeries.Name.Replace(" ", "_"));
                if (logic == "PERCENTAGE")
                {
                    foreach (DataPoint p in chartSeries.Points)
                    {
                        //p.YValues[0] = Math.Round(p.YValues[0], 2);
                        p.LabelFormat = "P";
                    }
                }

                chartSeries.Color = Charts.GetColourForColumn(chartSeries.Name, (int)ReportSettings.ReportSettingsTool.Availability);
                switch (chartSeries.Name)
                {
                case "AVAILABLE FLEET":
                case "RT":
                case "SU":
                //case "GOLD":
                //case "PREDELIVERY":
                case "OVERDUE":
                case "ON RENT":
                    chartSeries.Enabled = true;
                    break;

                default:
                    chartSeries.Enabled = false;
                    break;
                }

                // Set range column chart type
                chartSeries.Type = SeriesChartType.Line;

                //Set series tooltip
                chartSeries.ToolTip = "#VALX: #VAL, #SERIESNAME";

                // Set the side-by-side drawing style
                chartSeries["DrawSideBySide"] = "false";

                chartSeries.BorderWidth = 2;


                //Set x value type
                if (xAxisValue == "REP_DATE")
                {
                    chartSeries.XValueType = ChartValueTypes.DateTime;
                }
                else
                {
                    chartSeries.XValueType = ChartValueTypes.Int;
                }

                chartSeries.Color = Charts.GetColourForColumn(chartSeries.Name, (int)ReportSettings.ReportSettingsTool.Availability);

                chartSeries.ShowInLegend = false;
                // Add custom legend item with image
                LegendItem legendItem  = new LegendItem();
                LegendCell legendCell1 = new LegendCell();
                LegendCell legendCell2 = new LegendCell();

                legendItem.BackImageTranspColor = System.Drawing.Color.Red;
                legendCell1.CellType            = LegendCellType.Image;
                if (chartSeries.Enabled == true)
                {
                    legendCell1.Image = "~/App.Images/chk_checked.png";
                }
                else
                {
                    legendCell1.Image = "~/App.Images/chk_unchecked.png";
                }
                legendCell1.ImageTranspColor = System.Drawing.Color.Red;
                legendCell2.CellType         = LegendCellType.Text;
                legendCell2.Font             = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Regular);
                legendCell2.Text             = chartSeries.Name;
                legendCell2.TextColor        = chartSeries.Color;
                legendItem.Cells.Add(legendCell1);
                legendItem.Cells.Add(legendCell2);
                legendItem.MapAreaAttributes = "onclick=\"" + ChartHistoricalTrend.CallbackManager.GetCallbackEventReference("LegendClick", index.ToString()) + "\"";

                legendItem.BorderWidth = 0;
                ChartHistoricalTrend.Legends["Default"].CustomItems.Add(legendItem);
                index += 1;
            }

            var yLabelStyle = string.Empty;

            switch (logic)
            {
            case "PERCENTAGE":
                yLabelStyle = "P";
                break;

            case "NUMERIC":
                yLabelStyle = "D";
                break;

            default:
                yLabelStyle = "P0";
                break;
            }
            ChartHistoricalTrend.ChartAreas["Default"].AxisY.LabelStyle.Format = yLabelStyle;



            //Set X Axis style
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.LabelsAutoFit        = false;
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.LabelStyle.Font      = new System.Drawing.Font("Arial", 7, System.Drawing.FontStyle.Bold);
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.LineColor            = System.Drawing.Color.FromArgb(64, 64, 64, 64);
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.Interlaced           = false;
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.MajorGrid.LineColor  = System.Drawing.Color.FromArgb(64, 64, 64, 64);
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.LabelStyle.FontAngle = -45;

            ChartHistoricalTrend.ChartAreas["Default"].AxisY.LabelStyle.Font     = new System.Drawing.Font("Arial", 7, System.Drawing.FontStyle.Bold);
            ChartHistoricalTrend.ChartAreas["Default"].AxisY.LineColor           = System.Drawing.Color.Gray;
            ChartHistoricalTrend.ChartAreas["Default"].AxisY.Interlaced          = true;
            ChartHistoricalTrend.ChartAreas["Default"].AxisY.InterlacedColor     = System.Drawing.Color.FromArgb(20, 20, 20, 20);
            ChartHistoricalTrend.ChartAreas["Default"].AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(64, 64, 64, 64);

            //Disable Variable Label Intervals - force showing every X Value
            ChartHistoricalTrend.ChartAreas["Default"].AxisX.Interval = 1;

            // Enable AntiAliasing for either Text and Graphics or just Graphics
            ChartHistoricalTrend.AntiAliasing = AntiAliasing.All;
        }
        private void BuildLineChart()
        {
            var ca = new ChartArea {
                Name = "Historical Trend"
            };

            ca.AxisX.MajorGrid.Enabled = false;
            //ca.AxisX.Interval = 1;
            ca.AxisX.IntervalType = HourlySeries ? DateTimeIntervalType.Hours : DateTimeIntervalType.Days;

            //ca.AxisX.LabelStyle.Enabled = true;
            //ca.AxisX.IsLabelAutoFit = true;
            //ca.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;

            ca.AxisY.MajorGrid.Enabled   = true;
            ca.AxisY.MajorGrid.LineColor = Color.LightGray;

            ca.AxisX.MajorGrid.Enabled   = true;
            ca.AxisX.MajorGrid.LineColor = Color.LightGray;
            ca.AxisX.MajorGrid.LineWidth = 1;


            var percentageValueSelected = (PercentageDivisorType)Enum.Parse(typeof(PercentageDivisorType), hfPercentageValues.Value);


            chrtHistoricalTrend.ChartAreas.Add(ca);
            chrtHistoricalTrend.ChartAreas[0].AxisX.LabelStyle.Angle  = -45;
            chrtHistoricalTrend.ChartAreas[0].AxisX.LabelStyle.Format = HourlySeries ? "HH:mm:00" : "dd/MM/yyyy";
            chrtHistoricalTrend.ChartAreas[0].AxisY.LabelStyle.Format =
                percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P";


            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType           = SeriesChartType.Line,
                    Color               = cd.GraphColour,
                    BorderWidth         = 2,
                    XValueType          = ChartValueType.DateTime,
                    IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName),
                    ToolTip             = "#SERIESNAME - #VALX{dd/MM/yyyy" + (HourlySeries ? " HH:mm:00" : string.Empty) +
                                          "} - #VALY{" + (percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P") + "}",
                    LabelFormat = percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P"
                };

                for (var i = 0; i < cd.Xvalue.Count; i++)
                {
                    cs.Points.AddXY(cd.Xvalue[i], cd.Yvalue[i]);
                }



                chrtHistoricalTrend.Series.Add(cs);


                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(cd.SeriesName);

                var legendCell2Colour = seriesHidden ? MarsColours.ChartLegendValuesHidden : cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour,
                    Alignment = ContentAlignment.MiddleLeft
                };
                legendItem.Cells.Add(legendCell);


                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell2Colour,
                    Font          = new Font("Tahoma", 9),
                    Alignment     = ContentAlignment.MiddleRight,
                    PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                chrtHistoricalTrend.Legends["RightLegend"].CustomItems.Add(legendItem);
                //


                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }

            var slideLegendItem = new LegendItem {
                Name = "SlideButton"
            };
            var slideLegendCell = new LegendCell
            {
                Name          = "Cell4",
                Alignment     = ContentAlignment.TopRight,
                PostBackValue = ShowLegend ? "HideLegend" : "ShowLegend",
                CellType      = LegendCellType.Image,
                Image         = ShowLegend ? "~/App.Images/hideRightIcon.gif" : "~/App.Images/hideLeftIcon.gif",
            };

            slideLegendItem.Cells.Add(slideLegendCell);
            chrtHistoricalTrend.Legends["SlideLegend"].CustomItems.Add(slideLegendItem);
        }