parent
8d57e4906a
commit
28f8813060
@ -0,0 +1,12 @@
|
|||||||
|
svg {
|
||||||
|
overflow: visible;
|
||||||
|
margin-left: 20px; /* add this line */
|
||||||
|
}
|
||||||
|
rect {
|
||||||
|
stroke: white;
|
||||||
|
stroke-width:1px;
|
||||||
|
}
|
||||||
|
#bottom-axis text {
|
||||||
|
transform:rotate(45deg);
|
||||||
|
text-anchor: start;
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
var WIDTH = 800;
|
||||||
|
var HEIGHT = 600;
|
||||||
|
|
||||||
|
d3.select('svg')
|
||||||
|
.style('width', WIDTH)
|
||||||
|
.style('height', HEIGHT);
|
||||||
|
|
||||||
|
d3.json('data.json').then(function(data){
|
||||||
|
d3.select('svg').selectAll('rect')
|
||||||
|
.data(data)
|
||||||
|
.enter()
|
||||||
|
.append('rect');
|
||||||
|
var yScale = d3.scaleLinear();
|
||||||
|
yScale.range([HEIGHT, 0]);
|
||||||
|
var yMin = d3.min(data, function(datum, index){
|
||||||
|
return datum.count;
|
||||||
|
})
|
||||||
|
var yMax = d3.max(data, function(datum, index){
|
||||||
|
return datum.count;
|
||||||
|
})
|
||||||
|
yScale.domain([yMin-1, yMax]);
|
||||||
|
d3.selectAll('rect')
|
||||||
|
.attr('height', function(datum, index){
|
||||||
|
return HEIGHT-yScale(datum.count);
|
||||||
|
});
|
||||||
|
var xScale = d3.scaleLinear();
|
||||||
|
xScale.range([0, WIDTH]);
|
||||||
|
xScale.domain([0, data.length]);
|
||||||
|
d3.selectAll('rect')
|
||||||
|
.attr('x', function(datum, index){
|
||||||
|
return xScale(index);
|
||||||
|
});
|
||||||
|
d3.selectAll('rect')
|
||||||
|
.attr('y', function(datum, index){
|
||||||
|
return yScale(datum.count);
|
||||||
|
});
|
||||||
|
d3.selectAll('rect')
|
||||||
|
.attr('width', WIDTH/data.length);
|
||||||
|
var yDomain = d3.extent(data, function(datum, index){
|
||||||
|
return datum.count;
|
||||||
|
})
|
||||||
|
var colorScale = d3.scaleLinear();
|
||||||
|
colorScale.domain(yDomain)
|
||||||
|
colorScale.range(['#00cc00', 'blue'])
|
||||||
|
d3.selectAll('rect')
|
||||||
|
.attr('fill', function(datum, index){
|
||||||
|
return colorScale(datum.count)
|
||||||
|
})
|
||||||
|
var leftAxis = d3.axisLeft(yScale);
|
||||||
|
d3.select('svg')
|
||||||
|
.append('g').attr('id', 'left-axis')
|
||||||
|
.call(leftAxis);
|
||||||
|
var skillScale = d3.scaleBand();
|
||||||
|
var skillDomain = data.map(function(skill){
|
||||||
|
return skill.name
|
||||||
|
});
|
||||||
|
skillScale.range([0, WIDTH]);
|
||||||
|
skillScale.domain(skillDomain);
|
||||||
|
var bottomAxis = d3.axisBottom(skillScale);
|
||||||
|
d3.select('svg')
|
||||||
|
.append('g').attr('id', 'bottom-axis')
|
||||||
|
.call(bottomAxis)
|
||||||
|
.attr('transform', 'translate(0,'+HEIGHT+')');
|
||||||
|
|
||||||
|
});
|
||||||
@ -0,0 +1,142 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "HTML",
|
||||||
|
"count": 21
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CSS",
|
||||||
|
"count": 17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Responsive Web Design",
|
||||||
|
"count": 17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "JavaScript",
|
||||||
|
"count": 17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Git",
|
||||||
|
"count": 16
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Angular.js",
|
||||||
|
"count": 9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Node.js",
|
||||||
|
"count": 9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PostgreSQL",
|
||||||
|
"count": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Agile Project Management",
|
||||||
|
"count": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MongoDB",
|
||||||
|
"count": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Trello",
|
||||||
|
"count": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Testing / TDD",
|
||||||
|
"count": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jQuery",
|
||||||
|
"count": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Testing",
|
||||||
|
"count": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MySQL",
|
||||||
|
"count": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PHP",
|
||||||
|
"count": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "React.js",
|
||||||
|
"count": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AJAX",
|
||||||
|
"count": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Express.js",
|
||||||
|
"count": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Heroku",
|
||||||
|
"count": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Wireframing",
|
||||||
|
"count": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sass/SCSS",
|
||||||
|
"count": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mobile Web",
|
||||||
|
"count": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rails",
|
||||||
|
"count": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "WordPress",
|
||||||
|
"count": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Drupal",
|
||||||
|
"count": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ruby",
|
||||||
|
"count": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ember.js",
|
||||||
|
"count": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Python",
|
||||||
|
"count": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Amazon EC2",
|
||||||
|
"count": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Computer Science degree",
|
||||||
|
"count": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Backbone.js",
|
||||||
|
"count": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Less",
|
||||||
|
"count": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Prototyping",
|
||||||
|
"count": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Redis",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="app.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<svg></svg>
|
||||||
|
<script src="https://d3js.org/d3.v5.min.js"></script>
|
||||||
|
<script src="app.js" charset="utf-8"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in new issue