2014-06-05 1 views
0

J'ai 2 séries de barres dans un tableau de départ. L'un est un pourcentage entre 0 et 100 et utilise l'axe de gauche. L'autre est une température, utilise l'axe droit, et la plage des valeurs possibles est comprise entre -40F et 160F.Définir l'axe minumum comme un nombre négatif, mais avoir une barre qui descend vers l'origine au lieu de zéro

Je voudrais que les deux barres commencent à l'axe du bas. Je pensais que les propriétés UseOrigin et Origin de la série le feraient mais apparemment cela ne fonctionne pas.

Ci-dessous est mon code:

 chartTank = new TChart(); 
     chartTank.Axes.Left.Grid.Visible = false; 
     chartTank.Axes.Right.Grid.Visible = false; 
     chartTank.Axes.Right.Maximum = 160.0; 
     chartTank.Axes.Right.Minimum = -40; 
     chartTank.Axes.Right.Increment = 40; 

     chartTank.Axes.Right.Automatic = false; 
     chartTank.Axes.Right.AutomaticMinimum = false; 
     chartTank.Axes.Right.AutomaticMaximum = false; 

     chartTank.Aspect.View3D = false; 
     chartTank.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None; 
     chartTank.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None; 
     chartTank.Axes.Left.Grid.Visible = false; 
     chartTank.Axes.Bottom.GridCentered = false; 
     chartTank.Axes.Bottom.Ticks.Visible = false; 
     chartTank.Axes.Left.Automatic = false; 
     chartTank.Axes.Left.Minimum = 0; 
     chartTank.Axes.Left.Maximum = 100; 
     chartTank.Axes.Right.Visible = true; 


     var barProduct = new Steema.TeeChart.Styles.Bar(); 
     barProduct.MultiBar = MultiBars.Stacked; 
     barProduct.Color = Color.Green; 

     barProduct.Marks.Visible = false; 
     barProduct.Title = "% Vol"; 
     barProduct.ShowInLegend = true; 
     chartTank.Series.Add(barProduct); 


     var barTemperature = new Steema.TeeChart.Styles.Bar(); 
     barTemperature.MultiBar = MultiBars.None; 
     barTemperature.Color = Color.FromArgb(153, 74, 11); 

     barTemperature.Marks.Visible = false; 
     barTemperature.VertAxis = VerticalAxis.Right; 
     barTemperature.UseOrigin = true; 
     barTemperature.Origin = -40; 
     barTemperature.Title = "Temperature"; 
     barTemperature.ShowInLegend = true; 
     chartTank.Series.Add(barTemperature); 

     Controls.Add(chartTank); 

Voici le résultat: enter image description here

J'utilise TeeChart 2014 4.1 pour le fonctionnement .NET sur Windows CE 6.0

Répondre

2

Le code suivant:

private void InitializeChart() 
{ 
    tChart1.Axes.Right.Grid.Visible = false; 
    tChart1.Axes.Right.Maximum = 160.0; 
    tChart1.Axes.Right.Minimum = -40; 
    tChart1.Axes.Right.Increment = 40; 

    tChart1.Axes.Right.Automatic = false; 
    tChart1.Axes.Right.AutomaticMinimum = false; 
    tChart1.Axes.Right.AutomaticMaximum = false; 

    tChart1.Aspect.View3D = false; 
    tChart1.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None; 
    tChart1.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None; 
    tChart1.Axes.Left.Grid.Visible = false; 
    tChart1.Axes.Bottom.Grid.Centered = false; 
    tChart1.Axes.Bottom.Ticks.Visible = false; 
    tChart1.Axes.Left.Automatic = false; 
    tChart1.Axes.Left.Minimum = 0; 
    tChart1.Axes.Left.Maximum = 100; 
    tChart1.Axes.Right.Visible = true; 


    var barProduct = new Steema.TeeChart.Styles.Bar(); 
    barProduct.MultiBar = MultiBars.Side; 
    barProduct.Color = Color.Green; 

    barProduct.Marks.Visible = false; 
    barProduct.Title = "% Vol"; 
    barProduct.ShowInLegend = true; 

    Random rnd = new Random(); 

    for (int i = 0; i < 10; i++) 
    { 
    barProduct.Add(rnd.Next(0, 100)); 
    } 

    tChart1.Series.Add(barProduct); 

    var barTemperature = new Steema.TeeChart.Styles.Bar(); 
    barTemperature.MultiBar = MultiBars.Side; 
    barTemperature.Color = Color.FromArgb(153, 74, 11); 

    barTemperature.Marks.Visible = false; 
    barTemperature.VertAxis = VerticalAxis.Right; 
    barTemperature.UseOrigin = true; 
    barTemperature.Origin = -40; 
    barTemperature.Title = "Temperature"; 
    barTemperature.ShowInLegend = true; 
    for (int i = 0; i < 10; i++) 
    { 
    barTemperature.Add(rnd.Next(-40, 160)); 
    } 
    tChart1.Series.Add(barTemperature); 

    tChart1.Panel.Gradient.Visible = false; 
    tChart1.Walls.Back.Gradient.Visible = false; 
    tChart1.Panel.Color = Color.White; 
    tChart1.Walls.Back.Color = Color.White; 
} 

me donne le caractère suivant t:

enter image description here

obtenez-vous les mêmes résultats à votre fin?

Questions connexes