图(图)算法 [英] Graph (Chart) Algorithm

查看:131
本文介绍了图(图)算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个体面的算法,计算轴的最小值和最大值?

Does anyone have a decent algorithm for calculating axis minima and maxima?

在创建图表的一组给定的数据项,我希望能够给算法:

When creating a chart for a given set of data items, I'd like to be able to give the algorithm:

  • 在设定的最大值(Y)值
  • 在设置最小(Y)值
  • 要出现在轴的刻度线数量
  • 在一个可选值必须显示为一个周期(例如,零点显示+时,ve和-ve值)
  • the maximum (y) value in the set
  • the minimum (y) value in the set
  • the number of tick marks to appear on the axis
  • an optional value that must appear as a tick (e.g. zero when showing +ve and -ve values)

该算法应该返回

  • 最大轴值
  • 最小轴值(尽管这可以从最大的推断,间隔的大小和蜱的数目)
  • 的区间大小

蜱应以固定的间隔应该是一个合理的大小(例如1,3,5,甚至可能是2.5,但是现在不是了SIG图)。

The ticks should be at a regular interval should be of a "reasonable" size (e.g. 1, 3, 5, possibly even 2.5, but not any more sig figs).

可选值的presence会歪斜这一点,但没有该值最大的项目应前两名刻度线之间出现,底部的两个之间的最低值。

The presence of the optional value will skew this, but without that value the largest item should appear between the top two tick marks, the lowest value between the bottom two.

这是一个语言无关的问题,但如果有一个C#/。NET库周围,这将是粉碎。)

This is a language-agnostic question, but if there's a C#/.NET library around, that would be smashing ;)

推荐答案

我一直在使用了jQuery的海军报图形库。它是开源的,确实轴/刻度产生相当不错的。我建议你​​看着它是code,并从那里捏一些想法。

I've been using the jQuery flot graph library. It's open source and does axis/tick generation quite well. I'd suggest looking at it's code and pinching some ideas from there.

这篇关于图(图)算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆