Trying to create a histogram using ZedGraph

I am trying to create a histogram using ZedGraph.

Bars and data are good, the only thing needed is my bars to be between ticks, and not directly on ticks.

Sample data:

1, 4
2, 8
3, 1

Means I have:

4 items that are >= 0 and < 1
8 items that are >= 1 and < 2
1 item that is >= 2 and < 3

So, now my bars, of course, appear directly on ticks (x values) 1, 2 and 3.

But I would like to see:

  • first bar between ticks 0 and 1,
  • second bar between ticks 1 and 2 and
  • third bar between ticks 2 and 3

What property can be configured to achieve this? I'm looking in XAxisand now XAxis.Scale, but I haven't found anything yet ...

+3
source share
1 answer

, BarItem. BoxObj .

histList - PointPairList, ( ), :

for (int i = 0; i < histList.Count - 1; i++)
{
BoxObj box = new BoxObj(histList[i].X, histList[i].Y, histList[i + 1].X - histList[i].X, histList[i].Y);
box.IsClippedToChartRect = true;
box.Fill.Color = myColor;
pane.GraphObjList.Add(box);
}

BoxObj, , .. documentation


, BoxObj ( GraphObj ) X Y . :

pane.XAxis.Scale.Min = ...
pane.XAxis.Scale.Max = ...
pane.YAxis.Scale.Min = ...
pane.YAxis.Scale.Max = ...
+3

Source: https://habr.com/ru/post/1768871/


All Articles