D3 again -

Developer
Size
3,264 Kb
Views
12,144

How do I make an d3 again -?

Working from http://chimera.labs.oreilly.com/books/1230000000345/ch09.html#updating_thevisuals. What is a d3 again -? How do you make a d3 again -? This script and codes were developed by Shannon Range on 10 November 2022, Thursday.

D3 again - Previews

D3 again - - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>D3 again - </title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="after" class="button">AFTER TRANSFERS</div>
<div id="before"class="button">BEFORE TRANSFERS</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

D3 again - - Script Codes CSS Codes

.button {	-moz-box-shadow:inset 0px 1px 0px 0px #c1ed9c;	-webkit-box-shadow:inset 0px 1px 0px 0px #c1ed9c;	box-shadow:inset 0px 1px 0px 0px #c1ed9c;	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #9dce2c), color-stop(1, #8cb82b) );	background:-moz-linear-gradient( center top, #9dce2c 5%, #8cb82b 100% );	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#9dce2c', endColorstr='#8cb82b');	background-color:#9dce2c;	-webkit-border-top-left-radius:20px;	-moz-border-radius-topleft:20px;	border-top-left-radius:20px;	-webkit-border-top-right-radius:20px;	-moz-border-radius-topright:20px;	border-top-right-radius:20px;	-webkit-border-bottom-right-radius:20px;	-moz-border-radius-bottomright:20px;	border-bottom-right-radius:20px;	-webkit-border-bottom-left-radius:20px;	-moz-border-radius-bottomleft:20px;	border-bottom-left-radius:20px;	text-indent:0;	border:1px solid #83c41a;	display:inline-block;	color:#ffffff;	font-family:Arial;	font-size:15px;	font-weight:bold;	font-style:normal;	height:50px;	line-height:50px;	width:179px;	text-decoration:none;	text-align:center;	text-shadow:1px 1px 0px #689324; margin:20px
}
.button:hover {	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #8cb82b), color-stop(1, #9dce2c) );	background:-moz-linear-gradient( center top, #8cb82b 5%, #9dce2c 100% );	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8cb82b', endColorstr='#9dce2c');	background-color:#8cb82b;
}
.button:active {	position:relative;	top:1px;
}

D3 again - - Script Codes JS Codes

//Width and height	var w = 588;	var h = 600;
// HERE IS THE INITIAL SET OF DATA WHEN THE PAGE LOADS
var dataset = [40.5, 33.1,31.6, 31.0, 29.9, 28.9, 25.2, 25.2, 24.8, 24.3, 24.0, 22.6, 20.5, 19.5, 19.0, 18.9, 18.8, 18.5, 18.4, 17.6, 17.1, 17.1, 17.1, 16.3, 16.2, 14.2, 13.6, 13.6, 13.5, 13.3, 11.9, 11.1, 10.3, 9.5, 9.2];
var xScale = d3.scale.ordinal()	.domain(d3.range(dataset.length))	.rangeRoundBands([0, w], 0.05);
var yScale = d3.scale.linear()	.domain([0, d3.max(dataset)])	.range([0, h]);
var colors = d3.scale.linear() .domain([0,d3.max(dataset)]) .range(["#ff9900","#990000"])
//Create SVG element
var svg = d3.select("body")	.append("svg")	.attr("width", w)	.attr("height", h);
//HERE WE DRAW THE FIRST SET OF BARS WHEN THE PAGE LOADS
var drawBars = svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("x", function(d, i) {	return xScale(i); }) .attr("width", xScale.rangeBand()) .attr("height", 0) .attr("y", h) .attr("fill", colors) .on('mouseover', function(d) {d3.select(this).style('opacity', .4)}) .on('mouseout', function(d) {d3.select(this).style('opacity', 1)})
drawBars.transition().delay(100).duration(2000) .attr("height", function(d) { return yScale(d);}) .attr("y", function(d) {	return h - yScale(d); })	//Create labels
var drawLabels = svg.selectAll("text") .data(dataset) .enter() .append("text") .text(function(d) {return d;}) .attr('opacity',0) .attr("text-anchor", "middle") .attr("x", function(d, i) {	return xScale(i) + xScale.rangeBand() / 2; }) .attr("y", function(d) {	return h - yScale(d) + 14; }) .attr("font-family", "sans-serif") .attr("font-size", "11px") .attr("fill", "white");
drawLabels.transition().delay(2000).duration(500) .attr('opacity',1);
// HERE IS THE SECOND SET OF DATA FOR THE "AFTER TRANSFERS"
d3.select("#after") .on("click", function() { //New values for dataset dataset = [8.4, 12.1, 25.5, 10.3, 11.7, 10.9, 13.3, 23.1, 15.4, 12.3, 17.8, 18.8, 14.7, 8.8, 11.2, 10.2, 17.1, 14.5, 11.9, 7.3, 7.4, 8.5, 8.9, 15.9, 14.9, 5.3, 6.3, 7.3, 6.1, 16, 6.5, 6.1, 6.1, 8.1, 4.7]; //Update all rects svg.selectAll("rect") .data(dataset) .transition().delay(0).duration(1000).ease('cubic-in-out') .attr("y", function(d) { return h - yScale(d); }) .attr("height", function(d) { return yScale(d); }) .attr("fill", colors) var drawNewlabels = svg.selectAll("text") .data(dataset) .text(function(d) {return d;}) .attr('opacity',0) .attr("x", function(d, i) {return xScale(i) + xScale.rangeBand() / 2; }) .attr("y", function(d) {return h - yScale(d) + 14; }); drawNewlabels.transition().delay(1000).duration(500) .attr('opacity',1) });
// HERE WE RETURN TO THE FIRST SET OF DATA FOR THE "BEFORE TRANSFERS"
d3.select("#before") .on("click", function() { //New values for dataset	var dataset = [40.5, 33.1,31.6, 31.0, 29.9, 28.9, 25.2, 25.2, 24.8, 24.3, 24.0, 22.6, 20.5, 19.5, 19.0, 18.9, 18.8, 18.5, 18.4, 17.6, 17.1, 17.1, 17.1, 16.3, 16.2, 14.2, 13.6, 13.6, 13.5, 13.3, 11.9, 11.1, 10.3, 9.5, 9.2]; //Update all rects svg.selectAll("rect") .data(dataset) .transition().delay(0).duration(1000).ease('cubic-in-out') .attr("y", function(d) { return h - yScale(d); }) .attr("height", function(d) { return yScale(d); }) .attr("fill", colors) var drawFirstlabels = svg.selectAll("text") .data(dataset) .text(function(d) {return d;}) .attr('opacity',0) .attr("x", function(d, i) {return xScale(i) + xScale.rangeBand() / 2; }) .attr("y", function(d) {return h - yScale(d) + 14; }); drawFirstlabels.transition().delay(1000).duration(500) .attr('opacity',1) });
D3 again - - Script Codes
D3 again - - Script Codes
Home Page Home
Developer Shannon Range
Username silentkrange
Uploaded November 10, 2022
Rating 3
Size 3,264 Kb
Views 12,144
Do you need developer help for D3 again -?

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!

Shannon Range (silentkrange) 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!