【发布时间】:2018-07-31 11:38:49
【问题描述】:
我正在关注here 提供的文档以获得简单的折线图。所有依赖包都是使用yarn 添加的,是否有可能附加的 css/scss 没有正确引导?
问题
如截图所示,渲染的图表全是黑色和丑陋的,可能是因为缺少 css,不确定。
使用的包
"dependencies": {
"chartist": "^0.11.0",
"vue": "2.5.0",
"vue-typed": "git+https://github.com/icfr/vue-typed.git#update_vue",
"vuetify": "^0.17.6"
},
"devDependencies": {
"@types/chartist": "^0.9.38"
}
Vue Js 模板 - linechart.vue
<template>
<v-content>
<v-container grid-list-xl>
<h2>Line chart using chartist.js</h2>
<div class ="ct-chart"></div>
</v-container>
</v-content>
</template>
TS 代码
import Vue from "vue";
import { Component, Prop } from "vue-typed";
import * as Chartist from "chartist";
const template = require("./linechart.vue");
export default class ChartistLineChart extends Vue {
mounted() {
let chart = this.$el.getElementsByClassName("ct-chart")[0];
let data: Chartist.IChartistData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
series: [[740, 790, 720, 900, 890, 880, 840],
[140, 390, 100, 900, 190, 180, 400]
]
};
let options: Chartist.ILineChartOptions = {
fullWidth: true,
chartPadding: {
right: 40
}
};
let lineChart = new Chartist.Line(chart, data, options);
}
我可能缺少什么?谢谢!
【问题讨论】:
标签: typescript webpack vue.js vuetify.js chartist.js