本文介绍了如果你的值没有零,你如何得到在graphael中从零开始的y轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个y轴从0开始的图形。我的值都不为0。我怎么做在graphael中这样做?

I wish to create a graph whose y-axis starts at 0. None of my values are 0 though. How do i go about doing that in graphael ?

作为扩展,如何创建一个y轴的图形,其最大值是所提供数据中最大值的两倍?

As an extension, how can I create a graph with a y-axis whose maximum value is, lets say, twice the maximum value in the provided data ?

推荐答案

我不知道这是不是太晚了,但我一直在努力与gRaphael自己,并遇到一个解决方案,可能工作您。没有明显或干净的方式来做到这一点,但我发现了一个体面的黑客。

I don't know if this is too late but I've been struggling with gRaphael myself and came across a solution that might work for you. There's no obvious or clean way to do this but I've found a decent hack for it.

你可以添加另一个y值数组(第一个是0和最后为您的最大值的2倍),并使用颜色选项指定此行的颜色为透明。

You can add in another array of y values (the first being 0 and last being 2x your max value) and specify the color for this line to be transparent using the colors option.

我创建了一个小提琴,以便您可以看到我的意思:

I've created a fiddle so you can see what I mean: jsFiddle example

第一个图表是您当前的图表,第二个图表显示第二组y值的添加。

The first chart is what you currently have and the second shows the addition of the second set of y values.

这篇关于如果你的值没有零,你如何得到在graphael中从零开始的y轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 11:32