Skip to content

Commit

Permalink
Merge pull request #214 from ONSvisual/212-column-chart-y-axis-label-…
Browse files Browse the repository at this point in the history
…needs-text-anchor-start

Standardising y-axis label position on column charts
  • Loading branch information
MikeLister authored Mar 22, 2024
2 parents b5d133d + 01e7317 commit d121715
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions column-chart-sm/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', -margin.left + 10)
.attr('y', -5)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(() => chartIndex % chartEvery == 0 ? config.essential.yAxisLabel : "")
.attr('text-anchor', 'start');
Expand Down
2 changes: 1 addition & 1 deletion column-chart-stacked-sm/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', -margin.left + 10)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(() => chartIndex % chartEvery == 0 ? config.essential.yAxisLabel : "")
Expand Down
2 changes: 1 addition & 1 deletion column-chart-stacked-with-line-sm/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', -margin.left + 10)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(() => chartIndex % chartEvery == 0 ? config.essential.yAxisLabel : "")
Expand Down
4 changes: 2 additions & 2 deletions column-chart-stacked-with-line/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', 0)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(config.essential.yAxisLabel)
.attr('text-anchor', 'end');
.attr('text-anchor', 'start');

//create link to source
d3.select('#source').text('Source: ' + config.essential.sourceText);
Expand Down
4 changes: 2 additions & 2 deletions column-chart-stacked/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', 0)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(config.essential.yAxisLabel)
.attr('text-anchor', 'end');
.attr('text-anchor', 'start');

//create link to source
d3.select('#source').text('Source: ' + config.essential.sourceText);
Expand Down
4 changes: 2 additions & 2 deletions column-chart-with-ci-sm/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', -(margin.left - 5))
.attr('y', -10)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(() => chartPosition == 0 ? config.essential.yAxisLabel : "")
.attr('text-anchor', 'start');
Expand Down
8 changes: 4 additions & 4 deletions column-chart/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ config = {
"optional": {
"margin": {
"sm": {
"top": 15,
"top": 25,
"right": 20,
"bottom": 50,
"left": 70
},
"md": {
"top": 15,
"top": 25,
"right": 20,
"bottom": 50,
"left": 70
},
"lg": {
"top": 15,
"top": 25,
"right": 20,
"bottom": 50,
"left": 70
}
},
"aspectRatio": {
"sm": [1, 2],
"sm": [1, 1],
"md": [1, 1],
"lg": [2, 1]
},
Expand Down
6 changes: 3 additions & 3 deletions column-chart/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ function drawGraphic() {
.append('g')
.attr('transform', 'translate(0,0)')
.append('text')
.attr('x', 0)
.attr('y', 0)
.attr('x', 5 - margin.left)
.attr('y', -10)
.attr('class', 'axis--label')
.text(config.essential.yAxisLabel)
.attr('text-anchor', 'end');
.attr('text-anchor', 'start');

//create link to source
d3.select('#source').text('Source: ' + config.essential.sourceText);
Expand Down

0 comments on commit d121715

Please sign in to comment.