D3 Axes

https://github.com/d3/d3/blob/master/API.md#axes-d3-axis

<head>
    <style>
        .axis path,line{
            fill:none;
            stroke:black;
            shape-rendering:crispEdges;
        }
        .axis text{
            font-family: sans-serif;
            font-size:11px;
        }
    </style>
</head>
<body>
    <script>
        var width = 600
        var height = 600
		//添加画布
        var svg = d3.select("body")
                    .append('svg')
                    .attr('width',width)
                    .attr('height',height)
        var xScale = d3.scale.linear()
                        .domain([0,1])
                        .range([0,300])
        var axis = d3.svg.axis()
                    .scale(xScale)
                    .orient('bottom')
        //使用g元素绘制刻度
        var gAxis = svg.append('g')
        .call(axis)//等同于axis(gAxis)
        .attr('transform','translate(80,80)')
        .attr('class','axis')

    </script>
</body>

d3.axisTop - create a new top-oriented axis generator.
d3.axisRight - create a new right-oriented axis generator.
d3.axisBottom - create a new bottom-oriented axis generator.
d3.axisLeft - create a new left-oriented axis generator.
axis - generate an axis for the given selection.
axis.scale - set the scale.
axis.ticks - customize how ticks are generated and formatted.
axis.tickArguments - customize how ticks are generated and formatted.
axis.tickValues - set the tick values explicitly.
axis.tickFormat - set the tick format explicitly.
axis.tickSize - set the size of the ticks.
axis.tickSizeInner - set the size of inner ticks.
axis.tickSizeOuter - set the size of outer (extent) ticks.
axis.tickPadding - set the padding between ticks and labels.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值