VibeFox JS Charts — डेमो
त्वरित शुरुआत
सादा HTML
प्लान के कॉलम, मार्करों वाली फ़ैक्ट-रेखा और उसकी औसत रेखा। साझा टूलटिप के लिए चार्ट पर होवर करें, कॉलम पर क्लिक करें, किसी सीरीज़ को छिपाने के लिए लीजेंड आइटम पर क्लिक करें, प्लॉट पर माउस व्हील घुमाकर ज़ूम करें।
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 }) },
});मूल अवधारणाएँ
सीरीज़ और बिंदु
बिंदु सादी संख्याओं के रूप में (गुरुवार पर null अंतराल के साथ), श्रेणी नामों वाले [x, y] जोड़ों के रूप में, और अपने label व 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 },
] },
],
});इवेंट
चार्ट के नीचे की पंक्ति आख़िरी इवेंट और उसका पेलोड दिखाती है। बिंदु पर क्लिक करें, लीजेंड आइटम पर क्लिक करें, ज़ूम के लिए प्लॉट पर खींचें।
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); });स्थिति के स्नैपशॉट
ज़ूम इन करें, किसी सीरीज़ को छिपाएँ और Save state दबाएँ; फिर व्यू बदलें (या Reset zoom दबाएँ) और Restore state दबाएँ। सहेजा गया JSON चार्ट के नीचे दिखाया जाता है।
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');सीरीज़ प्रकार
कार्टेज़ियन सीरीज़
सूची से कोई चार्ट चुनें: टार्गेट लाइन वाले स्टैक्ड कॉलम, एरिया, बार, स्कैटर और बबल, हीटमैप, वाटरफ़ॉल, बॉक्स प्लॉट, हिस्टोग्राम, रेंज और x-रेंज (पंक्तियों पर कार्य)।
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);पाई और अक्ष के बिना अन्य सीरीज़
सूची से कोई चार्ट चुनें: गेज वाला डोनट, पाई (स्लाइस पर क्लिक करके उसे बाहर खींचें), रडार, पोलर, रेडियल बार, पिरामिड वाला फ़नल, ट्रीमैप, सनबर्स्ट और बुलेट चार्ट।
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);संबंध, टेक्स्ट और समय
सूची से कोई चार्ट चुनें: सैंकी आरेख, कॉर्ड आरेख, डिपेंडेंसी व्हील, आर्क आरेख, नेटवर्क (उसके नोड खींचें), वर्ड क्लाउड, वेन आरेख और टाइमलाइन।
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);अक्ष
समय वाला x-अक्ष और दो y-अक्ष: बाईं ओर कीमत, दाईं ओर वॉल्यूम, जिसका अपना फ़ॉर्मैट है। बाएँ अक्ष को लॉगरिदमिक पैमाने पर बदलने और वापस लाने के लिए Log scale दबाएँ।
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));लेबल, टूलटिप, लीजेंड और एनोटेशन
डेटा लेबल
कॉलमों के बाहर टेम्पलेट वाले लेबल और पाई स्लाइस के प्रतिशत लेबल। कॉलम लेबल चालू या बंद करने के लिए Labels on / off दबाएँ।
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());टूलटिप और लीजेंड
क्रॉसहेयर और अपने फ़ॉर्मैट वाला एक साझा टूलटिप, दाईं ओर लीजेंड। प्लॉट पर होवर करें; किसी सीरीज़ को हाइलाइट करने के लिए लीजेंड आइटम पर होवर करें, उसे छिपाने के लिए क्लिक करें।
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] },
],
});एनोटेशन और आँकड़ों की रेखाएँ
एक लक्ष्य रेखा, छायांकित कैंपेन पट्टी, फ़ैक्ट सीरीज़ का चिह्नित न्यूनतम और अधिकतम, तथा उसकी औसत और ट्रेंड रेखाएँ (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);घोस्ट तुलना
डैश वाली रूपरेखा पिछला सप्ताह है, जिसे नया डेटा सेट करने से पहले snapshot() से सहेजा गया था। फिर से तुलना के लिए Next week दबाएँ।
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();ज़ूम, नेविगेटर और रेंज सेलेक्टर
दो साल के दैनिक मान, ऊपर रेंज सेलेक्टर के बटन और तारीख़ें, नीचे नेविगेटर और स्क्रॉलबार। कोई रेंज बटन दबाएँ, नेविगेटर में विंडो खींचें, या ज़ूम के लिए प्लॉट पर खींचें।
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' },
});ड्रिलडाउन
यूरोप पर क्लिक करें: उसके देश drilldown.series से खुलते हैं। अमेरिका पर क्लिक करें: यह स्तर drilldown.load से लोड होता है (यहाँ सर्वर की जगह थोड़ी देरी वाला स्टब है)। ब्रेडक्रम्ब्स वापस ले जाते हैं।
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 }] };
},
},
});रीयल-टाइम डेटा
हर आधे सेकंड में एक नया बिंदु; विंडो आख़िरी 120 बिंदु रखती है (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);डेटा स्रोत
चार्ट अपने ऊपर मौजूद HTML टेबल को पढ़ता है (dataSource.table, watch: true के साथ)। टेबल में किसी संख्या पर क्लिक करके उसे बदलें: चार्ट भी बदल जाता है।
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'] },
});बड़ा डेटा
2,00,000 बिंदुओं वाली एक लाइन WebGL (largeData.webgl) से बनाई जाती है और दृश्यमान विंडो के हिसाब से डाउनसैंपल की जाती है; चार्ट के नीचे की लाइन getRenderInfo() है। माउस व्हील से ज़ूम इन करें: अधिक विवरण दिखता है। लाइब्रेरी लाखों बिंदु संभाल सकती है; डेमो पेज को हल्का रखता है।
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();बिंदुओं का संपादन
कॉलम को ऊपर या नीचे खींचें (0 और 10 के बीच 0.5 के चरणों में), या चार्ट पर फ़ोकस करके Shift+तीर कुंजियों का उपयोग करें। Undo और Redo (या Ctrl+Z / Ctrl+Y) खींचने की क्रियाओं के बीच आगे-पीछे ले जाते हैं।
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());मानचित्र
एक छोटे, काल्पनिक देश का कोरोप्लेथ मानचित्र (उसका GeoJSON कोड में है), जिसमें राजधानियाँ बिंदुओं के रूप में और एक मार्ग दिखाए गए हैं। किसी क्षेत्र पर होवर करें, ज़ूम के लिए स्क्रॉल करें, पैन करने के लिए खींचें, रीसेट करने के लिए डबल-क्लिक करें; Zoom to North 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());रिस्पॉन्सिव नियम
स्लाइडर खिसकाकर चार्ट की चौड़ाई बदलें: 500 px से कम पर लीजेंड नीचे चला जाता है, x लेबल घूम जाते हैं और डेटा लेबल छिप जाते हैं।
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'; };डैशबोर्ड
एक ही कॉन्फ़िगरेशन से KPI टाइलें, दो चार्ट और दो फ़िल्टर। पाई के किसी स्लाइस पर क्लिक करें: कॉलम चार्ट और KPI केवल उस क्षेत्र को दिखाते हैं (क्रॉस-फ़िल्टरिंग); प्रोडक्ट फ़िल्टर बदलें।
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
});निर्यात
बटन चार्ट को PNG, SVG (वेक्टर), PDF (वेक्टर), CSV और Excel फ़ाइलों के रूप में डाउनलोड करते हैं, प्रिंट डायलॉग खोलते हैं, या डेटा को एक्सेसिबल टेबल के रूप में दिखाते हैं।
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());DOM के बिना रेंडरिंग
यहाँ कोई चार्ट कॉम्पोनेंट नहीं है: renderToSVG() ने SVG स्ट्रिंग लौटाई (जिसे छवि के रूप में दिखाया गया है); वही कॉल Node या वर्कर में भी चलती है। फिर से रेंडर करने के लिए New data दबाएँ।
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();टेक्स्ट से चार्ट और व्याख्याएँ
अनुरोध लिखें (या सूची से कोई चुनें) और Make chart दबाएँ: textToChart() अंतर्निर्मित नियमों से विकल्प बनाता है, किसी मॉडल की ज़रूरत नहीं। चार्ट के नीचे का टेक्स्ट 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();थीम और स्टाइलिंग
थीम
सूची से कोई थीम चुनें: लाइट, डार्क, हाई-कॉन्ट्रास्ट और 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);CSS वेरिएबल
केवल इस चार्ट के CSS वेरिएबल बदले जाते हैं: एक्सेंट और सीरीज़ के रंग, बड़ा फ़ॉन्ट, डैश वाली ग्रिड रेखाएँ और गोल कॉलम।
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] },
],
});तैयार स्टाइल और पैलेट
कोई तैयार स्टाइल चुनें (vivid, pastel, monochrome, dark, print) और कोई पैलेट (रंग-अंधता के लिए सुरक्षित पैलेट भी)। print और monochrome में हैच, डैश और मार्कर के आकार इस्तेमाल होते हैं।
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);घनत्व और आकार
कंटेनर का घनत्व (data-vfjs-density) और आकार की इकाई (--vfjs-size-unit) चुनें: टेक्स्ट, पैडिंग और मार्कर उसी के अनुसार बदलते हैं।
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);आपका अपना CSS
पेज के सादे CSS नियम लीजेंड और शीर्षक की स्टाइल बदल देते हैं; लाइब्रेरी का CSS @layer vfjs में होने के कारण वे !important के बिना ही लाइब्रेरी पर भारी पड़ते हैं।
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] },
],
});स्थानीयकरण और RTL
भाषाएँ
भाषा को अंग्रेज़ी और रूसी के बीच बदलें (भाषा पैक vibefox-js-charts.ru.js लाइब्रेरी के बाद लोड होता है): रेंज सेलेक्टर, आँकड़ों की रेखाएँ, समय-अक्ष के महीनों के नाम और संख्या का फ़ॉर्मैट उसी के अनुसार बदलते हैं।
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);नई भाषा जोड़ना
addLocale() से जर्मन भाषा का आंशिक शब्दकोश जोड़ा गया है: रेंज सेलेक्टर और आँकड़ों की रेखाएँ उसका उपयोग करती हैं, महीनों के नाम ब्राउज़र से आते हैं, बाकी के लिए अंग्रेज़ी पर वापस जाया जाता है।
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)]) }],
});राइट-टू-लेफ़्ट
विकल्प rtl: true: शीर्षक, लीजेंड और टूलटिप राइट-टू-लेफ़्ट दिशा का पालन करते हैं; प्लॉट में x-मान दाईं ओर बढ़ते रहते हैं।
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] },
],
});एक्सेसिबिलिटी
कीबोर्ड
तीसरा बिंदु कोड से फ़ोकस किया गया है (focusPoint())। चार्ट पर क्लिक करें (या Tab से वहाँ जाएँ) और तीर कुंजियों, Home / End, ज़ूम के लिए + / − और बिंदु पर क्लिक के लिए Enter का उपयोग करें।
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 });स्क्रीन रीडर
चार्ट के नीचे का टेक्स्ट getSummary() है, वह विवरण जो स्क्रीन रीडर को मिलता है। Speak summary उसे स्क्रीन रीडर को सुनाता है; Data table डेटा को एक्सेसिबल HTML टेबल के रूप में दिखाता है।
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());अन्य VibeFox JS लाइब्रेरी के साथ उपयोग
link() से कॉम्पोनेंट्स को जोड़ना
link() से जुड़े दो चार्ट: ऊपर वाले चार्ट को ज़ूम करें (उसके प्लॉट पर खींचकर या उसके नेविगेटर से) और नीचे वाला चार्ट वही रेंज दिखाता है।
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);AI टूल
"show as bar", "pie" या "title Revenue 2026" जैसा अनुरोध लिखें और Ask दबाएँ। यहाँ model फ़ंक्शन एक छोटा स्टब है, जो टूल कॉल से उत्तर देता है; आपके एप्लिकेशन में वह अनुरोध आपके मॉडल को भेजता है। लॉग में टूल कॉल दिखते हैं।
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;
};