Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use vue to make Transverse oblique cut histogram

Shulou Source: shulou.com Published: 2022-06-03 18:28:32 10月03日 Update

This article mainly explains "how to use vue to make a horizontal oblique bar chart", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "how to use vue to make horizontal oblique bar chart"!

In this paper, an example is given to share the specific code of vue to realize the horizontal oblique cut bar chart for your reference. The details are as follows.

Achieve results:

Implementation code:

Import echarts from 'echarts'const myShape = {x: 0, y: 0, width: 10 / / spacing} / / draw the left side const InclinedRoofBar = echarts.graphic.extendShape ({shape: myShape, buildPath: function (ctx, shape) {/ / canvas should be able to read Shape is const xAxisPoint = shape.xAxisPoint const c0 = [shape.x, shape.y] const C1 = [shape.x + 14, shape.y-10] const c2 = [xAxisPoint [0], xAxisPoint [1]-10] const c3 = [xAxisPoint [0], xAxisPoint [1] ctx .moveto (c0 [0], c0 [1]) .lineTo (C1 [0], C1 [1]) .lineTo (c2 [0]) C2 [1]) .lineTo (c3 [0], c3 [1]) .closePath ()}) const colors = ['rgba (50,197,255,0.8)', 'rgba (0,253,255,0.8)', 'rgba (255,235,0,0.8)'] const colorss = ['rgba (0,145,255,1)', 'rgba (68,215,182,1)', 'rgba (215,170,68)' 1)'] / / register three face graphics echarts.graphic.registerShape ('InclinedRoofBar', InclinedRoofBar) const defaultOption = {tooltip: {show: true, trigger:' axis', axisPointer: {type: 'shadow'}}, grid: {top: 10, bottom: 30, left: 10, right: 10, containLabel: true}, yAxis: {type:' category', data: [] AxisLine: {show: false}, axisTick: {show: false}, axisLabel: {color (value, index) {return colorss [index]}, fontSize: 14}}, xAxis: {type: 'value', axisLine: {show: false}, min: 0, splitLine: {show: false} AxisTick: {show: false}, axisLabel: {show: false}, boundaryGap: ['20% custom', name,'20%]}, series: [{type: 'custom', name:', itemStyle: {color: 'rgba (44,197,253,1)}, renderItem: (params Api) = > {const location = api.coord ([api.value (0), api.value (1)]) const xlocation = api.coord ([0, api.value (1)]) return {type: 'InclinedRoofBar', shape: {api, xValue: api.value (0), yValue: api.value (1), x: location [0] Y: location [1] + myShape.width, xAxisPoint: [xlocation [0], xlocation [1] + myShape.width]}, style: {fill: new echarts.graphic.LinearGradient (0,0,1,0, [{offset: 0, color: colors [params.dataIndex]]} {offset: 1, color: colorss [params.dataIndex]})}, data: []}, {type: 'bar', label: {normal: {show: true, position:' right' FontSize: 14, offset: [15,0]}}, showBackground: false, barWidth: 14, backgroundStyle: {color: 'rgba (50,197,255,0.1)'}, itemStyle: {color: 'transparent'}, tooltip: {show: false} Data: []}} export default {data () {return {myChart: null}}, mounted () {this.myChart = echarts.init (this.$refs.ConsumptionChart)}, methods: {getOption (seriesData) {const option = defaultOption const {yAxis, series} = option / / processing data yAxis.data = ['low', 'medium' 'Gao'] series [0] .data = seriesData series [1] .data = seriesData.map ((item, index) = > Object.assign (item, {label: {color: colorss [index]})) this.myChart.setOption (option)} Thank you for reading The above is the content of "how to use vue to make transverse diagonal histogram". After the study of this article, I believe you have a deeper understanding of how to use vue to make transverse oblique histogram, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Horizontal column production content learning code three graphics examples that is ideas situations effects data articles more knowledge knowledge points articles follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn Redmi Huawei Shulou Technology