refactor: 默认使用svg渲染echart

This commit is contained in:
Captain.B 2020-08-26 16:23:31 +08:00
parent e483748b97
commit b653848594
8 changed files with 452 additions and 397 deletions

View File

@ -9,7 +9,7 @@
</div> </div>
</el-row> </el-row>
<chart id="chart" ref="chart" :options="options" :autoresize="true"></chart> <ms-chart id="chart" ref="chart" :options="options" :autoresize="true"></ms-chart>
<el-row type="flex" justify="center" align="middle"> <el-row type="flex" justify="center" align="middle">
<i class="circle success"/> <i class="circle success"/>
<div class="metric-box"> <div class="metric-box">
@ -50,9 +50,11 @@
</template> </template>
<script> <script>
import MsChart from "@/business/components/common/chart/MsChart";
export default { export default {
name: "MsMetricChart", name: "MsMetricChart",
components: {MsChart},
props: { props: {
content: Object, content: Object,
totalTime: Number totalTime: Number
@ -62,7 +64,7 @@
hour: 0, hour: 0,
minutes: 0, minutes: 0,
seconds: 0, seconds: 0,
time: 0 time: 0,
} }
}, },
created() { created() {

View File

@ -0,0 +1,41 @@
<template>
<chart
:init-options="defaultInitOptions"
:options="options"
:theme="theme"
:group="group"
:watch-shallow="watchShallow"
:manual-update="manualUpdate"
:autoresize="autoresize"/>
</template>
<script>
export default {
name: "MsChart",
props: {
options: Object,
theme: [String, Object],
initOptions: Object,
group: String,
autoresize: Boolean,
watchShallow: Boolean,
manualUpdate: Boolean
},
data() {
return {
defaultInitOptions: this.initOptions
}
},
mounted() {
this.defaultInitOptions = this.defaultInitOptions || {};
// svg
if (!this.defaultInitOptions.renderer) {
this.defaultInitOptions.renderer = 'svg';
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,17 +1,19 @@
<template> <template>
<div> <div>
<chart :options="options"> <ms-chart :options="options">
</chart> </ms-chart>
</div> </div>
</template> </template>
<script> <script>
import MsChart from "@/business/components/common/chart/MsChart";
export default { export default {
name: "MsPieChart", name: "MsPieChart",
components: {}, components: {MsChart},
mounted() { mounted() {
this.getDataNamesByData(); this.getDataNamesByData();
}, },

View File

@ -1,12 +1,14 @@
<template> <template>
<chart :options="bar"></chart> <ms-chart :options="bar"></ms-chart>
</template> </template>
<script> <script>
import echarts from 'echarts' import echarts from 'echarts'
import MsChart from "@/business/components/common/chart/MsChart";
export default { export default {
name: "PerformanceChart", name: "PerformanceChart",
components: {MsChart},
data() { data() {
return { return {
bar: { bar: {

View File

@ -84,7 +84,7 @@
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<div class="title">{{ $t('load_test.pressure_prediction_chart') }}</div> <div class="title">{{ $t('load_test.pressure_prediction_chart') }}</div>
<chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></chart> <ms-chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></ms-chart>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -92,6 +92,7 @@
<script> <script>
import echarts from "echarts"; import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart";
const TARGET_LEVEL = "TargetLevel"; const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp"; const RAMP_UP = "RampUp";
@ -102,6 +103,7 @@ const RPS_LIMIT_ENABLE = "rpsLimitEnable";
export default { export default {
name: "MsPerformancePressureConfig", name: "MsPerformancePressureConfig",
components: {MsChart},
props: ['report'], props: ['report'],
data() { data() {
return { return {

View File

@ -59,18 +59,21 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<chart ref="chart1" :options="loadOption" class="chart-config" :autoresize="true"></chart> <ms-chart ref="chart1" :options="loadOption" class="chart-config" :autoresize="true"></ms-chart>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<chart ref="chart2" :options="resOption" class="chart-config" :autoresize="true"></chart> <ms-chart ref="chart2" :options="resOption" class="chart-config" :autoresize="true"></ms-chart>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import MsChart from "@/business/components/common/chart/MsChart";
export default { export default {
name: "TestOverview", name: "TestOverview",
components: {MsChart},
data() { data() {
return { return {
maxUsers: "0", maxUsers: "0",

View File

@ -99,7 +99,7 @@
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<div class="title">{{ $t('load_test.pressure_prediction_chart') }}</div> <div class="title">{{ $t('load_test.pressure_prediction_chart') }}</div>
<chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></chart> <ms-chart class="chart-container" ref="chart1" :options="orgOptions" :autoresize="true"></ms-chart>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -107,6 +107,7 @@
<script> <script>
import echarts from "echarts"; import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart";
const TARGET_LEVEL = "TargetLevel"; const TARGET_LEVEL = "TargetLevel";
const RAMP_UP = "RampUp"; const RAMP_UP = "RampUp";
@ -117,6 +118,7 @@ const RPS_LIMIT_ENABLE = "rpsLimitEnable";
export default { export default {
name: "PerformancePressureConfig", name: "PerformancePressureConfig",
components: {MsChart},
props: { props: {
testPlan: { testPlan: {
type: Object type: Object

View File

@ -2,6 +2,7 @@ import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line' import 'echarts/lib/chart/line'
import 'echarts/lib/chart/bar' import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/pie' import 'echarts/lib/chart/pie'
import 'zrender/lib/svg/svg'
export default { export default {
install(Vue) { install(Vue) {