Exemplo n.º 1
0
        private void UpdateNormal(double[] ds, Color[] cs)
        {
            GaugeLayer theLayer = null;

            if (MyChart.Layer.Contains("GaugeLayer"))
            {
                theLayer = _mychart.Layer["GaugeLayer"] as GaugeLayer;
            }
            else
            {
                theLayer            = new GaugeLayer();
                theLayer.Appearance = new GaugeAppearance();

                theLayer.Appearance.Radius = 300;
                //theLayer.Appearance.Center = new Point(190, 190);

                //theLayer.Appearance.DialPE.Stroke = Color.Black;
                //theLayer.Appearance.DialPE.StrokeWidth = 5;

                theLayer.ChartComponent = MyChart;

                _mychart.Layer.Add("GaugeLayer", theLayer);
                _mychart.UserLayerIndex = new string[] { "GaugeLayer" };

                // Set axes
                _mychart.ChartType      = ChartType.PieChart;
                _mychart.Legend.Visible = false;

                _mychart.Axis.Y.Labels.ItemFormatString  = "<DATA_VALUE:0>";
                _mychart.Axis.Y.MajorGridLines.Thickness = 5;
                _mychart.Axis.Y.MinorGridLines.Thickness = 2;
                _mychart.Axis.Y.MajorGridLines.DrawStyle = LineDrawStyle.Solid;
                _mychart.Axis.Y.MinorGridLines.DrawStyle = LineDrawStyle.Solid;

                // Set data source (this is meaningless to the gauge layer)
                _mychart.Data.DataSource = Infragistics.UltraChart.Data.DemoTable.Table();
                _mychart.Data.DataBind();
                //this.ultraChart1.BackgroundImage = System.Drawing.Image.FromFile(Config.ImagePath + @"\chart_gray_bg.jpg");
            }

            #region sections & needle
            theLayer.Appearance.Sections.Clear();
            theLayer.Appearance.Needles.Clear();
            GaugeSection section = null;

            _invalidcode = 0;
            double maxtick = _maxtick;
            if (!double.IsNaN(ds[0]))
            {
                if (ds[0] < 0)
                {
                    _invalidcode = 1;
                }
                maxtick = Math.Max(maxtick, ds[0]);
            }
            if (!double.IsNaN(ds[1]))
            {
                if (ds[1] < 0)
                {
                    _invalidcode = 1;
                }
                maxtick = Math.Max(maxtick, ds[1]);
            }
            if (!double.IsNaN(ds[2]))
            {
                if (ds[2] < 0)
                {
                    _invalidcode = 2;
                }
                maxtick = Math.Max(maxtick, ds[2]);
            }
            if (!double.Equals(maxtick, 100.0))
            {
                long mt = Convert.ToInt64(Math.Ceiling(maxtick));
                if (mt % 100 == 0)
                {
                    if (mt < 100)
                    {
                        maxtick = 100;
                    }
                    else
                    {
                        maxtick = Convert.ToDouble((mt / 100) * 100);
                    }
                }
                else
                {
                    maxtick = Convert.ToDouble((mt / 100 + 1) * 100);
                }
            }

            if (!double.IsNaN(ds[0]))
            {
                if (!double.IsNaN(ds[1]))
                {
                    section                      = new GaugeSection(ds[0] - _mintick);
                    section.StartWidth           = _sectionstart;
                    section.EndWidth             = _sectionend;
                    section.PE.ElementType       = PaintElementType.SolidFill; //.Gradient;
                    section.PE.FillGradientStyle = GradientStyle.Horizontal;
                    section.PE.Fill              = cs[0];                      //Color.Green;
                    //section.PE.FillStopColor = Color.Yellow;
                    theLayer.Appearance.Sections.Add(section);

                    section                      = new GaugeSection(ds[1] - ds[0]);
                    section.StartWidth           = _sectionstart;
                    section.EndWidth             = _sectionend;
                    section.PE.ElementType       = PaintElementType.SolidFill; //.Gradient;
                    section.PE.FillGradientStyle = GradientStyle.Horizontal;
                    section.PE.Fill              = cs[1];                      //Color.Green;
                    //section.PE.FillStopColor = Color.Yellow;
                    theLayer.Appearance.Sections.Add(section);

                    section                      = new GaugeSection(maxtick - ds[1]);
                    section.StartWidth           = _sectionstart;
                    section.EndWidth             = _sectionend;
                    section.PE.ElementType       = PaintElementType.SolidFill; //.Gradient;
                    section.PE.FillGradientStyle = GradientStyle.Horizontal;
                    section.PE.Fill              = cs[2];                      //Color.Green;
                    //section.PE.FillStopColor = Color.Yellow;
                    theLayer.Appearance.Sections.Add(section);
                }
                else
                {
                    section                      = new GaugeSection(ds[0] - _mintick);
                    section.StartWidth           = _sectionstart;
                    section.EndWidth             = _sectionend;
                    section.PE.ElementType       = PaintElementType.SolidFill; //.Gradient;
                    section.PE.FillGradientStyle = GradientStyle.Horizontal;
                    section.PE.Fill              = cs[0];                      //Color.Green;
                    //section.PE.FillStopColor = Color.Yellow;
                    theLayer.Appearance.Sections.Add(section);

                    section                      = new GaugeSection(maxtick - ds[0]);
                    section.StartWidth           = _sectionstart;
                    section.EndWidth             = _sectionend;
                    section.PE.ElementType       = PaintElementType.SolidFill; //.Gradient;
                    section.PE.FillGradientStyle = GradientStyle.Horizontal;
                    section.PE.Fill              = cs[2];                      //Color.Green;
                    //section.PE.FillStopColor = Color.Yellow;
                    theLayer.Appearance.Sections.Add(section);
                }
            }
            else
            {
                section                      = new GaugeSection(maxtick - _mintick);
                section.StartWidth           = 1;
                section.EndWidth             = 2;
                section.PE.ElementType       = PaintElementType.SolidFill;//.Gradient;
                section.PE.FillGradientStyle = GradientStyle.Horizontal;
                section.PE.Fill              = _gaugecolor;
                theLayer.Appearance.Sections.Add(section);
            }

            if (!double.IsNaN(ds[2]))
            {
                Needle nv = new Needle(ds[2], new PaintElement(_needlecolor));
                nv.PE.StrokeWidth = 12;
                nv.Length         = _needlelength;
                theLayer.Appearance.Needles.Add(nv);
            }
            #endregion

            theLayer.Appearance.StartAngle = _bsemicircle ? 0 : -45;
            theLayer.Appearance.EndAngle   = _bsemicircle ? 180 : 225;
            theLayer.Appearance.TextLoc    = _textloc;
            theLayer.Appearance.TickStart  = _tickstart;
            theLayer.Appearance.TickEnd    = _tickend;

            _mychart.Axis.Y.Visible                = true;
            _mychart.Axis.Y.Labels.Visible         = true;
            _mychart.Axis.Y.MajorGridLines.Visible = true;
            _mychart.Axis.Y.MinorGridLines.Visible = true;

            _mychart.Axis.Y.MajorGridLines.Color = _tickcolor;
            _mychart.Axis.Y.MinorGridLines.Color = _tickcolor;
            _mychart.Axis.Y.Labels.FontColor     = _fontcolor;
            _mychart.Axis.Y.LineColor            = _linecolor;

            if (_gaugetype == GaugeType.Blue3D)
            {
                theLayer.Appearance.DialPE = new PaintElement(String4Report.GetImage("Template0.gif"));
            }
            else
            {
                theLayer.Appearance.DialPE = new PaintElement(_gaugecolor);
            }
            //theLayer.Appearance.DialPE = new PaintElement(Color.WhiteSmoke, Color.CornflowerBlue, GradientStyle.Elliptical);

            //if (_caption != null)
            //{
            //    _mychart.TitleBottom.Text = _caption;
            //    _mychart.TitleBottom.FontSizeBestFit = true;
            //    _mychart.TitleBottom.HorizontalAlign = StringAlignment.Center;
            //}
            _mychart.InvalidateLayers();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Determines whether the GaugeSectionCollection contains a specific GaugeSection.
 /// </summary>
 /// <param name="value">A GaugeSection</param>
 /// <returns>true if the GaugeSectionCollection contains the specified GaugeSection; otherwise, false.</returns>
 public bool Contains(GaugeSection value)
 {
     // If value is not of type GaugeSection, this will return false.
     return(List.Contains(value));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Removes the first occurrence of a specific GaugeSection from the GaugeSection Collection.
 /// </summary>
 /// <param name="value">A GaugeSection</param>
 public void Remove(GaugeSection value)
 {
     List.Remove(value);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inserts an element into the GaugeSection Collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The GaugeSection to insert.</param>
 public void Insert(int index, GaugeSection value)
 {
     List.Insert(index, value);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Searches for the specified GaugeSection and returns the zero-based index of the first occurrence within the entire GaugeSectionCollection.
 /// </summary>
 /// <param name="value">GaugeSection to search</param>
 /// <returns>The zero-based index of the first occurrence of given GaugeSection within the entire GaugeSection Collection, if found; otherwise, -1</returns>
 public int IndexOf(GaugeSection value)
 {
     return(List.IndexOf(value));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds an GaugeSection to the end of the GaugeSection Collection.
 /// </summary>
 /// <param name="value">A GaugeSection</param>
 /// <returns>The GaugeSection Collection index at which the value has been added.</returns>
 public int Add(GaugeSection value)
 {
     return(List.Add(value));
 }