mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
🎨
This commit is contained in:
parent
2d6f6dc7ae
commit
cd46ed7eff
|
@ -51,6 +51,7 @@ export default class extends Module {
|
||||||
});
|
});
|
||||||
|
|
||||||
chart = {
|
chart = {
|
||||||
|
title: `@${params.user.username}さんの投稿数`,
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: data.diffs.normal
|
data: data.diffs.normal
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -3,11 +3,7 @@ import { createCanvas, registerFont } from 'canvas';
|
||||||
const width = 1024 + 256;
|
const width = 1024 + 256;
|
||||||
const height = 512 + 256;
|
const height = 512 + 256;
|
||||||
const margin = 128;
|
const margin = 128;
|
||||||
|
const titleTextSize = 35;
|
||||||
const chartAreaX = margin;
|
|
||||||
const chartAreaY = margin;
|
|
||||||
const chartAreaWidth = width - (margin * 2);
|
|
||||||
const chartAreaHeight = height - (margin * 2);
|
|
||||||
|
|
||||||
const lineWidth = 16;
|
const lineWidth = 16;
|
||||||
const yAxisThickness = 2;
|
const yAxisThickness = 2;
|
||||||
|
@ -46,12 +42,20 @@ export function renderChart(chart: Chart) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.fillRect(0, 0, width, height);
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
|
let chartAreaX = margin;
|
||||||
|
let chartAreaY = margin;
|
||||||
|
let chartAreaWidth = width - (margin * 2);
|
||||||
|
let chartAreaHeight = height - (margin * 2);
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
if (chart.title) {
|
if (chart.title) {
|
||||||
ctx.font = '35px CustomFont';
|
ctx.font = `${titleTextSize}px CustomFont`;
|
||||||
const t = ctx.measureText(chart.title);
|
const t = ctx.measureText(chart.title);
|
||||||
ctx.fillStyle = colors.text;
|
ctx.fillStyle = colors.text;
|
||||||
ctx.fillText(chart.title, (width / 2) - (t.width / 2), 128);
|
ctx.fillText(chart.title, (width / 2) - (t.width / 2), 128);
|
||||||
|
|
||||||
|
chartAreaY += titleTextSize;
|
||||||
|
chartAreaHeight -= titleTextSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const xAxisCount = chart.datasets[0].data.length;
|
const xAxisCount = chart.datasets[0].data.length;
|
||||||
|
|
Loading…
Reference in a new issue