Copy this code to implement the chart in your project:
+
+
+
@@ -154,12 +164,16 @@
autoFitWidth: true, // Automatically adjust font size to fit container width
useBinMode: true, // Start in time bin mode
binDuration: 4000, // 4 seconds
- xAxisLabelFormat: 'elapsed'
+ xAxisLabelFormat: 'elapsed',
+ debug: false // Debug mode disabled by default
});
// Initial render
chart.render();
chart.updateInfo();
+
+ // Generate initial code example
+ generateCodeExample();
// Test data generator (separate from chart API)
class DataGenerator {
@@ -300,6 +314,13 @@
}
}
+ // Function to toggle debug mode
+ function toggleDebugMode() {
+ const debugMode = document.getElementById('debug-mode').checked;
+ // Note: Debug mode requires recreating the chart to take effect
+ // This is a limitation since debug mode is set at construction time
+ }
+
// Function to manually rotate bin
function rotateBin() {
if (chart && chart.useBinMode) {
@@ -307,6 +328,48 @@
}
}
+ // Function to generate code example
+ function generateCodeExample() {
+ const maxColumns = parseInt(document.getElementById('max-columns').value);
+ const chartHeight = parseInt(document.getElementById('chart-height').value);
+ const useBinMode = document.getElementById('use-bin-mode').checked;
+ const binDuration = parseFloat(document.getElementById('bin-duration').value);
+ const xAxisLabelFormat = document.getElementById('x-axis-format').value;
+ const debugMode = document.getElementById('debug-mode').checked;
+
+ let code = '// Include the ASCII Bar Chart library\n';
+ code += '