Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active December 5, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbostock/6f1cc065d4d172bcaf322e399aa8d62f to your computer and use it in GitHub Desktop.
Save mbostock/6f1cc065d4d172bcaf322e399aa8d62f to your computer and use it in GitHub Desktop.
Localized Time Axis
license: gpl-3.0
<!DOCTYPE html>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
margin = {top: 250, right: 40, bottom: 250, left: 40},
width = svg.attr("width") - margin.left - margin.right,
height = svg.attr("height") - margin.top - margin.bottom;
d3.json("https://unpkg.com/d3-time-format@2/locale/ru-RU.json", function(error, locale) {
if (error) throw error;
d3.timeFormatDefaultLocale(locale);
var x = d3.scaleTime()
.domain([new Date(2000, 0, 1), new Date(2001, 0, 1)])
.range([0, width]);
svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(d3.axisBottom(x));
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment