简体   繁体   English

WPF工具包是否可以像Excel一样缩放图表

[英]WPF toolkit Is it possible to scale Chart like Excel

I am developing a plot/chart/graph. 我正在开发一个绘图/图表/图形。 I want o scale the Y axis on Log of base 10 - so I want values 0, 10, 100, 1000, 10000, 100000 on Y axis. 我想在以10为底的对数上缩放Y轴-所以我想在Y轴上设置值0、10、100、1000、10000、100000。 I am able to get the scale also, but want the values in same distances. 我也可以得到比例尺,但是想要相同距离的值。 Attached snap shots of what I get and what I want : 附上我所能得到和想要的快照:

Results of what I get from my code : 我从代码中得到的结果: 这就是我得到的

我正在寻找的结果: This is a plot generated from Excel. 这是从Excel生成的图。 In my app, I want this results ie equal distance between numbers. 在我的应用中,我希望得到这样的结果,即数字之间的距离相等。

Code that I use to scale my Y axis : 我用来缩放Y轴的代码:

public class LogConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        double x = double.Parse(value.ToString());
        int y = (int)x;
        switch (y)
        {
            case 0:
            case 10:
            case 100:
            case 1000:
            case 10000:
            case 100000: 
            case 1000000:
            case 10000000:
                Console.WriteLine("Log = " + value);
                return y.ToString();
            default:
                return null;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

I set Min =0 & Max (dynamic) of Y Axis and its interval is set to 10. Any idea how do I achieve this goal ? 我将Y轴的Min = 0和Max(动态)设置为10,并将其间隔设置为10。知道如何实现此目标吗? Is it possible in WPF ? 在WPF中可以吗? Any help is highly appreciated. 非常感谢您的帮助。

You may have to create your own logarithmic axis . 您可能必须创建自己的对数轴 This blog has an example: WPF & Silverlight Charting: A Logarithmic Axis . 该博客有一个示例: WPF和Silverlight图表:对数轴

我使用OxyPlot开源来实现我的目标

Like Tvd said, you can use OxyPlot. 就像电视说的那样,您可以使用OxyPlot。

If you look here: OxyPlot Documentation it says the documentation is under construction. 如果您在此处查看: OxyPlot文档,则说明该文档正在构建中。 Never the less, head into your code, and you can do this: 无论如何,进入您的代码,您可以执行以下操作:

var logarithmicAxis = new LogarithmicAxis();

There are 3 constructors you can use ... it should be smooth sailing from there. 您可以使用3个构造函数...从那里开始应该很顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM