我正在尝试为甘特图创建水平堆叠的条形图,但是轴是反向的。

我写的代码如下:

a[0] = 0;
a[1] = 6;
a[2] = 7;
a[3] = 7;

b[0] = 6;
b[1] = 0;
b[2] = 11;
b[3] = 0;

c[0] = 0;
c[1] = 6;
c[2] = 0;
c[3] = 19;


string[] labels = new string[] { "A1", "A2", "B1" , "B2" };

GraphPane _p = zedGraphControl1.GraphPane;

BarItem bar1 = _p.AddBar("", a, null, Color.White);
BarItem bar2 = _p.AddBar("", b, null, Color.Blue);
BarItem bar3 = _p.AddBar("", c, null, Color.Green);

_p.BarSettings.MinClusterGap = 0;

_p.YAxis.Scale.TextLabels = labels;
_p.YAxis.Type = AxisType.Text;

_p.BarSettings.Base = BarBase.Y;
_p.BarSettings.Type = BarType.Stack;


如何反转y轴?我想要顶部的A1,然后是A2,B1和B2。

最佳答案

_p.YAxis.Scale.IsReverse = true;

10-05 22:56