如何获得量化值 [英] How to get quantize values

查看:194
本文介绍了如何获得量化值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法来获得量化标度的量化的开始和结束值。
范围由5种颜色定义,域由d3.min和d3.max函数对我的json文件中的数据进行定义。
我需要他们为我的choropleth地图的传奇。



这是我的代码

  var quantizecolors = [#d7191c,#fdae61,#ffffbf,#a6d96a,#1a9641]; 
var colorEnerg = d3.scale.quantize()。range(quantizecolors);
colorEnerg.domain([
d3.min(collection.features,function(d){return d.properties.EB / d.properties.BEVZ;}),
d3.max collection.features,function(d){return d.properties.EB / d.properties.BEVZ;})
]);


解决方案

我假设你问的是最大域值。除了在设置它们时保存它们,还可以调用 colorEnerg.domain()而不使用任何值,这将返回数组 [min ,max]



您可以通过计算间隔的数量和位置来获取休息位置:

  var dom = colorEnerg.domain(),
l =(dom [1] - dom [0])/ colorEnerg.range ,
breaks = d3.range(0,colorEnerg.range()。length).map(function(i){return i * l;});


is there a way to get the start and end values of the quantizes of an quantize scale. The range is defined by 5 colors ans the domain by d3.min and d3.max function on my data from an json file. I need them for my legend of an choropleth map. Thank you for helping.

Carsten

Thats my code

var quantizecolors = ["#d7191c","#fdae61","#ffffbf", "#a6d96a","#1a9641"];
var colorEnerg = d3.scale.quantize().range(quantizecolors);
colorEnerg.domain([
                            d3.min(collection.features, function(d){return d.properties.EB/d.properties.BEVZ;}),
                            d3.max(collection.features, function(d){return d.properties.EB/d.properties.BEVZ;})
                            ]); 

解决方案

I assume that you're asking about the minimum and maximum domain values. Apart from saving them when you're setting them, you can also call colorEnerg.domain() without any values, which will return the array [min, max].

You can get the position of the breaks by computing the number and position of intervals:

var dom = colorEnerg.domain(),
    l = (dom[1] - dom[0])/colorEnerg.range().length,
    breaks = d3.range(0, colorEnerg.range().length).map(function(i) { return i * l; });

这篇关于如何获得量化值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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