v4.x 版本-折线图
代码是基于vue 2.x版本项目中,代码注释部分为关键点解释都是基于d3-v4.x版本的。
demo实现效果图如下:
实现代码如下:(包含关键代码注释)
<template>
<div class="hello">
</div>
</template>
<script>
const d3 = require("d3");
// import * as d3 from "d3"
export default {
name: "Emotion",
data() {
return {
msg: "Welcome to Your Vue.js App"
};
},
mounted: function() {
this.$nextTick(function() {
var dataset = [20, 40, 20, 40, 20, 50];
var width = 400;
var height = 400;
var svg = d3
.select("body")
.append("svg")
.attr("width", width)
.attr("height", height)
.style("bord