github.com/shoshinnikita/budget-manager@v0.7.1-0.20220131195411-8c46ff1c6778/static/js/chart.js (about)

     1  // Update global Chart.js options
     2  (function () {
     3  	const global = Chart.defaults;
     4  	const plugins = global.plugins;
     5  
     6  	// Hide legend
     7  	plugins.legend.display = false;
     8  	// Disable animations
     9  	global.animation.duration = 0;
    10  	// Tune tooltips
    11  	plugins.tooltip.animation.duration = 200;
    12  	plugins.tooltip.titleFontSize = 15;
    13  	plugins.tooltip.backgroundColor = "#000000d0";
    14  	plugins.tooltip.cornerRadius = 5;
    15  	// Other
    16  	global.font.size = 14;
    17  	global.maintainAspectRatio = false;
    18  	// Tune scale
    19  	const scale = Chart.defaults.scale;
    20  	scale.ticks.beginAtZero = true;
    21  	scale.grid.color = getGridLinesColor();
    22  
    23  	// Register custom formatter for money
    24  	Chart.Ticks.formatters.money = formatMoney;
    25  })();
    26  
    27  function getGridLinesColor() {
    28  	return isDarkTheme() ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)";
    29  }
    30  
    31  const formatter = new Intl.NumberFormat("en-US");
    32  const thinSpace = " ";
    33  
    34  function formatMoney(value, index, values) {
    35  	return formatter.format(value).replace(",", thinSpace);
    36  };