Pergunta

I am using TreeChart to make an indicator as shown in the picture. But I have a problem I can not make the three-color gradient to that gauge. This is my code

        Steema.TeeChart.TChart tChart = new Steema.TeeChart.TChart(this);
        tChart.Panel.Transparent = false;
        Steema.TeeChart.Styles.Gauges gauges = new Steema.TeeChart.Styles.Gauges(tChart.Chart);
        Steema.TeeChart.Drawing.Gradient g = new Steema.TeeChart.Drawing.Gradient(gauges.Chart);


        gauges.bBrush.Gradient.Direction = Steema.TeeChart.Drawing.GradientDirection.DiagonalUp;
        gauges.bBrush.Gradient.StartColor = System.Drawing.Color.Red;
        gauges.bBrush.Gradient.MiddleColor = System.Drawing.Color.Black;
        gauges.bBrush.Gradient.EndColor = System.Drawing.Color.Blue;
        gauges.bBrush.Gradient.Visible = true;
        gauges.Pen.Color = System.Drawing.Color.FromArgb(5,56,73);

        gauges.TotalAngle = 180; // circular arc  
        gauges.RotationAngle = 180; // arc rotation angle  
        gauges.HandStyle = Steema.TeeChart.Styles.HandStyle.Triangle; // pointer style  
        gauges.Center.Style = Steema.TeeChart.Styles.PointerStyles.Circle; // SPHERE center circle style  
        gauges.Center.HorizSize = 5; // center circle level size  
        gauges.Center.VertSize = 5; // center circle vertical size 

        gauges.ShowInLegend = false; // display the legend  
        gauges.HandDistance = 23; // pointer length  

        //---------------------------------------------------
        gauges.Value = 80;
        gauges.Minimum = 0; //   minimum;
        gauges.Maximum = 100; // maximum value  
        //----------------------------------------------------

        gauges.MinorTickDistance = 0;

        gauges.Pen.DashWidth = 23;
        gauges.Chart.Axes.Left.AxisPen.Width = 65; //   brush width; 
        gauges.Chart.Axes.Left.AxisPen.Color = System.Drawing.Color.Red;
        gauges.Chart.Axes.Left.MinorTickCount = 5; // the scale value scale line number  
        gauges.Chart.Axes.Left.MinorTicks.Length = 10; // the scale value scale line length of  
        gauges.Chart.Axes.Left.Ticks.Length = 20; // display the value scale line length of  
        gauges.Chart.Axes.Left.Increment = 3000; // the scale value of interval size

        SetContentView(tChart) ;

I also tried the following lines of code

        gauges.CircleGradient.Direction = Steema.TeeChart.Drawing.GradientDirection.DiagonalUp;
        gauges.CircleGradient.Visible = true;
        gauges.CircleGradient.StartColor = System.Drawing.Color.Green;
        gauges.CircleGradient.EndColor = System.Drawing.Color.Red;
        gauges.CircleGradient.UseStandardGradient = true;

I hope I help

regards

Foi útil?

Solução

You should use Steema.TeeChart.Styles.CircularGauge instead of Steema.TeeChart.Styles.Gauges which is a much simpler gauge version. For example, using the code snippet below, you get a similar gauge to the image in your link:

Circular gauge with TeeChart

Is this similar to what you are looking for?

  tChart1.Header.Visible = false;

  Steema.TeeChart.Styles.CircularGauge circularGauge1 = new Steema.TeeChart.Styles.CircularGauge(tChart1.Chart);

  circularGauge1.Frame.Visible = false;
  circularGauge1.FaceBrush.Visible = false;
  circularGauge1.DisplayTotalAngle = 180;
  circularGauge1.TotalAngle = 180;
  circularGauge1.Value = 200;
  circularGauge1.Ticks.Visible = false;
  circularGauge1.Minimum = 0;
  circularGauge1.Maximum = 1000;
  circularGauge1.Axis.AxisPen.Visible = false;
  circularGauge1.Axis.Increment = 500;
  circularGauge1.RedLine.Visible = false;
  circularGauge1.GreenLineStartValue = 0;
  circularGauge1.GreenLineEndValue = 1000;
  circularGauge1.GreenLine.Gradient.Direction = Steema.TeeChart.Drawing.GradientDirection.LeftRight;
  circularGauge1.GreenLine.Gradient.UseMiddle = true;
  circularGauge1.GreenLine.Gradient.StartColor = Color.Orange;
  circularGauge1.GreenLine.Gradient.MiddleColor = Color.Yellow;
  circularGauge1.GreenLine.Gradient.EndColor = Color.Green;
  circularGauge1.GreenLine.Pen.Visible = false;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top