UNPKG

steam-family-bot-core

Version:

一个用于新版 Steam 家庭的库存监控 Bot 插件

167 lines 5.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaytimeGraph = exports.defaultTextStyle = exports.selectableColor = exports.axisStyle = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const renderChart_1 = require("../renderChart"); exports.axisStyle = { axisLine: { lineStyle: { color: '#ffffff', }, }, axisLabel: { color: '#ffffff', }, splitLine: { lineStyle: { color: 'rgb(0,0,0,0.3)', }, }, }; exports.selectableColor = [ 'rgba(196, 71, 95, 0.7)', 'rgba(53, 162, 235, 0.7)', 'rgba(245, 193, 87, 0.7)', 'rgba(227, 92, 94, 0.7)', 'rgba(66, 151, 104, 0.7)', 'rgba(243, 121, 78, 0.7)', 'rgba(242, 180, 158, 0.7)', ]; exports.defaultTextStyle = { color: '#ffffff', }; const secondsToHours = (sec) => { return sec / 3600; }; function PlaytimeGraph({ playtime, players, style, }) { const option = { darkMode: true, axisTick: { lineStyle: { color: '#ffffff', }, }, axisLabel: { lineStyle: { color: '#ffffff', }, }, color: exports.selectableColor, title: { text: '谁是义父,谁是义子?', left: 'center', textStyle: exports.defaultTextStyle, }, tooltip: { trigger: 'item', textStyle: exports.defaultTextStyle, formatter: (param) => { return (param.name + ` ${param.seriesName} ` + Math.abs(param.value).toFixed(1) + 'h'); }, }, legend: { left: 'center', top: 'bottom', textStyle: exports.defaultTextStyle, data: ['被嫖时长', '白嫖时长'], }, xAxis: [ { type: 'value', nameTextStyle: exports.defaultTextStyle, axisLine: { lineStyle: { color: '#ffffff', }, }, axisLabel: { color: '#ffffff', }, splitLine: { lineStyle: { color: 'rgb(0,0,0,0.3)', }, }, }, ], yAxis: [ { nameTextStyle: exports.defaultTextStyle, axisLine: { lineStyle: { color: '#ffffff', }, }, axisLabel: { color: '#ffffff', }, splitLine: { lineStyle: { color: '#000000', }, }, offset: 30, nameGap: 0, type: 'category', data: playtime .map((item) => item.steamid) .map((id) => players.find((it) => it.steamid?.toString() == id)?.personaName ?? '前成员'), }, ], series: [ { roundCap: true, name: '被嫖时长', type: 'bar', stack: 'Total', opacity: 0.5, height: 3, label: { formatter: (param) => { return param.value.toFixed(1) + 'h'; }, show: true, textStyle: exports.defaultTextStyle, position: 'right', }, itemStyle: { borderRadius: [0, 100, 100, 0], }, emphasis: { focus: 'series', }, data: playtime.map((item) => secondsToHours(item.asOwnerLendTime)), }, { name: '白嫖时长', type: 'bar', stack: 'Total', label: { show: true, formatter: (param) => { return Math.abs(param.value).toFixed(1) + 'h'; }, textStyle: exports.defaultTextStyle, position: 'left', }, itemStyle: { borderRadius: [100, 0, 0, 100], }, emphasis: { focus: 'series', }, data: playtime.map((item) => -secondsToHours(item.asPlayerTime)), }, ], }; const res = (0, renderChart_1.renderChart)(option, style); return ((0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: res, } })); } exports.PlaytimeGraph = PlaytimeGraph; //# sourceMappingURL=playtimeGraph.js.map