English 中文(简体)
缩略语
原标题:Equal scale for both of X and Y in Zedgraph chart

Based on my experience with Zedgraph I could not set both of X and Y axes scale same to have a correct scatter graph! Assume we have a square grid of 10x10m cells in which each cell is a square shape 1x1m. when we try to draw points of such data, the output is not acceptable because each axis scaled to different scale. It is worse when we try to call Zoomall, then we find all points are fitted to chart area regardless their equal spacing! I hope someone can help me to find a solution. Although Zedgraph is flexible library but this is a big fault!

问题回答

perfectly aware, this q. is 9 years old, but still.. Have just encountered and solved the issue of presenting the graph in a square pane. (It seems that was the OP question) It s a bit "brute" and invokes redundant redraws, but gets the job done.

        //"GraphWinFormsHost" is my ZGraph container
        GraphWinFormsHost.SizeChanged += (sender, args) =>
        {
            //"IsEqualScale" is my property, indicating a square is needed
            if(_ChartData == null || !_ChartData.IsEqualScale)
                return;

            _ZedGraphControl.GraphPane.Chart.IsRectAuto = true;
            _ZedGraphControl.Refresh();

            //here, the graph pane is redrawn according to available space
            float x = _ZedGraphControl.GraphPane.Chart.Rect.X;
            float y = _ZedGraphControl.GraphPane.Chart.Rect.Y;
            float h = _ZedGraphControl.GraphPane.Chart.Rect.Height;
            float w = _ZedGraphControl.GraphPane.Chart.Rect.Width;
            float min = Math.Min(h, w);
            _ZedGraphControl.GraphPane.Chart.Rect = new RectangleF(x, y, min, min);
        };

比额表。 IsAnyOrdinal 是任何轴心。 比额表?

Zed Graph在比额表时似乎根据指数抵消而不是按负值排列的点子。 型号为AxisType。 文本,Ordinal, 日期AsOrdinal, 或 LinearAsOrdinal。

我最近不得不解决同样的问题。 这对我来说是行之有效的:

zg1.AxisChange();
                
if (myPane.XAxis.Scale.Max > myPane.YAxis.Scale.Max) {
    myPane.YAxis.Scale.Max = myPane.XAxis.Scale.Max;
    myPane.YAxis.Scale.Min = myPane.XAxis.Scale.Min;
    myPane.YAxis.Scale.MajorStep = myPane.XAxis.Scale.MajorStep;
} else {
    myPane.XAxis.Scale.Max = myPane.YAxis.Scale.Max;
    myPane.XAxis.Scale.Min = myPane.YAxis.Scale.Min;
    myPane.XAxis.Scale.MajorStep = myPane.YAxis.Scale.MajorStep;
}

zg1.AxisChange();

第1次电话:<代码>AxisChange 控制权自动计算了我数据正确的数值。 然后,我复制从一个比额表到另一个比额表的相关参数,并适用这一改动。





相关问题
Scale proportionally below movieclip size

I m trying to make a movieclip scale proportionally only if the item is being resize smaller than the current. Obviously I can use the ScaleX/Y values like so: if (cont.scaleX < cont.scaleY ) { ...

how can i make this equation faster

right now i have a bottle neck in my program I m trying to write. i am trying to use a pinch gesture to control the scale of a UIImage. its the calculation of the scale that is causing the program to ...

How Do You CAKeyframeAnimation Scale?

I want to create an animation with several key frames. I want my Layer (a button in this case) to scale up to 1.5 then down to 0.5 then up to 1.2 then down to 0.8 then 1.0. I also want to EaseIn and ...

How do I scale a UIButton s imageView?

I created a UIButton instance named "button" with an image using [UIButton setImage:forState:]. The button.frame is larger than the image s size. Now I want to scale this button s image smaller. I ...

Scaling and cropping huge image on the iPhone

For the last few weeks I ve been tearing my hair out trying to get a tiling mechanism working on an iPhone. I need to scale and crop images of about 150mb so that they can be saved as tiles that will ...

Scale a .jpg file in WPF

I d like to open a .jpg file in WPF, scale it down to around 50%, then save it back to the file system. What s a good/efficient way to go about doing that?

热门标签