当前位置: 首页 > wzjs >正文

做产品推广哪个网站好宽屏网站设计

做产品推广哪个网站好,宽屏网站设计,wordpress 新浪微博图床,wordpress tipton在Vue2中使用ECharts还是比较麻烦的,今天做了几个组件让我们能更加简单的调用Echars来显示图表。 效果展示 echarts 导入 这里我们使用 package.json 方式导入Echars。配置好后使用命令 npm install或者其他方式都可以 {// ... "scripts": {// ... &qu…

在Vue2中使用ECharts还是比较麻烦的,今天做了几个组件让我们能更加简单的调用Echars来显示图表。

效果展示

在这里插入图片描述
在这里插入图片描述

echarts 导入

这里我们使用 package.json 方式导入Echars。配置好后使用命令 npm install或者其他方式都可以

{// ... "scripts": {// ... "setYarn": "yarn config set registry https://registry.npmmirror.com/", // 设置yarn镜像地址"yarnInstall": "yarn install", // yarn}// ... "dependencies": {// ... "echarts": "^5.4.3", // 博主用的是这个版本可根据自己需求修改}// ... 
}

父组件引用

<template><div><!-- 操作按钮区域 --><div><a-button @click="loadData" type="primary" icon="sync">刷新</a-button></div><EBarChart title='MSA偏倚直方图' :data="barData" x-label='测量值' y-label='频数' width="90%" height="500px" /><ELineChart title='' :data="barData" x-label='测量值' y-label='频数' width="90%" height="500px" /><EPieChart title='' :data=" [{ value: 1048, name: '测量值1' },{ value: 735, name: '测量值2' },{ value: 580, name: '测量值3' },]" width="90%" height="500px" /></div>
</template><script>
import { getAction } from '@/api/manage';
import EBarChart from '@comp/EChart/EBarChart.vue';
import ELineChart from '@comp/EChart/ELineChart.vue'
import EPieChart from '@comp/EChart/EPieChart.vue'export default {name: '',components: { ELineChart, EBarChart, EPieChart },data() {return {dataSource: [],chartOptions: {},barData: {x:[],y:[],},url: {list: '/msa/msaBias/listAllMsaGroupDataByMainId',},};},methods: {clearList() {this.dataSource = [];},loadData() {this.chartOptions = {};this.barData = {x: [],y: []};// 这里是请求服务器数据的方式 如果不需要自行修改getAction(this.url.list, { pid: this.mainId }).then(res => {if (res.success) {this.dataSource = res.result.records || res.result;const xData = this.dataSource.map(item => String(item.minValue)); // 确保是字符串const yData = this.dataSource.map(item => Number(item.sampleCount)); // 确保是数值this.barData = {x: xData,y: yData};} else {this.$message.error(res.message);}});},},
};
</script><style scoped></style>

柱状图组件

<template><div ref="chartContainer" :style="{ width: width, height: height }"></div>
</template><script>
import * as echarts from 'echarts';export default {name: 'EBarChart',props: {title: { type: String, default: "柱状图" },xLabel: { type: String, default: "" },yLabel: { type: String, default: "" },options: { type: Object, default: () => ({}) },// 自定义optionsdata: { type: Object, default: () => ({}) }, // 调用方式{x:[],y:[]}width: { type: String, default: '100%' },height: { type: String, default: '400px' },},data() {let xLabel = this.xLabellet yLabel = this.yLabelreturn {chartInstance: null,defaultOptions: {// 标题配置title: {text: this.title, // 标题文本left: 'center', // 标题位置(居中)top: '0px', // 标题距离图表顶部 20pxtextStyle: {fontSize: 25, // 标题字体大小fontWeight: 'bold', // 标题字体加粗color: '#333', // 标题字体颜色},},// 提示框配置tooltip: {trigger: 'axis', // 触发方式(坐标轴触发)backgroundColor: 'rgba(50, 50, 50, 0.7)', // 提示框背景颜色borderColor: '#333', // 提示框边框颜色borderWidth: 1, // 提示框边框宽度padding: 10, // 提示框内边距textStyle: {fontSize: 18, // 提示框字体大小color: '#fff', // 提示框字体颜色},formatter: function (params) {// 自定义提示框内容return `${yLabel}: ${params[0].name}<br/>${xLabel}: ${params[0].value}`;},},// 图例配置legend: {show: true, // 是否显示图例data: [yLabel], // 图例数据(与 series.name 对应)left: 'right', // 图例位置(右侧)textStyle: {fontSize: 18, // 图例字体大小color: '#333', // 图例字体颜色},},// 网格配置grid: {left: '10%', // 网格左侧距离right: '10%', // 网格右侧距离bottom: '15%', // 网格底部距离top: '15%',containLabel: true, // 是否包含坐标轴标签},// X 轴配置xAxis: {type: 'category', // 坐标轴类型(类目轴)data: [], // 类目数据axisLabel: {fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色rotate: 0, // 标签旋转角度interval: 0, // 强制显示所有标签},axisLine: {lineStyle: {color: '#333', // 坐标轴线颜色width: 2, // 坐标轴线宽度},},axisTick: {show: true, // 是否显示坐标轴刻度alignWithLabel: true, // 刻度与标签对齐},name: xLabel, // 坐标轴名称nameLocation: 'center', // 坐标轴名称位置(居中)nameGap: 50, // 坐标轴名称与轴线的距离nameTextStyle: {fontSize: 18, // 坐标轴名称字体大小color: '#333', // 坐标轴名称字体颜色},},// Y 轴配置yAxis: {type: 'value', // 坐标轴类型(数值轴)axisLabel: {fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色},axisLine: {lineStyle: {color: '#333', // 坐标轴线颜色width: 2, // 坐标轴线宽度},},axisTick: {show: true, // 是否显示坐标轴刻度},splitLine: {show: true, // 是否显示分割线lineStyle: {color: '#eee', // 分割线颜色type: 'dashed', // 分割线类型(虚线)},},name: yLabel, // 坐标轴名称nameLocation: 'center', // 坐标轴名称位置(居中)nameGap: 50, // 坐标轴名称与轴线的距离nameTextStyle: {fontSize: 18, // 坐标轴名称字体大小color: '#333', // 坐标轴名称字体颜色},},// 数据系列配置series: [{name: yLabel, // 系列名称(与图例对应)type: 'bar', // 图表类型(柱状图)data: [], // 数据值barWidth: 'auto', // 柱状图宽度(自动计算)barGap: '5px', // 两个柱子之间的宽度label: {show: true, // 是否显示标签position: 'top', // 标签位置(柱状图顶部)fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色formatter: '{c}', // 标签内容格式(显示数据值)},itemStyle: {color: '#5470C6', // 柱状图颜色borderColor: '#333', // 柱状图边框颜色borderWidth: 1, // 柱状图边框宽度},},],},};},mounted() {this.initChart();window.addEventListener('resize', this.handleResize);},beforeDestroy() {window.removeEventListener('resize', this.handleResize);if (this.chartInstance) this.chartInstance.dispose();},methods: {initChart() {const dom = this.$refs.chartContainer;if (!dom) {console.error('Chart container not found!');return;}this.chartInstance = echarts.init(dom);const mergedOptions = this.generateOptions();console.log('initChart:', mergedOptions); // 打印 mergedOptionsthis.chartInstance.setOption(mergedOptions);},generateOptions() {let mergedOptions = { ...this.defaultOptions };if (Object.keys(this.options).length > 0) {// 方式一:使用用户自定义的 optionsmergedOptions = this.options;} else if (this.data?.x?.length > 0 && this.data?.y?.length > 0) {// 方式二:使用默认配置,填充 datamergedOptions.xAxis.data = this.data.x;mergedOptions.series[0].data = this.data.y;}console.log('generateOptions:', mergedOptions); // 打印 mergedOptionsreturn mergedOptions;},handleResize() {this.chartInstance?.resize();},},watch: {options: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},data: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},},
};
</script>

折线图组件

<template><div ref="chartContainer" :style="{ width: width, height: height }"></div>
</template><script>
import * as echarts from 'echarts';export default {name: 'ELineChart',props: {title: { type: String, default: "折线图" },xLabel: { type: String, default: "" },yLabel: { type: String, default: "" },options: { type: Object, default: () => ({}) }, // 自定义optionsdata: { type: Object, default: () => ({}) }, // 调用方式{x:[],y:[]}width: { type: String, default: '100%' },height: { type: String, default: '400px' },},data() {let xLabel = this.xLabellet yLabel = this.yLabelreturn {chartInstance: null,defaultOptions: {// 标题配置title: {text: this.title, // 标题文本left: 'center', // 标题位置(居中)top: '0px', // 标题距离图表顶部 20pxtextStyle: {fontSize: 25, // 标题字体大小fontWeight: 'bold', // 标题字体加粗color: '#333', // 标题字体颜色},},// 提示框配置tooltip: {trigger: 'axis', // 触发方式(坐标轴触发)backgroundColor: 'rgba(50, 50, 50, 0.7)', // 提示框背景颜色borderColor: '#333', // 提示框边框颜色borderWidth: 1, // 提示框边框宽度padding: 10, // 提示框内边距textStyle: {fontSize: 18, // 提示框字体大小color: '#fff', // 提示框字体颜色},formatter: function (params) {// 自定义提示框内容return `${yLabel}: ${params[0].name}<br/>${xLabel}: ${params[0].value}`;},},// 图例配置legend: {show: true, // 是否显示图例data: [yLabel], // 图例数据(与 series.name 对应)left: 'right', // 图例位置(右侧)textStyle: {fontSize: 18, // 图例字体大小color: '#333', // 图例字体颜色},},// 网格配置grid: {left: '10%', // 网格左侧距离right: '10%', // 网格右侧距离bottom: '15%', // 网格底部距离top: '15%',containLabel: true, // 是否包含坐标轴标签},// X 轴配置xAxis: {type: 'category', // 坐标轴类型(类目轴)data: [], // 类目数据axisLabel: {fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色rotate: 0, // 标签旋转角度interval: 0, // 强制显示所有标签},axisLine: {lineStyle: {color: '#333', // 坐标轴线颜色width: 2, // 坐标轴线宽度},},axisTick: {show: true, // 是否显示坐标轴刻度alignWithLabel: true, // 刻度与标签对齐},name: xLabel, // 坐标轴名称nameLocation: 'center', // 坐标轴名称位置(居中)nameGap: 50, // 坐标轴名称与轴线的距离nameTextStyle: {fontSize: 18, // 坐标轴名称字体大小color: '#333', // 坐标轴名称字体颜色},},// Y 轴配置yAxis: {type: 'value', // 坐标轴类型(数值轴)axisLabel: {fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色},axisLine: {lineStyle: {color: '#333', // 坐标轴线颜色width: 2, // 坐标轴线宽度},},axisTick: {show: true, // 是否显示坐标轴刻度},splitLine: {show: true, // 是否显示分割线lineStyle: {color: '#eee', // 分割线颜色type: 'dashed', // 分割线类型(虚线)},},name: yLabel, // 坐标轴名称nameLocation: 'center', // 坐标轴名称位置(居中)nameGap: 50, // 坐标轴名称与轴线的距离nameTextStyle: {fontSize: 18, // 坐标轴名称字体大小color: '#333', // 坐标轴名称字体颜色},},// 数据系列配置series: [{name: yLabel, // 系列名称(与图例对应)type: 'line', // 图表类型(折线图)data: [], // 数据值label: {show: true, // 是否显示标签position: 'top', // 标签位置(折线图顶部)fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色formatter: '{c}', // 标签内容格式(显示数据值)},itemStyle: {color: '#5470C6', // 折线图颜色borderColor: '#333', // 折线图边框颜色borderWidth: 1, // 折线图边框宽度},lineStyle: {color: '#5470C6', // 折线颜色width: 2, // 折线宽度},symbol: 'circle', // 数据点形状symbolSize: 8, // 数据点大小},],},};},mounted() {this.initChart();window.addEventListener('resize', this.handleResize);},beforeDestroy() {window.removeEventListener('resize', this.handleResize);if (this.chartInstance) this.chartInstance.dispose();},methods: {initChart() {const dom = this.$refs.chartContainer;if (!dom) {console.error('Chart container not found!');return;}this.chartInstance = echarts.init(dom);const mergedOptions = this.generateOptions();console.log('initChart:', mergedOptions); // 打印 mergedOptionsthis.chartInstance.setOption(mergedOptions);},generateOptions() {let mergedOptions = { ...this.defaultOptions };if (Object.keys(this.options).length > 0) {// 方式一:使用用户自定义的 optionsmergedOptions = this.options;} else if (this.data?.x?.length > 0 && this.data?.y?.length > 0) {// 方式二:使用默认配置,填充 datamergedOptions.xAxis.data = this.data.x;mergedOptions.series[0].data = this.data.y;}console.log('generateOptions:', mergedOptions); // 打印 mergedOptionsreturn mergedOptions;},handleResize() {this.chartInstance?.resize();},},watch: {options: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},data: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},},
};
</script>

饼图组件

<template><div ref="chartContainer" :style="{ width: width, height: height }"></div>
</template><script>
import * as echarts from 'echarts';export default {name: 'EPieChart',props: {title: { type: String, default: "饼图" },options: { type: Object, default: () => ({}) },data: { type: Object, default: () => ([]) },// 调用方式 [{ value: 1048, name: '测量值1' },...]width: { type: String, default: '100%' },height: { type: String, default: '400px' },},data() {return {chartInstance: null,defaultOptions: {// 标题配置title: {text: this.title, // 标题文本left: 'center', // 标题位置(居中)top: '0px', // 标题距离图表顶部 20pxtextStyle: {fontSize: 25, // 标题字体大小fontWeight: 'bold', // 标题字体加粗color: '#333', // 标题字体颜色},},// 提示框配置tooltip: {trigger: 'item', // 触发方式(数据项触发)backgroundColor: 'rgba(50, 50, 50, 0.7)', // 提示框背景颜色borderColor: '#333', // 提示框边框颜色borderWidth: 1, // 提示框边框宽度padding: 10, // 提示框内边距textStyle: {fontSize: 18, // 提示框字体大小color: '#fff', // 提示框字体颜色},formatter: function (params) {// 自定义提示框内容return `${params.name}: ${params.value} (${params.percent}%)`;},},// 图例配置legend: {show: true, // 是否显示图例left: 'right', // 图例位置(右侧)textStyle: {fontSize: 18, // 图例字体大小color: '#333', // 图例字体颜色},},// 数据系列配置series: [{name: '频数', // 系列名称(与图例对应)type: 'pie', // 图表类型(饼图)radius: '50%', // 饼图半径(50%表示占容器的一半)data: [], // 数据值label: {show: true, // 是否显示标签fontSize: 18, // 标签字体大小color: '#333', // 标签字体颜色formatter: '{b}: {c} ({d}%)', // 标签内容格式(显示名称、值和百分比)},itemStyle: {borderColor: '#fff', // 饼图边框颜色borderWidth: 2, // 饼图边框宽度},emphasis: {// 高亮样式label: {show: true,fontSize: 20,fontWeight: 'bold',},itemStyle: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: 'rgba(0, 0, 0, 0.5)',},},},],},};},mounted() {this.initChart();window.addEventListener('resize', this.handleResize);},beforeDestroy() {window.removeEventListener('resize', this.handleResize);if (this.chartInstance) this.chartInstance.dispose();},methods: {initChart() {const dom = this.$refs.chartContainer;if (!dom) {console.error('Chart container not found!');return;}this.chartInstance = echarts.init(dom);const mergedOptions = this.generateOptions();console.log('initChart:', mergedOptions); // 打印 mergedOptionsthis.chartInstance.setOption(mergedOptions);},generateOptions() {let mergedOptions = { ...this.defaultOptions };if (Object.keys(this.options).length > 0) {// 方式一:使用用户自定义的 optionsmergedOptions = this.options;} else if (this.data?.length > 0) {// 方式二:使用默认配置,填充 datamergedOptions.series[0].data = this.data;}console.log('generateOptions:', mergedOptions); // 打印 mergedOptionsreturn mergedOptions;},handleResize() {this.chartInstance?.resize();},},watch: {options: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},data: {deep: true,handler() {if (this.chartInstance) {const mergedOptions = this.generateOptions();this.chartInstance.setOption(mergedOptions, { notMerge: true }); // 强制更新}},},},
};
</script>

文章转载自:

http://d6UZ83Oj.Lxhrq.cn
http://IoR6rbYD.Lxhrq.cn
http://rPKImPFb.Lxhrq.cn
http://xbEC0owB.Lxhrq.cn
http://id5eW7o3.Lxhrq.cn
http://PMtW9LdD.Lxhrq.cn
http://aLmzOpoz.Lxhrq.cn
http://hUSe7ZdW.Lxhrq.cn
http://FpFll4tk.Lxhrq.cn
http://3QxnOPyB.Lxhrq.cn
http://Qd4gLnsm.Lxhrq.cn
http://AyTGfRv0.Lxhrq.cn
http://aFiNiVBQ.Lxhrq.cn
http://kRWzGW88.Lxhrq.cn
http://vzntGb9p.Lxhrq.cn
http://20vyAGAE.Lxhrq.cn
http://oyudHb6I.Lxhrq.cn
http://hiO2lrOp.Lxhrq.cn
http://gWpaeD9b.Lxhrq.cn
http://zE7Iooj7.Lxhrq.cn
http://sJhb7T7e.Lxhrq.cn
http://SIr1h0O1.Lxhrq.cn
http://Ztk3Zygg.Lxhrq.cn
http://dwQrrWP1.Lxhrq.cn
http://LcjcVscd.Lxhrq.cn
http://6L5lK4xC.Lxhrq.cn
http://XapOBTTv.Lxhrq.cn
http://fcSRme8R.Lxhrq.cn
http://HNr0r5Lm.Lxhrq.cn
http://HZOr8v42.Lxhrq.cn
http://www.dtcms.com/wzjs/631738.html

相关文章:

  • 番禺建设网站哪个好重庆市建设工程施工安全管理总站
  • 网站做图分辨率是多少合适石家庄市城乡建设学校网站
  • 建设网站需要多少钱济南兴田德润o厉害吗网页制作与网站建设
  • 如何用服务器搭建网站手机网站优化指南
  • 郑州网站建设公司最火的网站开发语言
  • 湖南住房和城乡建设网门户网站工作组赴河南协助
  • 番禺市桥做网站公司动易网站后台密码破解
  • 有网站怎么建设手机站做circrna的网站
  • 做标志的网站如何同步打开两个wordpress
  • 企业网站设计特点爱生活辽宁移动app
  • 酷我音乐网站架构智能小程序WordPress
  • 天塔网站建设公司eclipse做企业网站
  • 苏州建设工程招标在哪个网站生成属于自己app的软件
  • ftp网站怎么看后台的代码wordpress 样式插件
  • 网站备案自己备案和代理备案必须网站的访问量
  • 门户网站建设方法wordpress中文文档 chm
  • 网站开发静态怎样转成动态内网代理ip建设网站
  • 广州有网站建设学校wordpress移动端底部添加菜单
  • 局域网站怎么做重庆互联网企业
  • 自己专业做网站百度推广客户端app
  • 网站标题切换wordpress+防止采集
  • 公众号制作模板网站招远 两学一做 网站
  • 网站需求流程图网络信息安全公司排名
  • 六安门户网站建设哪家好展示型网站模板源码
  • 专业建站制作网站设计色彩搭配
  • 做国际贸易有哪些平台王通seo赚钱培训
  • 环球资源的服务种类seo标签优化
  • 厦门网站开发排名兰州有互联网公司嘛
  • 在网站做电子画册安徽建筑培训网
  • 网站怎么做404页面的跳转抖音seo搜索优化