Code Monkey home page Code Monkey logo

Comments (4)

ckinmind avatar ckinmind commented on July 23, 2024

刻度调整, 调增刻度的数量

var yAxis = d3.axisLeft(yScale)  
// 变为
var yAxis = d3.axisLeft(yScale).ticks(5)

刻度变为算上原点总共6个

image

from d3hub.

ckinmind avatar ckinmind commented on July 23, 2024

刻度显示百分比

var yScale = d3.scaleLinear()
  .domain([0, 1])
  .range([height, 0]);
var yAxis = d3.axisLeft(yScale).ticks(5, '%')

image

from d3hub.

ckinmind avatar ckinmind commented on July 23, 2024

刻度显示小数位数

var yScale = d3.scaleLinear()
  .domain([0, 1])
  .range([height, 0]);
var yAxis = d3.axisLeft(yScale).ticks(5, '.2s');  // 显示两位小数
svg.call(yAxis);

image

from d3hub.

ckinmind avatar ckinmind commented on July 23, 2024

刻度不是均值,自定义的分布

var yScale = d3.scaleLinear()
  .domain([0, 1])
  .range([height, 0]);
var yAxis = d3.axisLeft(yScale).tickValues([8, 19, 43, 77]);
svg.call(yAxis);
  1. tickValues 明确地指定刻度值
  2. 注意到图里的0和100没出现,因为指定的数组中没有0和100

image

from d3hub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.