D3JS Simple JSON SVG barchart vertical

Size
2,234 Kb
Views
42,504

How do I make an d3js simple json svg barchart vertical?

From tutorial http://bost.ocks.org/mike/bar/2/. What is a d3js simple json svg barchart vertical? How do you make a d3js simple json svg barchart vertical? This script and codes were developed by Dzulfikar Adi Putra on 06 September 2022, Tuesday.

D3JS Simple JSON SVG barchart vertical Previews

D3JS Simple JSON SVG barchart vertical - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>D3JS Simple JSON SVG barchart vertical</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h2>D3JS Simple JSON SVG barchart Horizontal</h2>
<i>using simple JSON data</i><br/>
taken from <a href="https://bost.ocks.org/mike/bar/3/">https://bost.ocks.org/mike/bar/3/</a> <br/><br/>
<div id="chart"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://d3js.org/d3.v3.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

D3JS Simple JSON SVG barchart vertical - Script Codes CSS Codes

#chart rect{ fill: #4aaeea; margin : 3px; padding: 2px;
}
#chart text{ fill: white; font: 10px sans-serif; text-anchor: end;
}
body{ background: #1a1a1a; color : #eaeaea; padding : 10px;
}

D3JS Simple JSON SVG barchart vertical - Script Codes JS Codes

var width=960, height=500;
var y = d3.scale.linear().range([height, 0]);
var chart = d3.select("#chart") .append("svg") .attr("width", width) .attr("height", height);
d3.json("https://codepen.io/superpikar/pen/kcJDf.js", function(error, data){ y.domain([0, d3.max(data, function(d){return d.frequency})]); var barWidth = width/data.length; //width of each bar var bar = chart.selectAll("g") .data(data) .enter() .append("g") .attr("transform", function(d, i){ return "translate("+i*barWidth+", 0)"; }); bar.append("rect") .attr("y", function(d) { return y(d.frequency); }) .attr("height", function(d) { return height - y(d.frequency); }) .attr("width", barWidth - 1); bar.append("text") .attr("x", barWidth / 2) .attr("y", function(d) { return y(d.frequency) -10; }) .attr("dy", ".75em") .text(function(d) { return d.letter; });
});
D3JS Simple JSON SVG barchart vertical - Script Codes
D3JS Simple JSON SVG barchart vertical - Script Codes
Home Page Home
Developer Dzulfikar Adi Putra
Username superpikar
Uploaded September 06, 2022
Rating 3
Size 2,234 Kb
Views 42,504
Do you need developer help for D3JS Simple JSON SVG barchart vertical?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Dzulfikar Adi Putra (superpikar) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!