VibeFox JS Charts — Demo
Inicio rápido
HTML puro
Columnas del plan, una línea de los valores reales con marcadores y su línea de promedio. Pase el cursor sobre el gráfico para ver el tooltip compartido, haga clic en una columna, haga clic en un elemento de la leyenda para ocultar una serie y use la rueda del ratón sobre el área de trazado para hacer zoom.
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Sales 2026',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', data: [8, 14, 11, 13, 17, 16], markers: true, stats: ['avg'] },
],
yAxis: { title: 'k EUR' },
on: { pointClick: (e) => chart.setOptions({ subtitle: 'Clicked: ' + e.series.name + ', ' + e.point }) },
});Conceptos básicos
Series y puntos
Puntos como números simples (con un hueco null el jueves), como pares [x, y] con nombres de categoría y como objetos con su propio label y color.
VibeFoxJSCharts.createChart('#app', {
categories: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
series: [
{ name: 'Numbers', type: 'column', data: [5, 7, 6, null, 8, 9, 4] },
{ name: 'Pairs', type: 'line', markers: true, data: [['Mon', 3], ['Wed', 5], ['Fri', 4], ['Sun', 7]] },
{ name: 'Objects', type: 'line', markers: true, data: [
{ y: 2 }, { y: 3 }, { y: 2.5 }, { y: 4 },
{ y: 10, label: 'Best day', color: '#dc2626' },
{ y: 6 }, { y: 5 },
] },
],
});Eventos
La línea debajo del gráfico muestra el último evento y su payload. Haga clic en un punto, haga clic en un elemento de la leyenda y arrastre sobre el área de trazado para hacer zoom.
const output = document.createElement('p');
document.getElementById('app').after(output);
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
series: [
{ name: 'Visitors', type: 'line', markers: true, data: [42, 45, 51, 49, 58, 63, 61, 67] },
{ name: 'Orders', type: 'column', data: [12, 14, 13, 17, 19, 18, 22, 24] },
],
});
output.textContent = 'Events appear here.';
chart.on('pointClick', (e) => { output.textContent = 'pointClick: ' + e.series.name + ', index ' + e.index + ', value ' + e.point; });
chart.on('seriesToggle', (e) => { output.textContent = 'seriesToggle: ' + e.id + ', hidden ' + e.hidden; });
chart.on('zoomChange', (e) => { output.textContent = 'zoomChange: ' + e.start.toFixed(2) + ' … ' + e.end.toFixed(2); });Instantáneas del estado
Haga zoom, oculte una serie y pulse Save state; después cambie la vista (o pulse Reset zoom) y pulse Restore state. El JSON guardado se muestra debajo del gráfico.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const output = document.createElement('p');
document.getElementById('app').after(output);
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
series: [
{ id: 'north', name: 'North', data: [5, 6, 7, 8, 7, 9, 10, 9, 11, 12, 11, 13] },
{ id: 'south', name: 'South', data: [3, 4, 2, 5, 6, 5, 7, 6, 8, 7, 9, 10] },
],
});
let saved = null;
addButton('Save state', () => { saved = chart.getState(); output.textContent = JSON.stringify(saved); });
addButton('Restore state', () => saved && chart.setState(saved));
addButton('Reset zoom', () => { chart.resetZoom(); chart.showSeries('north'); chart.showSeries('south'); });
chart.setZoom(0.25, 0.75);
chart.hideSeries('south');Tipos de series
Series cartesianas
Elija un gráfico de la lista: columnas apiladas con una línea objetivo, áreas, barras, dispersión y burbujas, un mapa de calor, una cascada, diagramas de caja, un histograma, rangos y un x-range (tareas en filas).
const charts = {
'Stacked columns and a line': {
categories: ['Q1', 'Q2', 'Q3', 'Q4'],
stacked: true,
series: [
{ name: 'North', type: 'column', data: [5, 6, 7, 8], borderRadius: 4 },
{ name: 'South', type: 'column', data: [3, 4, 2, 5], pattern: 'diagonal' },
{ name: 'Target', type: 'line', data: [9, 9, 10, 12], stack: false, dash: [6, 4], smooth: true },
],
},
'Area and step line': {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
series: [
{ name: 'Storage, TB', type: 'area', smooth: true, fillOpacity: 0.3, data: [12, 13, 15, 15, 17, 18, 20, 21] },
{ name: 'Plan, TB', type: 'line', step: true, data: [12, 12, 16, 16, 16, 20, 20, 24] },
],
},
'Bars': {
categories: ['Laptops', 'Phones', 'Tablets', 'Monitors', 'Printers'],
series: [{ name: 'Sales', type: 'bar', data: [1240, 980, 760, 640, 410], borderRadius: 3 }],
},
'Scatter and bubbles': {
xAxis: { title: 'Ad spend' }, yAxis: { title: 'Leads' },
tooltip: { shared: false },
series: [
{ name: 'Campaigns', type: 'scatter', data: [[12, 210], [18, 340], [25, 300], [31, 420], [40, 500], [44, 380], [52, 610]] },
{ name: 'Markets', type: 'bubble', data: [[20, 520, 30], [35, 250, 60], [48, 450, 20]] },
],
},
'Heatmap': {
xAxis: { categories: ['09:00', '11:00', '13:00', '15:00', '17:00'] },
yAxis: { categories: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
series: [{ name: 'Tickets', type: 'heatmap', showValues: true, cellGap: 2,
data: Array.from({ length: 25 }, (_, i) => [i % 5, Math.floor(i / 5), (i * 37) % 23 + 2]) }],
},
'Waterfall': {
categories: ['Start', 'Sales', 'Services', 'Salaries', 'Rent', 'Result'],
series: [{ name: 'Cash', type: 'waterfall', data: [120, 80, 35, -90, -30, { sum: 'total' }] }],
},
'Box plot': {
categories: ['Team A', 'Team B', 'Team C'],
series: [{ name: 'Response time', type: 'boxplot', showMean: true, data: [
[12, 18, 22, 27, 35],
{ values: [10, 14, 15, 15, 16, 18, 19, 21, 22, 40] },
[8, 11, 13, 16, 20],
] }],
},
'Histogram': {
series: [{ name: 'Order value', type: 'histogram', bins: 10,
data: Array.from({ length: 300 }, (_, i) => 50 + ((i * 7919) % 101) * 0.6 + ((i * 104729) % 61) * 0.7) }],
},
'Ranges': {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Temperature', type: 'rangeArea', data: [[-5, 3], [-3, 6], [1, 11], [5, 16], [9, 21], [13, 25]] },
{ name: 'Price', type: 'rangeColumn', data: [[2, 6], [3, 8], [4, 9], [6, 12], [7, 14], [9, 18]] },
],
},
'X-range': {
series: [{ name: 'Tasks', type: 'xrange', data: [
{ x: '2026-01-01', x2: '2026-01-12', y: 'Design', partialFill: 1 },
{ x: '2026-01-08', x2: '2026-01-28', y: 'Build', partialFill: 0.6 },
{ x: '2026-01-20', x2: '2026-02-05', y: 'Test', partialFill: 0.2 },
{ x: '2026-02-02', x2: '2026-02-10', y: 'Release' },
] }],
},
};
const picker = document.createElement('select');
for (const name of Object.keys(charts)) picker.add(new Option(name));
document.getElementById('app').before(picker);
let chart = null;
const show = (name) => {
chart?.destroy();
chart = VibeFoxJSCharts.createChart('#app', charts[name]);
};
picker.onchange = () => show(picker.value);
show(picker.value);Circular y otras series sin ejes
Elija un gráfico de la lista: un gráfico de anillo con un medidor, un gráfico circular (haga clic en un sector para sacarlo), radar, polar, barras radiales, un embudo con pirámide, un mapa de árbol, un sunburst y gráficos bullet.
const tree = [
{ name: 'Europe', children: [{ name: 'Germany', value: 84 }, { name: 'France', value: 68 }, { name: 'Italy', value: 59 }] },
{ name: 'Asia', children: [{ name: 'Japan', value: 124 }, { name: 'Korea', value: 52 }] },
{ name: 'Oceania', children: [{ name: 'Australia', value: 27 }, { name: 'New Zealand', value: 5 }] },
];
const charts = {
'Donut and gauge': { series: [
{ type: 'donut', name: 'Share', data: [{ name: 'Web', value: 55 }, { name: 'Store', value: 30 }, { name: 'Phone', value: 15 }],
showTotal: true, centerLabel: 'Orders' },
{ type: 'gauge', name: 'Load', data: [72], max: 100, bands: [{ from: 80, to: 100, color: '#dc2626' }] },
] },
'Pie': { series: [{ type: 'pie', name: 'Traffic', selectable: true, data: [
{ name: 'Direct', value: 24 }, { name: 'Search', value: 38 }, { name: 'Social', value: 18 }, { name: 'Email', value: 12 }, { name: 'Other', value: 8 },
] }] },
'Radar': {
categories: ['Speed', 'Quality', 'Price', 'Support', 'Design', 'Docs'],
series: [
{ name: 'Product A', type: 'radar', max: 100, data: [88, 92, 85, 78, 90, 70] },
{ name: 'Product B', type: 'radar', data: [80, 75, 90, 85, 70, 85] },
],
},
'Polar': {
categories: ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'],
series: [
{ name: 'Wind, days', type: 'polar', mode: 'column', data: [8, 5, 3, 4, 6, 9, 12, 10] },
{ name: 'Gusts', type: 'polar', mode: 'line', data: [4, 3, 2, 2, 3, 6, 8, 6] },
],
},
'Radial bars': { series: [{ type: 'radialBar', name: 'Goals', max: 100, rounded: true, data: [
{ name: 'Running', value: 82 }, { name: 'Swimming', value: 54 }, { name: 'Cycling', value: 67 },
] }] },
'Funnel and pyramid': { series: [
{ type: 'funnel', name: 'Sales funnel', data: [{ name: 'Visits', value: 1000 }, { name: 'Leads', value: 600 }, { name: 'Offers', value: 320 }, { name: 'Deals', value: 200 }] },
{ type: 'pyramid', name: 'Pyramid', data: [{ name: 'Base', value: 50 }, { name: 'Middle', value: 30 }, { name: 'Top', value: 10 }] },
] },
'Treemap': { series: [{ type: 'treemap', name: 'Population, M', data: tree }] },
'Sunburst': { series: [{ type: 'sunburst', name: 'Population, M', data: tree }] },
'Bullet': {
categories: ['Revenue', 'Profit', 'Orders'],
series: [{ type: 'bullet', name: 'KPI', data: [
{ y: 270, target: 250, ranges: [150, 225, 300] },
{ y: 180, target: 260, ranges: [150, 225, 300] },
{ y: 240, target: 230, ranges: [150, 225, 300] },
] }],
},
};
const picker = document.createElement('select');
for (const name of Object.keys(charts)) picker.add(new Option(name));
document.getElementById('app').before(picker);
let chart = null;
const show = (name) => {
chart?.destroy();
chart = VibeFoxJSCharts.createChart('#app', charts[name]);
};
picker.onchange = () => show(picker.value);
show(picker.value);Relaciones, texto y tiempo
Elija un gráfico de la lista: un diagrama de Sankey, un diagrama de cuerdas, una rueda de dependencias, un diagrama de arcos, una red (arrastre sus nodos), una nube de palabras, un diagrama de Venn y una línea de tiempo.
const links = [['Coal', 'Power', 40], ['Gas', 'Power', 25], ['Solar', 'Power', 15], ['Power', 'Homes', 35], ['Power', 'Industry', 30], ['Power', 'Losses', 15], ['Gas', 'Homes', 10]];
const charts = {
'Sankey': { series: [{ type: 'sankey', name: 'Energy', data: links, linkColor: 'mix' }] },
'Chord': { series: [{ type: 'chord', name: 'Trade', nodes: ['Europe', 'Asia', 'America', 'Africa'],
matrix: [[0, 5, 4, 2], [6, 0, 5, 1], [3, 4, 0, 1], [2, 1, 1, 0]] }] },
'Dependency wheel': { series: [{ type: 'dependencyWheel', name: 'Modules',
data: [['core', 'ui', 5], ['core', 'data', 4], ['data', 'ui', 3], ['ui', 'app', 6], ['data', 'app', 2], ['auth', 'app', 2], ['core', 'auth', 2]] }] },
'Arc': { series: [{ type: 'arc', name: 'Calls', data: [['A', 'B', 3], ['A', 'D', 2], ['B', 'C', 1], ['C', 'E', 4], ['A', 'E', 1], ['D', 'F', 2], ['B', 'F', 3]] }] },
'Network': { series: [{ type: 'network', name: 'Team', draggable: true,
nodes: [{ id: 'Ann', group: 'Web' }, { id: 'Bob', group: 'Web' }, { id: 'Cid', group: 'Data' }, { id: 'Dan', group: 'Data' }, { id: 'Eve', group: 'Ops' }, { id: 'Fay', group: 'Ops' }],
data: [['Ann', 'Bob'], ['Ann', 'Cid'], ['Bob', 'Cid'], ['Cid', 'Dan'], ['Dan', 'Eve'], ['Eve', 'Fay'], ['Fay', 'Dan'], ['Ann', 'Eve']] }] },
'Word cloud': { series: [{ type: 'wordcloud', name: 'Words', data: [
['charts', 20], ['data', 16], ['canvas', 12], ['zoom', 10], ['legend', 9], ['tooltip', 9], ['export', 8], ['maps', 8],
['series', 7], ['axes', 7], ['themes', 6], ['labels', 6], ['drilldown', 5], ['dashboard', 5], ['realtime', 4], ['webgl', 4], ['pdf', 3], ['svg', 3],
] }] },
'Venn': { series: [{ type: 'venn', name: 'Skills', data: [
{ sets: ['JavaScript'], value: 10 }, { sets: ['Design'], value: 7 }, { sets: ['Data'], value: 6 },
{ sets: ['JavaScript', 'Design'], value: 3 }, { sets: ['JavaScript', 'Data'], value: 2 }, { sets: ['Design', 'Data'], value: 1.5 },
] }] },
'Timeline': { series: [{ type: 'timeline', name: 'Milestones', data: [
{ x: '2026-01-10', name: 'Start', description: 'Kick-off' }, { x: '2026-03-01', name: 'Beta', description: 'First users' },
{ x: '2026-05-20', name: 'Release', description: 'Version 1.0' }, { x: '2026-09-01', name: 'Update', description: 'Version 1.1' },
] }] },
};
const picker = document.createElement('select');
for (const name of Object.keys(charts)) picker.add(new Option(name));
document.getElementById('app').before(picker);
let chart = null;
const show = (name) => {
chart?.destroy();
chart = VibeFoxJSCharts.createChart('#app', charts[name]);
};
picker.onchange = () => show(picker.value);
show(picker.value);Ejes
Un eje x de tiempo y dos ejes y: el precio a la izquierda y el volumen a la derecha, con su propio formato. Pulse Log scale para cambiar el eje izquierdo a escala logarítmica y volver.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const price = [10, 12, 11, 15, 18, 26, 31, 45, 52, 80, 95, 120];
const volume = [5000, 8000, 6500, 7000, 9000, 12000, 11000, 15000, 14000, 18000, 21000, 19000];
const month = (i) => '2026-' + String(i + 1).padStart(2, '0') + '-01';
const chart = VibeFoxJSCharts.createChart('#app', {
xAxis: { type: 'time' },
yAxis: [{ title: 'Price' }, { title: 'Volume', position: 'right', format: (v) => v / 1000 + 'k' }],
series: [
{ name: 'Price', markers: true, data: price.map((v, i) => [month(i), v]) },
{ name: 'Volume', type: 'column', yAxisIndex: 1, data: volume.map((v, i) => [month(i), v]) },
],
});
addButton('Log scale', () => chart.toggleLogScale(0));Etiquetas, tooltips, leyenda y anotaciones
Etiquetas de datos
Etiquetas con una plantilla fuera de las columnas y etiquetas de porcentaje de los sectores del gráfico circular. Pulse Labels on / off para mostrar u ocultar las etiquetas de las columnas.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const chart = VibeFoxJSCharts.createChart('#app', {
seriesLayout: 'row',
categories: ['North', 'South', 'East', 'West'],
series: [
{ name: 'Revenue', type: 'column', data: [42, 28, 35, 19],
dataLabels: { show: true, format: '{y} k', position: 'outside' } },
{ name: 'Share', type: 'pie', data: [{ name: 'North', value: 42 }, { name: 'South', value: 28 }, { name: 'East', value: 35 }, { name: 'West', value: 19 }],
dataLabels: { show: true, format: '{percent}' } },
],
});
addButton('Labels on / off', () => chart.toggleDataLabels());Tooltip y leyenda
Un solo tooltip compartido con crosshair y su propio formato; la leyenda, a la derecha. Pase el cursor sobre el área de trazado; al pasar el cursor sobre un elemento de la leyenda se resalta su serie, y al hacer clic en él se oculta la serie.
VibeFoxJSCharts.createChart('#app', {
title: 'Website traffic',
subtitle: 'Thousands of visits per month',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'],
legend: { position: 'right' },
tooltip: {
shared: true,
crosshair: 'xy',
format: ({ title, rows }) => '<b>' + title + '</b><br>' + rows.map((r) => r.name + ': ' + r.value + ' k').join('<br>'),
},
series: [
{ name: 'Search', type: 'line', smooth: true, data: [32, 35, 38, 36, 42, 45, 44, 48, 52] },
{ name: 'Social', type: 'line', smooth: true, data: [18, 22, 21, 26, 25, 30, 33, 31, 36] },
{ name: 'Direct', type: 'line', smooth: true, data: [12, 12, 14, 13, 15, 16, 15, 17, 18] },
],
});Anotaciones y líneas de estadísticas
Una línea objetivo, una banda sombreada de campaña, el mínimo y el máximo marcados de la serie real, y sus líneas de promedio y de tendencia (stats).
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13, 16, 17] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16, 15, 19], stats: ['avg', 'trend'] },
],
});
chart.addAnnotation({ id: 'goal', type: 'lineY', value: 15, text: 'Goal', dash: [4, 4] });
chart.addAnnotation({ type: 'rangeX', from: 'Mar', to: 'Apr', text: 'Campaign', opacity: 0.15 });
chart.annotateExtremes(1);Comparación fantasma
El contorno discontinuo corresponde a la semana pasada, conservada con snapshot() antes de establecer los datos nuevos. Pulse Next week para volver a comparar.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const weeks = [[42, 48, 51, 47, 55, 38, 30], [45, 52, 49, 53, 60, 41, 33], [40, 44, 47, 50, 52, 45, 39], [48, 55, 58, 54, 63, 47, 36]];
let week = 0;
const series = (w) => [{ id: 'visits', name: 'Visits, k', type: 'column', data: weeks[w] }];
const chart = VibeFoxJSCharts.createChart('#app', { categories: days, series: series(0) });
const next = () => {
week = (week + 1) % weeks.length;
chart.snapshot();
chart.setData(series(week));
};
addButton('Next week', next);
next();Zoom, navigator y selector de rango
Dos años de valores diarios con los botones del selector de rango y las fechas arriba, y el navigator y la barra de desplazamiento abajo. Pulse un botón de rango, arrastre la ventana en el navigator o arrastre sobre el área de trazado para hacer zoom.
const start = Date.UTC(2025, 0, 1);
const day = 24 * 3600 * 1000;
const data = Array.from({ length: 730 }, (_, i) =>
[start + i * day, Math.round(200 + i * 0.4 + Math.sin(i / 15) * 40 + Math.sin(i / 3) * 12)]);
const chart = VibeFoxJSCharts.createChart('#app', {
xAxis: { type: 'time' },
series: [{ name: 'Active users', type: 'area', fillOpacity: 0.2, data }],
navigator: { enabled: true },
scrollbar: { enabled: true },
rangeSelector: { enabled: true, selected: '6M' },
});Desglose
Haga clic en Europe: sus países se abren desde drilldown.series. Haga clic en America: el nivel se carga mediante drilldown.load (aquí, un stub con un breve retardo en lugar de un servidor). Las migas de pan permiten volver atrás.
VibeFoxJSCharts.createChart('#app', {
series: [{ id: 'regions', type: 'column', name: 'Regions',
data: [{ name: 'Europe', y: 30, drilldown: 'eu' }, { name: 'America', y: 20, drilldown: true }] }],
drilldown: {
series: [{ id: 'eu', type: 'column', name: 'Europe', data: [{ name: 'Germany', y: 12 }, { name: 'France', y: 18 }] }],
load: async (ctx) => {
await new Promise((resolve) => setTimeout(resolve, 300)); // your server request here
return { type: 'pie', name: ctx.point.name, data: [{ name: 'USA', value: 15 }, { name: 'Canada', value: 5 }] };
},
},
});Datos en tiempo real
Un punto nuevo cada medio segundo; la ventana conserva los últimos 120 puntos (realtime.maxPoints).
let t = Date.now() - 60 * 500;
let v = 50;
const next = () => {
t += 500;
v = Math.max(5, Math.min(95, v + (Math.random() - 0.5) * 12));
return [t, Math.round(v)];
};
const chart = VibeFoxJSCharts.createChart('#app', {
xAxis: { type: 'time' },
realtime: { maxPoints: 120 },
series: [{ id: 'cpu', name: 'CPU, %', type: 'area', fillOpacity: 0.25, data: Array.from({ length: 60 }, next) }],
});
setInterval(() => chart.appendData('cpu', [next()]), 500);Fuentes de datos
El gráfico lee la tabla HTML que está encima de él (dataSource.table con watch: true). Haga clic en un número de la tabla y cámbielo: el gráfico lo sigue.
const table = document.createElement('table');
table.id = 'sales';
table.contentEditable = 'true';
table.innerHTML = '<thead><tr><th>Month</th><th>North</th><th>South</th></tr></thead><tbody>'
+ '<tr><td>Jan</td><td>5</td><td>3</td></tr><tr><td>Feb</td><td>6</td><td>4</td></tr>'
+ '<tr><td>Mar</td><td>7</td><td>2</td></tr><tr><td>Apr</td><td>8</td><td>5</td></tr></tbody>';
document.getElementById('app').before(table);
VibeFoxJSCharts.createChart('#app', {
dataSource: { table: '#sales', watch: true, type: 'column', x: 'Month', y: ['North', 'South'] },
});Grandes volúmenes de datos
Una línea de 200 000 puntos dibujada mediante WebGL (largeData.webgl) y reducida por muestreo a la ventana visible; la línea debajo del gráfico es getRenderInfo(). Haga zoom con la rueda: aparece más detalle. La biblioteca maneja millones de puntos; la demo mantiene la página ligera.
const output = document.createElement('p');
document.getElementById('app').after(output);
const points = Array.from({ length: 200000 }, (_, i) =>
[i, Math.sin(i / 5000) * 100 + Math.sin(i / 300) * 20 + ((i * 7919) % 100) / 10]);
const chart = VibeFoxJSCharts.createChart('#app', {
series: [{ name: 'Signal', type: 'line', data: points }],
largeData: { webgl: true },
});
const info = () => {
const r = chart.getRenderInfo()[0];
output.textContent = r.points + ' points, ' + r.drawn + ' drawn, method ' + r.method + ', renderer ' + r.renderer;
};
chart.on('zoomChange', info);
info();Edición de puntos
Arrastre una columna hacia arriba o hacia abajo (pasos de 0,5 entre 0 y 10), o dé el foco al gráfico y use Shift+flechas. Undo y Redo (o Ctrl+Z / Ctrl+Y) recorren los arrastres.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const output = document.createElement('p');
document.getElementById('app').after(output);
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['A', 'B', 'C', 'D', 'E'],
yAxis: { min: 0, max: 10 },
series: [{ name: 'Budget', type: 'column', data: [5, 7, 3, 6, 4], draggable: { min: 0, max: 10, step: 0.5 } }],
});
chart.on('pointDrop', (e) => { output.textContent = 'New value of ' + chart.getOption('categories')[e.index] + ': ' + e.value.y; });
addButton('Undo', () => chart.undo());
addButton('Redo', () => chart.redo());Mapas
Un mapa coroplético de un país pequeño ficticio (su GeoJSON está en el código), con capitales como puntos y una ruta. Pase el cursor sobre una región, use la rueda para hacer zoom, arrastre para desplazar el mapa y haga doble clic para restablecerlo; Zoom to North llama a zoomToRegion().
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
// your GeoJSON (here: six made-up regions); TopoJSON works too
const T = [[0, 52], [4.2, 52.6], [8.1, 52.3], [12, 51.6]];
const M = [[-0.4, 48.2], [4.6, 47.7], [7.6, 48.5], [12.5, 48]];
const B = [[0.3, 44], [4, 43.6], [8.4, 44.2], [11.6, 44.5]];
const region = (id, name, low, high, i) => ({ type: 'Feature', id, properties: { name },
geometry: { type: 'Polygon', coordinates: [[low[i], low[i + 1], high[i + 1], high[i], low[i]]] } });
const geo = { type: 'FeatureCollection', features: [
region('NW', 'Northwest', M, T, 0), region('N', 'North', M, T, 1), region('NE', 'Northeast', M, T, 2),
region('SW', 'Southwest', B, M, 0), region('S', 'South', B, M, 1), region('SE', 'Southeast', B, M, 2),
] };
const chart = VibeFoxJSCharts.createChart('#app', {
map: { data: geo },
colorAxis: { type: 'sequential', steps: 5, title: 'Population (M)' },
series: [
{ type: 'map', name: 'Population', joinBy: 'id', data: [
{ id: 'NW', value: 4.2 }, { id: 'N', value: 9.8 }, { id: 'NE', value: 6.1 },
{ id: 'SW', value: 2.4 }, { id: 'S', value: 7.3 }, { id: 'SE', value: 3.5 },
] },
{ type: 'mappoint', name: 'Cities', data: [
{ name: 'Northport', lon: 6.2, lat: 50.4 }, { name: 'Southfield', lon: 6, lat: 46 }, { name: 'Eastbay', lon: 10.5, lat: 49.5 },
] },
{ type: 'mapline', name: 'Route', data: [{ from: [6.2, 50.4], to: [10.5, 49.5] }, { from: [6.2, 50.4], to: [6, 46] }] },
],
});
addButton('Zoom to North', () => chart.zoomToRegion(0, 'N'));
addButton('Reset', () => chart.resetMapView());Reglas adaptables
Mueva el control deslizante para cambiar el ancho del gráfico: por debajo de 500 px la leyenda pasa abajo, las etiquetas del eje x se giran y las etiquetas de datos se ocultan.
const output = document.createElement('p');
document.getElementById('app').after(output);
const app = document.getElementById('app');
const slider = document.createElement('input');
slider.type = 'range'; slider.min = 300; slider.max = 900; slider.value = 900;
app.before(slider);
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['January', 'February', 'March', 'April', 'May', 'June'],
legend: { position: 'right' },
dataLabels: true,
series: [
{ name: 'Laptops', type: 'column', data: [12, 15, 11, 18, 21, 19] },
{ name: 'Phones', type: 'column', data: [22, 19, 24, 27, 25, 30] },
],
responsive: { rules: [
{ condition: { maxWidth: 500 }, options: { legend: { position: 'bottom' }, xAxis: { labelRotation: 45 }, dataLabels: false } },
] },
});
chart.on('responsiveChange', (e) => { output.textContent = 'Width ' + Math.round(e.width) + ' px, rules active: ' + e.active.length; });
slider.oninput = () => { app.style.maxWidth = slider.value + 'px'; };Cuadros de mando
Mosaicos de KPI, dos gráficos y dos filtros a partir de una sola configuración. Haga clic en un sector del gráfico circular: el gráfico de columnas y los KPI muestran solo esa región (filtrado cruzado); cambie el filtro de producto.
const regions = ['North', 'South', 'East', 'West'];
const products = ['Laptops', 'Phones', 'Tablets'];
const data = [];
for (let m = 1; m <= 12; m++) {
for (let r = 0; r < regions.length; r++) {
for (let p = 0; p < products.length; p++) {
data.push({ date: '2026-' + String(m).padStart(2, '0') + '-15', region: regions[r], product: products[p],
amount: 50 + ((m * 37 + r * 53 + p * 71) % 90) + m * 4 });
}
}
}
const dash = VibeFoxJSCharts.createChartDashboard('#app', {
title: 'Sales 2026',
data,
kpis: [
{ id: 'total', title: 'Revenue', field: 'amount', aggregate: 'sum', format: { compact: true }, sparkline: { field: 'date', by: 'month' } },
{ id: 'avg', title: 'Average order', field: 'amount', aggregate: 'avg' },
{ id: 'count', title: 'Orders', field: 'amount', aggregate: 'count' },
],
charts: [
{ id: 'byRegion', title: 'By region', type: 'pie', x: 'region', y: 'amount', aggregate: 'sum' },
{ id: 'byMonth', title: 'By month', type: 'column', x: { field: 'date', by: 'month' }, y: 'amount', series: 'product', stacked: true },
],
filters: [
{ id: 'product', field: 'product', type: 'multiselect' },
{ id: 'region', field: 'region', type: 'select' },
],
layout: { breakpoints: { 0: 6 } }, // six columns at every width
});Exportación
Los botones descargan el gráfico como archivos PNG, SVG (vectoriales), PDF (vectorial), CSV y Excel, abren el diálogo de impresión o muestran los datos como una tabla accesible.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Sales 2026',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16] },
],
});
addButton('PNG', () => chart.exportPNG('sales.png'));
addButton('SVG', () => chart.exportSVG('sales.svg'));
addButton('PDF', () => chart.exportPDF('sales.pdf', { pageSize: 'A4', orientation: 'landscape' }));
addButton('CSV', () => chart.exportCSV('sales.csv'));
addButton('Excel', () => chart.exportXLSX('sales.xlsx', { sheets: 'series' }));
addButton('Print', () => chart.print());
addButton('Data table', () => chart.toggleDataView());Renderizado sin DOM
Aquí no hay componente de gráfico: renderToSVG() devolvió una cadena SVG (que se muestra como imagen); la misma llamada funciona en Node o en un worker. Pulse New data para volver a renderizarlo.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const img = document.createElement('img');
img.alt = 'Rendered chart';
document.getElementById('app').append(img);
let n = 0;
const render = () => {
n++;
const svg = VibeFoxJSCharts.renderToSVG({
title: 'Report ' + n,
categories: ['A', 'B', 'C', 'D', 'E'],
series: [{ name: 'Value', type: 'column', data: [3, 5, 2, 6, 4].map((v, i) => v + ((n * (i + 2)) % 4)) }],
}, { width: 600, height: 300, theme: 'light' });
img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
};
addButton('New data', render);
render();Texto a gráfico y explicaciones
Escriba una solicitud (o elija una predefinida) y pulse Make chart: textToChart() construye las opciones con reglas integradas, sin necesidad de modelo. El texto debajo del gráfico es explain().
const output = document.createElement('p');
document.getElementById('app').after(output);
const rows = [
{ month: 'Jan', region: 'North', product: 'Laptops', sales: 120 }, { month: 'Jan', region: 'South', product: 'Phones', sales: 80 },
{ month: 'Feb', region: 'North', product: 'Phones', sales: 150 }, { month: 'Feb', region: 'East', product: 'Tablets', sales: 60 },
{ month: 'Mar', region: 'South', product: 'Laptops', sales: 170 }, { month: 'Mar', region: 'West', product: 'Phones', sales: 90 },
{ month: 'Apr', region: 'East', product: 'Laptops', sales: 140 }, { month: 'Apr', region: 'West', product: 'Tablets', sales: 75 },
{ month: 'May', region: 'North', product: 'Tablets', sales: 110 }, { month: 'May', region: 'South', product: 'Phones', sales: 130 },
];
const input = document.createElement('input');
input.size = 40;
input.value = 'sales by region as pie';
input.setAttribute('list', 'requests');
const list = document.createElement('datalist');
list.id = 'requests';
for (const r of ['sales by region as pie', 'sales by month as line', 'sales by product as bar', 'sales by month and region stacked column']) list.append(new Option(r));
const button = document.createElement('button');
button.textContent = 'Make chart';
document.getElementById('app').before(input, list, button);
let chart = null;
const make = () => {
chart?.destroy();
chart = VibeFoxJSCharts.createChart('#app', VibeFoxJSCharts.textToChart(input.value, rows));
output.textContent = chart.explain();
};
button.onclick = make;
make();Temas y estilos
Temas
Elija un tema de la lista: claro, oscuro, de alto contraste y los temas del paquete vibefox-js-themes.css (ocean, sunset, glass-dark, paper, graphite-dark).
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Sales 2026',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16] },
{ name: 'Last year', type: 'line', dash: [6, 4], data: [7, 9, 10, 11, 12, 12] },
],
});
const picker = document.createElement('select');
for (const name of ['light', 'dark', 'high-contrast', 'ocean', 'sunset', 'glass-dark', 'paper', 'graphite-dark']) picker.add(new Option(name));
picker.onchange = () => chart.setTheme(picker.value);
document.getElementById('app').before(picker);Variables CSS
Solo se cambian las variables CSS de este gráfico: el color de acento y de las series, una fuente más grande, líneas de cuadrícula discontinuas y columnas redondeadas.
const app = document.getElementById('app');
app.style.cssText = '--vfjs-charts-font-size: 14px; --vfjs-charts-grid-dash: 4 3; --vfjs-charts-bar-radius: 6px;'
+ '--vfjs-charts-color-0: #0f766e; --vfjs-charts-color-1: #f59e0b; --vfjs-charts-title-fg: #0f766e;';
VibeFoxJSCharts.createChart('#app', {
title: 'Styled with CSS variables',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16] },
],
});Estilos listos para usar y paletas
Elija un estilo listo para usar (vivid, pastel, monochrome, dark, print) y una paleta (también las aptas para el daltonismo). Print y monochrome usan tramas, guiones y formas de marcador.
const chart = VibeFoxJSCharts.createChart('#app', {
categories: ['Q1', 'Q2', 'Q3', 'Q4'],
series: [
{ name: 'North', type: 'column', data: [5, 6, 7, 8] },
{ name: 'South', type: 'column', data: [3, 4, 2, 5] },
{ name: 'East', type: 'column', data: [4, 5, 6, 4] },
{ name: 'Target', type: 'line', markers: true, data: [6, 7, 8, 9] },
{ name: 'Last year', type: 'line', markers: true, data: [4, 4, 5, 6] },
],
});
const style = document.createElement('select');
const palette = document.createElement('select');
style.add(new Option('style: default', ''));
for (const name of VibeFoxJSCharts.CHART_STYLES) style.add(new Option('style: ' + name, name));
palette.add(new Option('palette: default', ''));
for (const name of VibeFoxJSCharts.CHART_PALETTES) palette.add(new Option('palette: ' + name, name));
style.onchange = () => chart.setStyle(style.value || null);
palette.onchange = () => chart.setPalette(palette.value || null);
document.getElementById('app').before(style, palette);Densidad y tamaño
Elija una densidad para el contenedor (data-vfjs-density) y una unidad de tamaño (--vfjs-size-unit): los textos, el padding y los marcadores se ajustan a ellas.
const app = document.getElementById('app');
app.style.height = '400px';
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Density',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16] },
],
});
const density = document.createElement('select');
for (const name of ['normal', 'compact', 'comfortable']) density.add(new Option('density: ' + name, name));
density.onchange = () => { app.dataset.vfjsDensity = density.value; };
const unit = document.createElement('select');
for (const px of ['1px', '0.8px', '1.25px']) unit.add(new Option('--vfjs-size-unit: ' + px, px));
unit.onchange = () => app.style.setProperty('--vfjs-size-unit', unit.value);
app.before(density, unit);Su propio CSS
Las reglas CSS normales de la página cambian el estilo de la leyenda y del título; tienen prioridad sobre la biblioteca sin !important, porque el CSS de la biblioteca está en @layer vfjs.
const css = document.createElement('style');
css.textContent = '.vfjs-chart-legend-item { font-weight: 600; text-transform: uppercase; }'
+ ' .vfjs-chart-header { text-align: start; border-bottom: 2px solid #0f766e; }';
document.head.append(css);
VibeFoxJSCharts.createChart('#app', {
title: 'My styled chart',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Plan', type: 'column', data: [10, 12, 9, 14, 15, 13] },
{ name: 'Fact', type: 'line', markers: true, data: [8, 14, 11, 13, 17, 16] },
],
});Localización y RTL
Idiomas
Cambie el idioma entre inglés y ruso (el paquete de idioma vibefox-js-charts.ru.js se carga después de la biblioteca): el selector de rango, las líneas de estadísticas, los nombres de los meses del eje de tiempo y el formato de números se adaptan.
const start = Date.UTC(2025, 0, 1);
const day = 24 * 3600 * 1000;
const chart = VibeFoxJSCharts.createChart('#app', {
locale: 'en',
xAxis: { type: 'time' },
rangeSelector: { enabled: true, selected: '6M' },
series: [{ name: 'Orders', type: 'line', stats: ['avg', 'min', 'max'],
data: Array.from({ length: 365 }, (_, i) => [start + i * day, Math.round(12000 + Math.sin(i / 20) * 3000 + i * 10)]) }],
});
const picker = document.createElement('select');
picker.add(new Option('English', 'en'));
picker.add(new Option('Русский', 'ru'));
picker.onchange = () => chart.setOptions({ locale: picker.value });
document.getElementById('app').before(picker);Añadir un idioma
Un diccionario alemán parcial añadido con addLocale(): el selector de rango y las líneas de estadísticas lo usan, los nombres de los meses proceden del navegador y el resto recurre al inglés.
VibeFoxJSCharts.addLocale('de', {
chartRangeAll: 'Alle',
chartRangeAllTitle: 'Alle Daten',
chartRangeFrom: 'Von',
chartRangeTo: 'Bis',
chartRangeShortM: 'M',
chartRangeShortY: 'J',
chartStatAvg: 'Durchschnitt',
chartStatMin: 'Minimum',
chartStatMax: 'Maximum',
});
const start = Date.UTC(2025, 0, 1);
const day = 24 * 3600 * 1000;
VibeFoxJSCharts.createChart('#app', {
locale: 'de',
xAxis: { type: 'time' },
rangeSelector: { enabled: true, selected: '6M' },
series: [{ name: 'Bestellungen', type: 'line', stats: ['avg', 'min', 'max'],
data: Array.from({ length: 365 }, (_, i) => [start + i * day, Math.round(12000 + Math.sin(i / 20) * 3000 + i * 10)]) }],
});Derecha a izquierda (RTL)
La opción rtl: true: el título, la leyenda y el tooltip siguen la dirección de derecha a izquierda; el área de trazado mantiene el crecimiento del eje x hacia la derecha.
VibeFoxJSCharts.createChart('#app', {
rtl: true,
title: 'المبيعات',
subtitle: 'Sales by quarter',
categories: ['Q1', 'Q2', 'Q3', 'Q4'],
series: [
{ name: 'الشمال', type: 'column', data: [5, 6, 7, 8] },
{ name: 'الجنوب', type: 'column', data: [3, 4, 2, 5] },
],
});Accesibilidad
Teclado
El tercer punto recibe el foco desde el código (focusPoint()). Haga clic en el gráfico (o llegue a él con Tab) y use las teclas de flecha, Home / End, + / − para hacer zoom, Enter para hacer clic en un punto.
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Use the keyboard',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
series: [
{ name: 'Visitors', type: 'line', markers: true, data: [42, 45, 51, 49, 58, 63, 61, 67] },
{ name: 'Orders', type: 'line', markers: true, data: [12, 14, 13, 17, 19, 18, 22, 24] },
],
});
chart.focusPoint(0, 2, { focus: false });Lectores de pantalla
El texto debajo del gráfico es getSummary(), la descripción que reciben los lectores de pantalla. Speak summary lo anuncia a un lector de pantalla; Data table muestra los datos como una tabla HTML accesible.
function addButton(text, onClick) {
const b = document.createElement('button');
b.textContent = text;
b.onclick = onClick;
document.getElementById('app').before(b);
}
const output = document.createElement('p');
document.getElementById('app').after(output);
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Revenue and costs',
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{ name: 'Revenue', type: 'column', data: [120, 135, 128, 150, 162, 171] },
{ name: 'Costs', type: 'line', markers: true, data: [90, 95, 99, 101, 108, 110] },
],
});
output.textContent = chart.getSummary();
addButton('Speak summary', () => chart.announceSummary());
addButton('Data table', () => chart.toggleDataView());Uso con otras bibliotecas de VibeFox JS
Conexión de componentes con link()
Dos gráficos unidos con link(): haga zoom en el gráfico superior (arrastre sobre su área de trazado o use su navigator) y el gráfico inferior muestra el mismo rango.
const app = document.getElementById('app');
const upper = document.createElement('div');
const lower = document.createElement('div');
upper.style.height = '260px';
lower.style.height = '200px';
app.append(upper, lower);
const start = Date.UTC(2026, 0, 1);
const day = 24 * 3600 * 1000;
const days = Array.from({ length: 180 }, (_, i) => start + i * day);
const overview = VibeFoxJSCharts.createChart(upper, {
title: 'Price', xAxis: { type: 'time' }, navigator: { enabled: true },
series: [{ name: 'Price', type: 'line', data: days.map((t, i) => [t, Math.round(100 + i * 0.3 + Math.sin(i / 9) * 12)]) }],
});
const detail = VibeFoxJSCharts.createChart(lower, {
title: 'Volume', xAxis: { type: 'time' }, zoom: { enabled: false },
series: [{ name: 'Volume', type: 'column', data: days.map((t, i) => [t, 500 + ((i * 7919) % 400)]) }],
});
VibeFoxJSCharts.link(overview, 'zoomChange', detail, 'setXRange');
overview.setZoom(0.5, 0.8);Herramientas de IA
Escriba una solicitud como "show as bar", "pie" o "title Revenue 2026" y pulse Ask. La función model aquí es un stub pequeño que responde con una llamada a herramienta; en su aplicación envía la solicitud a su modelo. El registro muestra las llamadas a herramientas.
const output = document.createElement('p');
document.getElementById('app').after(output);
const chart = VibeFoxJSCharts.createChart('#app', {
title: 'Sales',
categories: ['North', 'South', 'East', 'West'],
series: [{ name: 'Sales', type: 'column', data: [42, 28, 35, 19] }],
});
const kit = VibeFoxJSCharts.createToolKit({ sales: chart });
// stub of your model: reads the last user message and answers with a tool call or a text
async function model(request) {
const last = request.messages[request.messages.length - 1];
if (last.role === 'tool') return { text: 'Done.' };
const text = last.content.toLowerCase();
const type = ['bar', 'pie', 'line', 'area', 'column', 'donut'].find((t) => text.includes(t));
const title = text.startsWith('title ') ? last.content.slice(6) : null;
if (title) return { toolCalls: [{ name: 'sales_chart_set_options', arguments: { title } }] };
if (type) {
const values = [42, 28, 35, 19];
const data = type === 'pie' || type === 'donut' ? ['North', 'South', 'East', 'West'].map((name, i) => ({ name, value: values[i] })) : values;
return { toolCalls: [{ name: 'sales_chart_set_options', arguments: { series: [{ name: 'Sales', type, data }] } }] };
}
return { toolCalls: [{ name: 'sales_chart_explain', arguments: {} }] };
}
const input = document.createElement('input');
input.size = 30;
input.value = 'show as bar';
const button = document.createElement('button');
button.textContent = 'Ask';
document.getElementById('app').before(input, button);
output.textContent = 'Tools: ' + kit.describe().map((t) => t.name).join(', ');
button.onclick = async () => {
const answer = await kit.ask(input.value, { model });
output.textContent = answer.calls.map((c) => c.name + ' ' + JSON.stringify(c.args) + ' → ' + JSON.stringify(c.result)).join('; ') || answer.text;
};