import { element } from 'protractor'; import { cloneDeep } from 'lodash' export const columnChart_series: { name: string, type: string, barGap: string, data: any[] }[] = [{ name: "", type: "bar", barGap: "10%", data: [], }, ]; export const barChart_series: any[] = [ { name: "", type: "bar", barGap: "50%", barCategoryGap: "30%", barMaxWidth: 11, data: [], label: { show: true, position: "right", fontSize: 11, fontWeight: "bold", color: "#333333", }, }, ]; const symbols = [ "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow", ]; export const getBasicLineChartSeries = function ( datas: any[][], seryNames: any[] ) { let series = []; for (let i = 0; i < seryNames.length; i++) { let sery = { name: seryNames[i], type: "line", symbol: symbols[i % symbols.length], symbolSize: 6, barGap: 0, smooth: 0.2, label: { show: true, position: "left", formatter: function (params) { if (datas[i].length - 1 == params.dataIndex) { return params.seriesName; } else { return ""; } }, }, data: datas[i], }; series.push(sery); } return series; }; export const getMoreLineChartSeries = function ( datas: any[][], seryNames: any[] ) { let series = []; for (let i = 0; i < seryNames.length; i++) { let sery = { name: seryNames[i], type: "line", symbol: symbols[i % symbols.length], symbolSize: 2, smooth: 0.2, lineStyle: { width: 1, }, label: { show: false, fontWeight: "bold", color: "#000000", }, data: datas[i], }; series.push(sery); } return series; }; export const getBigDataLineChartSeries = function ( datas: any[][][], seriesNames: any[] ) { let series = []; for (let i = 0; i < seriesNames.length; i++) { let sery = { name: seriesNames[i], type: "line", symbol: symbols[i % symbols.length], symbolSize: 0.8, lineStyle: { width: 0.8, }, data: datas[i], }; series.push(sery); } return series; }; export const getAnnotationsLineChartSeries = function ( datas: any[][][], seriesNames: any[], markPoints: any[] ) { let series = []; for (let i = 0; i < seriesNames.length; i++) { let sery = { name: seriesNames[i], type: "line", symbol: symbols[i % symbols.length], symbolSize: 1.2, lineStyle: { width: 1.2, }, // itemStyle: { // shadowOffsetX: 2, // shadowOffsetY: 2 // }, emphasis: { itemStyle: { borderColor: "#ffffff", borderWidth: 2, }, }, data: datas[i], areaStyle: { opacity: 0.5, }, smooth: 0.8, markPoint: { data: markPoints[i], symbol: "circle", symbolSize: 8, label: { show: true, position: "right", distance: 5, color: "#000000", formatter: function (param) { return param.data.name; }, backgroundColor: "#FFFFFF", borderColor: "#7cb5ec", borderWidth: 0.4, padding: 5, borderRadius: 2, }, itemStyle: { // color: "#020A0F", borderColor: "#4D4D4D", borderWidth: 0.5, }, }, }; series.push(sery); } return series; }; export const getNegativeBarChartSeries = function (datas: any[][][], seriesNames: any[], translationNumber: number) { let series = []; for (let i = 0; i < seriesNames.length; i++) { let sery = { name: seriesNames[i], type: "bar", // symbol: symbols[i % symbols.length], // symbolSize: 1.2, // lineStyle: { // width: 1.2, // }, // itemStyle: { // shadowOffsetX: 2, // shadowOffsetY: 2 // }, emphasis: { itemStyle: { borderColor: "#ffffff", borderWidth: 2, }, }, cursor: "pointer", barMaxWidth: 15, barGap: "35%", large: true, largeThreshold: 400, data: datas[i].map(element => { return [element[0], element[1] - translationNumber]; }), // areaStyle: { // opacity: 0.5, // }, // smooth: 0.8, // markPoint: { // data: markPoints[i], // symbol: "circle", // symbolSize: 8, // label: { // show: true, // position: "right", // distance: 5, // color: "#000000", // formatter: function (param) { // return param.data.name; // }, // backgroundColor: "#FFFFFF", // borderColor: "#7cb5ec", // borderWidth: 0.4, // padding: 5, // borderRadius: 2, // }, // itemStyle: { // // color: "#020A0F", // borderColor: "#4D4D4D", // borderWidth: 0.5, // }, // }, }; series.push(sery); } return series; }; export function getColumnChartSeries(data) { const columnChartSeries = { name: '', type: 'bar', barGap: '10%', data: [], barMaxWidth: 30, } let seriesArr = []; for (let i = 0; i < data.seriesName.length; i++) { let columnSeries = cloneDeep(columnChartSeries); columnSeries.name = data.seriesName[i]; columnSeries.data = data.yData[i] seriesArr.push(columnSeries) } return seriesArr; } export function getBarChartSeries(data) { const barChartSeries = { name: '', type: 'bar', barGap: '50%', barCategoryGap: "30%", barMaxWidth: 20, data: [], label: { show: true, position: 'right', fontSize: 11, fontWeight: 'bold', color: "#333333" } } let seriesArr = []; for (let i = 0; i < data.seriesName.length; i++) { let barSeries = cloneDeep(barChartSeries); barSeries.name = data.seriesName[i]; barSeries.data = data.xData[i]; seriesArr.push(barSeries) } return seriesArr; } /** * 获取堆叠柱状图的series */ export function getStackBarChartSeries(data) { const stackBarChartSeries = { name: '', type: 'bar', stack: '', barGap: '50%', barMaxWidth: 30, data: [], } let seriesArr = []; for (let i = 0; i < data.seriesName.length; i++) { let stackBarSeries = cloneDeep(stackBarChartSeries); stackBarSeries.name = data.seriesName[i]; // stackBarSeries.stack = data.stack[i % data.stack.length]; stackBarSeries.stack = data.stack[i]; stackBarSeries.data = data.yData[i] seriesArr.push(stackBarSeries) } return seriesArr; } /** * 获取金字塔图的series */ export function getPyramidBarChartSeries(data) { const pyramidBarChartSeries = { name: '', type: 'bar', stack: '', yAxisIndex: 0, barCategoryGap: '50%', data: [] } let pyramidSeries = [] console.log(data.xData) data.xData.forEach((item, index) => { let partOfSeries = cloneDeep(pyramidBarChartSeries); partOfSeries.name = data.seriesName[index]; partOfSeries.stack = data.stack; partOfSeries.data = item; partOfSeries.yAxisIndex = index; pyramidSeries.push(partOfSeries); }) return pyramidSeries }