0

Here the fiddle, I need to create a scale with variable values in, like this :

_________________________________________________________________
  |    |    |    |    |    |    |    |    |    |    |    |    |
  1    2    3    4    5    6    7    8    9    10   20   30   40

And I want my data [2, 5, 9, 20] to be show like this :

=======
======================
==========================================
=====================================================
_________________________________________________________________
  |    |    |    |    |    |    |    |    |    |    |    |    |
  1    2    3    4    5    6    7    8    9    10   20   30   40
  • Please provide more information. As it is right now, you can create such a scale with `var scale = d3.scale.ordinal(); scale.range([1,2,3,4,5,6,7,8,9,10,20,30,40]);`, but I assume that's not what you want (otherwise you would not ask). – Felix Kling Jun 09 '14 at 00:38
  • Looks like you want this scale: https://github.com/mbostock/d3/wiki/Quantitative-Scales#quantize-scales . As you can read in the `linear.range()` documentation, using `.linear` doesn't make sense: *"If values is specified, sets the scale's output range to the specified array of values. The array must contain two or more values, to match the cardinality of the input domain, otherwise the longer of the two is truncated to match the other."* So, your code is equivalent to `scale.domain([0,d3.max(dataArray)]).range([ 0, 1]);` . – Felix Kling Jun 09 '14 at 01:57
  • So I'll try linear.range right away ! – user3264208 Jun 09 '14 at 02:03
  • That's not what I'm trying to say with my comment: *"As you can read in the `linear.range()` documentation, using `.linear` **doesn't make sense**"* – Felix Kling Jun 09 '14 at 02:04
  • My bad, I wanted to say "I'll try quantize scales right away !" – user3264208 Jun 09 '14 at 02:08
  • @FelixKling The result is realy strange : [fiddle](http://jsfiddle.net/LU9PK/3/) I think it's what i need but maybe I use it in the wrong way ? – user3264208 Jun 09 '14 at 02:41
  • I don't know, looks good to me, though I'm not very familiar with scales. – Felix Kling Jun 09 '14 at 02:49
  • @user3264208 What do you mean when you say that it looks really strange? – Lars Kotthoff Jun 09 '14 at 03:45
  • @LarsKotthoff Maybe the result is logical but I don't understand it. I can't see how to get what I want – user3264208 Jun 09 '14 at 04:06
  • Well it looks to me like exactly what you're asking for. Maybe you could elaborate on how it isn't? – Lars Kotthoff Jun 09 '14 at 17:06

0 Answers0