Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
fix axis tick format
Browse files Browse the repository at this point in the history
  • Loading branch information
osoken committed Mar 20, 2020
1 parent d2f183b commit 0e25eef
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions components/PopulationLineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,30 @@ import * as d3 from 'd3'
export default {
directives: {
xAxis(el, _, vnode) {
d3.select(el).call(d3.axisBottom().scale(vnode.context.xScale))
d3.select(el)
.call(
d3
.axisBottom()
.scale(vnode.context.xScale)
.tickFormat(d => d3.timeFormat('%m/%d')(d))
)
.call(g =>
g
.selectAll('.tick text')
.attr('y', 0)
.attr('x', 9)
.attr('dy', '.35em')
.attr('text-anchor', 'start')
.attr('transform', 'rotate(90)')
)
},
yAxis(el, _, vnode) {
d3.select(el).call(d3.axisLeft().scale(vnode.context.yScale))
d3.select(el).call(
d3
.axisLeft()
.scale(vnode.context.yScale)
.ticks(3)
)
}
},
props: ['height', 'chartData'],
Expand All @@ -93,7 +113,7 @@ export default {
marginLeft: 60,
marginTop: 4,
marginRight: 4,
marginBottom: 20,
marginBottom: 40,
width: 480,
timeFormat: d3.timeFormat('%Y%m%d'),
timeParse: d3.timeParse('%Y%m%d'),
Expand Down

0 comments on commit 0e25eef

Please sign in to comment.