evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build an interactive sales performance visualization dashboard that displays sales data over time using multiple chart types. The dashboard should allow users to switch between different visualization modes and customize the appearance of the charts.
Create a TypeScript application that:
Registers Multiple Chart Types: Set up chart plugins for at least three different visualization types suitable for time series data (line, area, bar, or scatter charts).
Implements Chart Rendering: Render a sales performance chart that displays monthly sales data with the following features:
Configures Chart Appearance: Customize the chart with:
Handles Data Transformation: Process the raw sales data into the format required by the chart plugins, ensuring proper time series formatting and value scaling.
Provides comprehensive ECharts visualization plugins for Apache Superset including time series charts.
File: src/chartRegistry.test.ts
Test that chart plugins are properly registered and can be retrieved from the registry.
import { getChartPlugin } from './chartRegistry';
describe('Chart Plugin Registration', () => {
test('should register line chart plugin', () => {
const plugin = getChartPlugin('line');
expect(plugin).toBeDefined();
expect(plugin.metadata.name).toContain('Line');
});
test('should register area chart plugin', () => {
const plugin = getChartPlugin('area');
expect(plugin).toBeDefined();
expect(plugin.metadata.name).toContain('Area');
});
test('should register bar chart plugin', () => {
const plugin = getChartPlugin('bar');
expect(plugin).toBeDefined();
expect(plugin.metadata.name).toContain('Bar');
});
});File: src/dataTransform.test.ts
Test that sales data is correctly transformed into the chart data format.
import { transformSalesData } from './dataTransform';
describe('Data Transformation', () => {
test('should transform sales data to chart format', () => {
const salesData = [
{ month: '2024-01', sales: 50000 },
{ month: '2024-02', sales: 62000 },
{ month: '2024-03', sales: 58000 }
];
const transformed = transformSalesData(salesData);
expect(transformed).toHaveProperty('data');
expect(transformed.data).toHaveLength(3);
expect(transformed.data[0]).toHaveProperty('month');
expect(transformed.data[0]).toHaveProperty('sales');
});
});File: src/chartConfig.test.ts
Test that chart configuration is properly applied with custom settings.
import { createChartConfig } from './chartConfig';
describe('Chart Configuration', () => {
test('should create config with axis labels', () => {
const config = createChartConfig('line', {
xAxisTitle: 'Month',
yAxisTitle: 'Sales ($)'
});
expect(config.xAxisTitle).toBe('Month');
expect(config.yAxisTitle).toBe('Sales ($)');
});
test('should enable zoom functionality', () => {
const config = createChartConfig('line', { zoomable: true });
expect(config.zoomable).toBe(true);
});
test('should apply custom color scheme', () => {
const config = createChartConfig('line', { colorScheme: 'supersetColors' });
expect(config.colorScheme).toBeDefined();
});
});