Chartjs Quickref
by sjnims
This skill should be used when the user asks "Chart.js cheat sheet", "Chart.js quick reference", "Chart.js snippets", "common Chart.js patterns", "Chart.js copy paste", "Chart.js quick tips", "Chart.js one-liners", "quick Chart.js examples", "Chart.js recipes", or needs copy-paste ready code snippets for common Chart.js v4.5.1 patterns without deep documentation.
Skill Details
Repository Files
1 file in this skill directory
name: chartjs-quickref description: This skill should be used when the user asks "Chart.js cheat sheet", "Chart.js quick reference", "Chart.js snippets", "common Chart.js patterns", "Chart.js copy paste", "Chart.js quick tips", "Chart.js one-liners", "quick Chart.js examples", "Chart.js recipes", or needs copy-paste ready code snippets for common Chart.js v4.5.1 patterns without deep documentation.
Chart.js Quick Reference (v4.5.1)
Copy-paste snippets for common Chart.js patterns.
Data Formatting
Currency Labels
ticks: {
callback: (value) => '$' + value.toLocaleString()
}
Percentage Labels
ticks: {
callback: (value) => value + '%'
}
Abbreviated Numbers (1K, 1M)
ticks: {
callback: (value) => {
if (value >= 1000000) return (value / 1000000).toFixed(1) + 'M';
if (value >= 1000) return (value / 1000).toFixed(1) + 'K';
return value;
}
}
Date/Time Labels
// Requires: import 'chartjs-adapter-date-fns'; (or luxon, moment)
scales: {
x: {
type: 'time',
time: {
unit: 'day',
displayFormats: { day: 'MMM d' }
}
}
}
Common Configurations
Hide Legend
plugins: { legend: { display: false } }
Hide Tooltip
plugins: { tooltip: { enabled: false } }
Hide Title
plugins: { title: { display: false } }
Start Y-axis at Zero
scales: { y: { beginAtZero: true } }
Set Axis Range
scales: { y: { min: 0, max: 100 } }
Horizontal Bar Chart
type: 'bar',
options: { indexAxis: 'y' }
Disable Animation
animation: false
Stacked Bar/Line Chart
scales: {
x: { stacked: true },
y: { stacked: true }
}
Styling
Chart.js Default Palette
const colors = [
'rgb(255, 99, 132)', // red
'rgb(54, 162, 235)', // blue
'rgb(255, 206, 86)', // yellow
'rgb(75, 192, 192)', // teal
'rgb(153, 102, 255)', // purple
'rgb(255, 159, 64)' // orange
];
Semi-Transparent Backgrounds
backgroundColor: 'rgba(54, 162, 235, 0.5)',
borderColor: 'rgb(54, 162, 235)'
Hide Grid Lines
scales: {
x: { grid: { display: false } },
y: { grid: { display: false } }
}
Custom Font
Chart.defaults.font.family = "'Inter', sans-serif";
Chart.defaults.font.size = 14;
Responsiveness
Fill Container
options: {
responsive: true,
maintainAspectRatio: false
}
<div style="height: 400px;">
<canvas id="myChart"></canvas>
</div>
Fixed Aspect Ratio
options: {
responsive: true,
aspectRatio: 2 // width:height = 2:1
}
Square Chart
options: { aspectRatio: 1 }
Dynamic Updates
Update Data
chart.data.datasets[0].data = [1, 2, 3, 4, 5];
chart.update();
Update Without Animation
chart.update('none');
Add Data Point
chart.data.labels.push('New Label');
chart.data.datasets[0].data.push(42);
chart.update();
Remove Data Point
chart.data.labels.pop();
chart.data.datasets[0].data.pop();
chart.update();
Destroy Chart
chart.destroy();
Event Handling
Click Handler
options: {
onClick: (event, elements) => {
if (elements.length > 0) {
const index = elements[0].index;
console.log('Clicked:', chart.data.labels[index]);
}
}
}
Export as Image
const imageUrl = chart.toBase64Image();
Tree-Shaking Imports
Bar Chart
import { Chart, BarController, BarElement, CategoryScale, LinearScale } from 'chart.js';
Chart.register(BarController, BarElement, CategoryScale, LinearScale);
Line Chart
import { Chart, LineController, LineElement, PointElement, CategoryScale, LinearScale } from 'chart.js';
Chart.register(LineController, LineElement, PointElement, CategoryScale, LinearScale);
Pie/Doughnut Chart
import { Chart, PieController, ArcElement, Legend, Tooltip } from 'chart.js';
Chart.register(PieController, ArcElement, Legend, Tooltip);
// Use DoughnutController for doughnut charts
With Legend and Tooltip
import { Legend, Tooltip } from 'chart.js';
Chart.register(Legend, Tooltip);
Quick Start Templates
Minimal Bar Chart
new Chart(ctx, {
type: 'bar',
data: {
labels: ['A', 'B', 'C'],
datasets: [{ data: [10, 20, 30] }]
}
});
Minimal Line Chart
new Chart(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar'],
datasets: [{ data: [10, 20, 15] }]
}
});
Minimal Pie Chart
new Chart(ctx, {
type: 'pie',
data: {
labels: ['Red', 'Blue', 'Yellow'],
datasets: [{ data: [30, 50, 20] }]
}
});
Related Skills
Team Composition Analysis
This skill should be used when the user asks to "plan team structure", "determine hiring needs", "design org chart", "calculate compensation", "plan equity allocation", or requests organizational design and headcount planning for a startup.
Startup Financial Modeling
This skill should be used when the user asks to "create financial projections", "build a financial model", "forecast revenue", "calculate burn rate", "estimate runway", "model cash flow", or requests 3-5 year financial planning for a startup.
Dbt Transformation Patterns
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.
Startup Metrics Framework
This skill should be used when the user asks about "key startup metrics", "SaaS metrics", "CAC and LTV", "unit economics", "burn multiple", "rule of 40", "marketplace metrics", or requests guidance on tracking and optimizing business performance metrics.
Market Sizing Analysis
This skill should be used when the user asks to "calculate TAM", "determine SAM", "estimate SOM", "size the market", "calculate market opportunity", "what's the total addressable market", or requests market sizing analysis for a startup or business opportunity.
Clinical Decision Support
Generate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug develo
Anndata
This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.
Geopandas
Python library for working with geospatial vector data including shapefiles, GeoJSON, and GeoPackage files. Use when working with geographic data for spatial analysis, geometric operations, coordinate transformations, spatial joins, overlay operations, choropleth mapping, or any task involving reading/writing/analyzing vector geographic data. Supports PostGIS databases, interactive maps, and integration with matplotlib/folium/cartopy. Use for tasks like buffer analysis, spatial joins between dat
Market Research Reports
Generate comprehensive market research reports (50+ pages) in the style of top consulting firms (McKinsey, BCG, Gartner). Features professional LaTeX formatting, extensive visual generation with scientific-schematics and generate-image, deep integration with research-lookup for data gathering, and multi-framework strategic analysis including Porter's Five Forces, PESTLE, SWOT, TAM/SAM/SOM, and BCG Matrix.
Plotly
Interactive scientific and statistical data visualization library for Python. Use when creating charts, plots, or visualizations including scatter plots, line charts, bar charts, heatmaps, 3D plots, geographic maps, statistical distributions, financial charts, and dashboards. Supports both quick visualizations (Plotly Express) and fine-grained customization (graph objects). Outputs interactive HTML or static images (PNG, PDF, SVG).
