@quarri/claude-data-tools 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quarri/claude-data-tools",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Quarri Data Assistant - Natural language data analysis with Quarri",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -6,7 +6,9 @@ alwaysApply: false
6
6
 
7
7
  # /quarri-chart - Interactive Chart Generation
8
8
 
9
- Generate data visualizations as interactive Plotly charts using MCP UI resources.
9
+ Generate data visualizations as interactive **Plotly.js** charts using MCP UI resources.
10
+
11
+ **IMPORTANT**: Always use Plotly.js format. Do NOT generate React components, Recharts, Chart.js, or any other charting library. The MCP UI renderer only supports Plotly.js configuration objects.
10
12
 
11
13
  ## When to Use
12
14
 
@@ -16,19 +18,65 @@ Use `/quarri-chart` when users want visualizations:
16
18
  - "Show me a graph of this data"
17
19
  - "Chart sales by category"
18
20
 
21
+ ## Data Size Limits
22
+
23
+ **CRITICAL**: Charts should contain at most **500 data points**. Large datasets must be handled appropriately:
24
+
25
+ | Scenario | Solution |
26
+ |----------|----------|
27
+ | Time series with many dates | Aggregate to appropriate granularity (day→week→month→quarter) |
28
+ | Too many categories | Show Top N (10-20) + "Other" bucket |
29
+ | Scatter plot with many points | Sample data or use density/heatmap |
30
+ | Raw transactional data | Always GROUP BY before charting - never chart individual transactions |
31
+
32
+ ### Example: Handling Large Categorical Data
33
+
34
+ ```sql
35
+ -- BAD: Returns potentially thousands of products
36
+ SELECT product_name, SUM(sales) FROM orders GROUP BY product_name
37
+
38
+ -- GOOD: Top 10 + Other
39
+ WITH ranked AS (
40
+ SELECT product_name, SUM(sales) as total_sales,
41
+ ROW_NUMBER() OVER (ORDER BY SUM(sales) DESC) as rn
42
+ FROM quarri.schema
43
+ GROUP BY product_name
44
+ )
45
+ SELECT
46
+ CASE WHEN rn <= 10 THEN product_name ELSE 'Other' END as product_name,
47
+ SUM(total_sales) as total_sales
48
+ FROM ranked
49
+ GROUP BY CASE WHEN rn <= 10 THEN product_name ELSE 'Other' END
50
+ ORDER BY total_sales DESC
51
+ ```
52
+
53
+ ### Example: Handling Long Time Series
54
+
55
+ ```sql
56
+ -- BAD: Daily data for 5 years = 1800+ points
57
+ SELECT order_date, SUM(sales) FROM orders GROUP BY order_date
58
+
59
+ -- GOOD: Aggregate to months
60
+ SELECT DATE_TRUNC('month', order_date) as month, SUM(sales) as total_sales
61
+ FROM quarri.schema
62
+ GROUP BY DATE_TRUNC('month', order_date)
63
+ ORDER BY month
64
+ ```
65
+
19
66
  ## Primary Workflow
20
67
 
21
- ### Step 1: Query the data
68
+ ### Step 1: Query the data (with appropriate aggregation)
22
69
  ```sql
23
70
  SELECT category, SUM(sales) as total_sales
24
- FROM orders
71
+ FROM quarri.schema
25
72
  GROUP BY category
26
73
  ORDER BY total_sales DESC
74
+ LIMIT 20
27
75
  ```
28
76
 
29
77
  ### Step 2: Return chart as MCP UI resource
30
78
 
31
- After getting the data, construct a Plotly configuration and include it in your response. The chart will be rendered as an interactive UI component.
79
+ After getting the data, construct a **Plotly.js** configuration and include it in your response. The chart will be rendered as an interactive UI component.
32
80
 
33
81
  **Example Plotly config for bar chart:**
34
82
  ```json
@@ -307,3 +355,29 @@ Charts work best when combined with:
307
355
  - `/quarri-query`: Get data first, then visualize
308
356
  - `/quarri-analyze`: Called as part of full analysis pipeline
309
357
  - `/quarri-insights`: Visual support for statistical findings
358
+
359
+ ## Validation Checklist
360
+
361
+ Before generating a chart, verify:
362
+
363
+ 1. **Library**: Using Plotly.js format (NOT React, Recharts, Chart.js, D3, or others)
364
+ 2. **Data points**: ≤ 500 points total (aggregate or sample if more)
365
+ 3. **Categories**: ≤ 20 categories (use Top N + Other if more)
366
+ 4. **Time granularity**: Appropriate for date range (don't show daily for multi-year)
367
+ 5. **Aggregation**: Never chart raw transactions - always GROUP BY
368
+
369
+ **Output format must be:**
370
+ ```json
371
+ {
372
+ "data": [{ /* Plotly trace */ }],
373
+ "layout": { /* Plotly layout */ }
374
+ }
375
+ ```
376
+
377
+ **NOT:**
378
+ ```jsx
379
+ // WRONG - Do not generate React components
380
+ <BarChart data={data}>
381
+ <Bar dataKey="value" />
382
+ </BarChart>
383
+ ```