Highcharts实现3D 圆柱状图cylinder
程序员文章站
2022-06-09 23:30:03
...
import Highcharts from "highcharts/highstock";
import cylinder from "highcharts/modules/cylinder";
import Highcharts3D from "highcharts/highcharts-3d";
Highcharts3D(Highcharts);
cylinder(Highcharts);
chartBar_park1: function (docm) {
let self = this;
// let myColors = ["#5066b2", "#4b99a5", "#cf5f87", "#6bb582", "#764cba", "#55666d", "#5066b2", "#4b99a5", "#06d7f6", "#206ae5"];
Highcharts.chart(docm, {
chart: {
type: 'cylinder',
backgroundColor: null,
spacing: [30, 10, 10, 10],
options3d: {
enabled: true,
alpha: 16,
beta: 0,
depth: 0
}
},
colors: ["#5066b2", "#4b99a5", "#cf5f87", "#6bb582", "#764cba", "#55666d", "#5066b2", "#4b99a5", "#06d7f6", "#206ae5"],
title: {
text: ''
},
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span>{point.y}'
},
xAxis: {
// gridLineColor: "#21658a",
gridLineWidth: 0,
lineColor: "#21658a",
// categories: ["高新技术产业开发区", "经济技术开发区", "小蓝经济技术开发区", "新建经济开发区", "青山湖高新技术产业园区", "进贤经济开发区", "江西安义工业园区"],
categories: self.ParksCount.listX,
labels: {
style: {
color: "#fff",
fontSize: 10
},
autoRotation: false,
useHTML: true,
formatter: function () {
// return '<a href="' + categoryLinks[this.value] + '">' +
// this.value + '</a>';
// 获取到刻度值
let labelVal = this.value;
let ret = ""; // 拼接加\n返回的类目项
let maxLength = 3; // 每项显示文字个数
let valLength = labelVal.length; // X轴类目项的文字个数
let rowN = Math.ceil(valLength / maxLength); // 类目项需要换行的行数
// 如果类目项的文字大于3,
if (rowN > 1) {
for (let i = 0; i < rowN; i++) {
let temp = ""; // 每次截取的字符串
let start = i * maxLength; // 开始截取的位置
let end = start + maxLength; // 结束截取的位置
temp = labelVal.substring(start, end) + "<br/>";
ret += temp; // 凭借最终的字符串
}
return ret;
} else {
return labelVal;
}
}
}
},
yAxis: {
title: {
text: ''
},
gridLineColor: "#21658a",
labels: {
style: {
color: "#fff",
fontSize: 10
}
}
},
plotOptions: {
series: {
colorByPoint: true
}
},
series: [{
name: "",
colorByPoint: true,
data: self.ParksCount.listY,
showInLegend: false,
borderWidth: 0,
pointWidth: 14
}]
});