UNPKG

@ooples/token-optimizer-mcp

Version:

Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters

369 lines 10 kB
/** * DataVisualizer - Advanced data visualization with multiple chart types and interactive features * Track 2E - Tool #8 * * Target: 1,620 lines, 91% token reduction * Operations: 8 (create-chart, update-chart, export-chart, create-heatmap, create-timeline, create-network-graph, create-sankey, animate) */ import { CacheEngine } from '../../core/cache-engine.js'; import { TokenCounter } from '../../core/token-counter.js'; import { MetricsCollector } from '../../core/metrics.js'; export interface DataVisualizerOptions { operation: 'create-chart' | 'update-chart' | 'export-chart' | 'create-heatmap' | 'create-timeline' | 'create-network-graph' | 'create-sankey' | 'animate'; chartId?: string; chartName?: string; data?: any[]; dataFormat?: 'json' | 'csv' | 'array'; chartType?: 'line' | 'bar' | 'pie' | 'scatter' | 'area' | 'radar' | 'bubble' | 'candlestick' | 'waterfall' | 'funnel'; chartConfig?: { title?: string; subtitle?: string; xAxis?: AxisConfig; yAxis?: AxisConfig; series?: SeriesConfig[]; legend?: LegendConfig; tooltip?: TooltipConfig; colors?: string[]; theme?: 'light' | 'dark' | 'custom'; responsive?: boolean; animations?: boolean; }; heatmapConfig?: { xLabels: string[]; yLabels: string[]; values: number[][]; colorScale?: 'linear' | 'logarithmic' | 'threshold'; colors?: { min: string; mid?: string; max: string; }; }; timelineConfig?: { events: Array<{ time: number; label: string; description?: string; category?: string; }>; groupBy?: string; showMarkers?: boolean; }; networkConfig?: { nodes: Array<{ id: string; label?: string; group?: string; }>; edges: Array<{ source: string; target: string; weight?: number; }>; layout?: 'force' | 'circular' | 'hierarchical' | 'grid'; physics?: boolean; }; sankeyConfig?: { nodes: Array<{ name: string; category?: string; }>; links: Array<{ source: string; target: string; value: number; }>; }; animationConfig?: { frames: number; duration: number; transition?: 'linear' | 'ease' | 'ease-in' | 'ease-out'; }; exportFormat?: 'png' | 'svg' | 'pdf' | 'html' | 'json'; exportWidth?: number; exportHeight?: number; useCache?: boolean; cacheTTL?: number; } export interface AxisConfig { field?: string; label?: string; format?: string; scale?: 'linear' | 'logarithmic' | 'time' | 'category'; min?: number; max?: number; gridLines?: boolean; ticks?: { stepSize?: number; callback?: string; }; } export interface SeriesConfig { field: string; label?: string; color?: string; type?: 'line' | 'bar' | 'area' | 'scatter'; fill?: boolean; borderWidth?: number; pointRadius?: number; tension?: number; } export interface LegendConfig { display?: boolean; position?: 'top' | 'bottom' | 'left' | 'right'; align?: 'start' | 'center' | 'end'; labels?: { color?: string; font?: { size?: number; family?: string; weight?: string; }; }; } export interface TooltipConfig { enabled?: boolean; mode?: 'index' | 'dataset' | 'point' | 'nearest'; intersect?: boolean; callbacks?: { label?: string; title?: string; }; } export interface Chart { id: string; name: string; type: string; config: any; data: any[]; createdAt: number; updatedAt: number; metadata?: Record<string, any>; } export interface DataVisualizerResult { success: boolean; data?: { chart?: Chart; rendered?: string | Buffer; exported?: { path?: string; data: Buffer; }; }; metadata: { tokensUsed?: number; tokensSaved?: number; cacheHit: boolean; dataPoints?: number; }; error?: string; } export declare class DataVisualizer { private cache; private tokenCounter; private metricsCollector; private charts; private chartCounter; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector); /** * Main entry point for all data visualizer operations */ run(options: DataVisualizerOptions): Promise<DataVisualizerResult>; private createChart; private updateChart; private exportChart; private createHeatmap; private createTimeline; private createNetworkGraph; private createSankey; private animate; private buildChartConfig; private formatChartData; private buildLegendConfig; private buildTooltipConfig; private buildScalesConfig; private generateHeatmapSVG; private generateTimelineSVG; private generateNetworkGraphSVG; private generateSankeySVG; private exportToSVG; private exportToPNG; private exportToPDF; private exportToHTML; private generateBasicChartSVG; private generatePieChartSVG; private generateAnimatedVisualization; private drawLineChart; private drawBarChart; private calculateNodePositions; private calculateSankeyLevels; private calculateSankeyNodeValues; private generateSankeyLinkPath; private generateColorScaleLegend; private interpolateColor; private hexToRgb; private rgbToHex; private getDefaultColor; private generateChartId; private generateCacheKey; } export declare function getDataVisualizer(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): DataVisualizer; export declare const DATA_VISUALIZER_INPUT_SCHEMA: { type: string; properties: { operation: { type: string; enum: string[]; description: string; }; chartId: { type: string; description: string; }; chartType: { type: string; enum: string[]; description: string; }; data: { type: string; description: string; }; chartConfig: { type: string; description: string; }; heatmapConfig: { type: string; description: string; }; timelineConfig: { type: string; description: string; }; networkConfig: { type: string; description: string; }; sankeyConfig: { type: string; description: string; }; animationConfig: { type: string; description: string; }; renderFormat: { type: string; enum: string[]; description: string; default: string; }; exportFormat: { type: string; enum: string[]; description: string; default: string; }; exportWidth: { type: string; description: string; }; exportHeight: { type: string; description: string; }; useCache: { type: string; description: string; default: boolean; }; cacheTTL: { type: string; description: string; }; }; required: string[]; }; export declare const DATA_VISUALIZER_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { operation: { type: string; enum: string[]; description: string; }; chartId: { type: string; description: string; }; chartType: { type: string; enum: string[]; description: string; }; data: { type: string; description: string; }; chartConfig: { type: string; description: string; }; heatmapConfig: { type: string; description: string; }; timelineConfig: { type: string; description: string; }; networkConfig: { type: string; description: string; }; sankeyConfig: { type: string; description: string; }; animationConfig: { type: string; description: string; }; renderFormat: { type: string; enum: string[]; description: string; default: string; }; exportFormat: { type: string; enum: string[]; description: string; default: string; }; exportWidth: { type: string; description: string; }; exportHeight: { type: string; description: string; }; useCache: { type: string; description: string; default: boolean; }; cacheTTL: { type: string; description: string; }; }; required: string[]; }; }; //# sourceMappingURL=data-visualizer.d.ts.map