# Pie Chart

Original D3 demo at https://bl.ocks.org/mbostock/3887235

<55-1314-1718-2425-4445-64≥65
<template>
  <d3-pie class="demo" :width="860" :height="450" :outerRadius="200"
    :data="data" label="age" value="population" color="color"/>
</template>

<script>
import * as d3 from 'd3'

const colorScale = d3.scaleOrdinal([
  "#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"
])

export default {
  data () {
    return {
      data: null
    }
  },
  created () {
    d3.csv('/data/age-population.csv', d => {
      d.population = +d.population
      return d
    }).then(data => {
      data.forEach(d => d.color = colorScale(d.age))
      this.data = data
    })
  }
}
</script>

<style lang="scss" scoped>
.demo /deep/ {
  .arc text {
    font: 10px sans-serif;
    text-anchor: middle;
  }
  .arc path {
    stroke: #fff;
  }
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41