What is D3js version support policy?

人走茶凉 提交于 2019-12-07 06:05:43

问题


I'm new to D3js and before getting started I want to understand how versions for the core and plugins are managed so I don't find myself stuck with an old unsupported versions or using something that's too experimental.

If I look at the release history I see that v4 was introduced back in Jun 2016 (https://github.com/d3/d3/releases?after=v4.1.0) and v5 in Jan 2018 (https://github.com/d3/d3/releases?after=v5.0.1).

Yet, when I look at D3js code on the gallery (https://github.com/d3/d3/wiki/Gallery), I see that most of it is based on v3 which is 2 major releases behind.

For instance if I take a Sankey example updated in May 2018 it's still based on v3, and if I try to replace it with v5 it breaks.

Another example: someone had an issue with v4 back in Feb 2017, and the answer at the time and in April 2017 it was still not working (despite it was already v4.8 at the time, nearly 1 year after the release of v4) :

So it seems that v4/v5 are completely different branches from v3 and are not even backwards compatible.

Hence my questions:

  • To what extent is v5 backward compatible with v3?
  • How long will v3 still be supported?

回答1:


Consolidating comments as 1 comprehensive answer:

General philosophy
It seems, and it's understandable given the fact that D3 creator is creating/maintaining the library mostly by himself, that there isn't enough resources to design with backwards-compatibility nor maintain old code.

Which version to choose
Given the above, when starting fresh, it seems picking the latest version is the most sensible choice.

Backward compatibility
There have been backward incompatible changes going from v3 to to v5 (v5 removed d3-queue, d3-request, schemeCategory20...). So it wouldn't be a shocker if in the future other backward incompatible changes are introduced.

Legacy support
It seems the moment a new version is released, support for the older version is abandoned and all efforts are focused on the new version:
https://twitter.com/mbostock/status/764274097995907072




回答2:


The D3v3 schemeCategory20[bc] are not available in v4(??) and v5.

Using the color numbers from the v3 source code and converting them to the hex equivalents we can use if in v5 like

var colors = d3.scaleOrdinal(d3.schemeCategory20b);

The small snippet

function d3_rgbHexString(value) { return "#" + (0x1000000 + value).toString(16).substring(1); }
d3.schemeCategory20  = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbHexString);
d3.schemeCategory20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbHexString);
d3.schemeCategory20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbHexString);


来源:https://stackoverflow.com/questions/51477927/what-is-d3js-version-support-policy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!