Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize cascading histogram with Vue+ Antv F2

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to achieve cascading bar chart in Vue+ Antv F2". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "how to achieve cascading bar chart in Vue+ Antv F2" can help you solve the problem.

First, create the canvas tag. Second, write the chart drawing code methods: {/ / obtain the patent case Chart icon information getCaseChartData () {var _ this = this. Var params = {dataType:_this.caseDataType, beginDate:'', endDate:_this.endDate} _ this.$http.get ('/ api/patent/StatisticsPatentChartAmount' {params:params}) .then (res = > {if (res.status = = 200) {for (var I = 0) I

< res.data.length; i++){ if(res.data[i].dataType == "monthPatent"){res.data[i].dataType = '新立案'} else if(res.data[i].dataType == "applyPatent"){res.data[i].dataType = '新申请'} else if(res.data[i].dataType == "PCTPatent"){res.data[i].dataType = 'PCT国际'} else if(res.data[i].dataType == "otherPatent"){res.data[i].dataType = '其他案件'} else {} res.data[i].date = res.data[i].date+"-01" + " 00:00:00" } _this.caseData = res.data; _this.$options.methods.caseChart.bind(this)(); }else{ } }) .catch(error =>

{})}, caseChart () {var _ this = this / / create Chart object _ this.casechart = new this.$F2.Chart ({id: 'caseChart', pixelRatio: window.devicePixelRatio, / / specify resolution}) / / source load data _ this.casechart.source (JSON.parse (JSON.stringify (this.caseData)), {date: {/ / x axis type: 'timeCat', tickCount: 6, / / range: [0.1,0.9], mask:'YY-MM' }, / / amount: {/ /}}) _ this.casechart.tooltip ({custom: true, / / Custom tooltip content box onChange: function onChange (obj) {const legend = _ this.casechart.get ('legendController'). Legends.top [0]; const tooltipItems = obj.items; const legendItems = legend.items; const map = {} LegendItems.forEach (function (item) {map [item.name] = item;}); tooltipItems.forEach (function (item) {const name = item.name; const value = item.value) If (map [name]) {map [name] .value = value;}}); / / legend.setItems (_ .values (map)) }, onHide: function onHide () {const legend = _ this.casechart.get ('legendController'). Legends.top [0]; legend.setItems (_ this.casechart.getLegendItems () .country);}}); var barWidth = 16 * (window.innerWidth / 375) / / create the syntax of the graph, draw the graph, determine the position of the graph by date and amount attributes, and map the date to the x-axis. Amount maps to y axis _ this.casechart.interval () .position ('date*amount') .color (' dataType') .adjust ('stack') .size (barWidth) / / render chart _ this.casechart.render () }, mounted () {var v = this; this.$nextTick (() = > {v.caseChart ();});}, third, show the effect

This is the end of the introduction of "how to achieve cascading bar charts in Vue+ Antv F2". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report