2016-11-25 64 views

回答

3

如何:

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <link rel="stylesheet" type="text/css" href="https://rawgit.com/sujeetsr/d3.slider/master/d3.slider.css" media="screen" /> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script> 
 
    <script src="https://rawgit.com/sujeetsr/d3.slider/master/d3.slider.js"></script> 
 
</head> 
 

 
<body> 
 
    <div id="slider"></div> 
 
    <script> 
 
    
 
    var tickFormatter = function(d) { 
 
     return d === 0 ? "not important" : "very important" 
 
    } 
 

 
    var slider = d3.slider().min(0).max(1).ticks(1).tickFormat(tickFormatter) 
 
    d3.select('#slider').call(slider); 
 
    
 
    d3.select(".tick>text").style("text-anchor", "start"); 
 
    d3.select(".tick:last-of-type>text").style("text-anchor", "end"); 
 
    
 
    </script> 
 
</body> 
 

 
</html>

相關問題