MCPcopy
hub / github.com/zxlie/FeHelper / getChartOptions

Function getChartOptions

apps/chart-maker/chart-generator.js:347–551  ·  view source on GitHub ↗
(settings)

Source from the content-addressed store, hash-verified

345
346// 获取图表配置选项
347function getChartOptions(settings) {
348 const options = {
349 responsive: true,
350 maintainAspectRatio: false,
351 plugins: {
352 title: {
353 display: !!settings.title,
354 text: settings.title,
355 font: {
356 size: 18,
357 weight: 'bold'
358 },
359 padding: {
360 top: 10,
361 bottom: 20
362 }
363 },
364 legend: {
365 display: settings.legendPosition !== 'none',
366 position: settings.legendPosition === 'none' ? 'top' : settings.legendPosition,
367 labels: {
368 usePointStyle: true,
369 padding: 15,
370 font: {
371 size: 12
372 }
373 }
374 },
375 tooltip: {
376 enabled: true,
377 backgroundColor: 'rgba(0, 0, 0, 0.7)',
378 titleFont: {
379 size: 14
380 },
381 bodyFont: {
382 size: 13
383 },
384 padding: 10,
385 displayColors: true
386 }
387 },
388 animation: {
389 duration: settings.animateChart ? 1000 : 0,
390 easing: 'easeOutQuart'
391 }
392 };
393
394 // 只有部分图表类型需要轴线配置
395 if (!['pie', 'doughnut', 'polarArea'].includes(settings.type.replace(" (首系列)", ""))) { // 兼容(首系列)后缀
396 options.scales = {
397 x: {
398 title: {
399 display: !!settings.xAxisLabel,
400 text: settings.xAxisLabel,
401 font: {
402 size: 14,
403 weight: 'bold'
404 },

Callers 1

createChartFunction · 0.85

Calls 1

isColorDarkFunction · 0.85

Tested by

no test coverage detected