How to sync three GraphPane's in ZedGraph?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 02:22:53

问题


While using ZedGraph to display six graphs on three GraphPane's as shown in first pic, all graphs are in sync. However when i try to display the date for the first pane the graph are out of sync as shown in the second pic. Its important that all six graphs remain in sync for the user to make sense of the whole chart.

I have tried XAxis.Type = AxisType.Date as suggested by tmwoods here and was able to show the dates along X axis. The DateTime along X axis can be in minutes/seconds say from 9:00 AM to 4:00 PM could also be in days say form 28/1/2009 to 25/11/2012


回答1:


OK, I think I got it. Try adding this to your code:

pane1.Chart.Rect = new RectangleF (pane2.Chart.Rect.X,
            pane2.Chart.Rect.Y,
            pane2.Chart.Rect.Width,
            pane2.Chart.Rect.Height);

I've been peeking around and Zedgraph supports something called Graph Align but I can't find source on it anywhere. The closest I have found is here; check out the bottom-most example. It describes how to align multiple charts of varyng sizing vertically. But I haven't tested it out.




回答2:


The accepted answer is correct and works, however, ZedGraph has a built-in feature that keeps all axes in sync:

zgc.IsSynchronizeXAxes = true; // This keeps X axes min and max in sync
zgc.IsSynchronizeYAxes = true; // This keeps Y axes min and max in sync
zgc.MasterPane.IsCommonScaleFactor = true // This will ensure a common Scale is applied to all graphPanes axes.

Here is a IsCommonScaleFactor and a IsSynchronizeXAxes or IsSynchronizeYAxes sample.



来源:https://stackoverflow.com/questions/15996603/how-to-sync-three-graphpanes-in-zedgraph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!