Skip to content

Commit ab982ef

Browse files
committed
feat: add supported chart examples and unsupported type warning
1 parent 7603f94 commit ab982ef

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

docs/example_bar.png

305 KB
Loading

docs/example_line.png

204 KB
Loading

docs/example_scatter.png

218 KB
Loading

docs/index.html

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,69 @@
686686
text-decoration: none;
687687
}
688688

689+
/* Examples Section */
690+
.examples-section {
691+
max-width: 800px;
692+
margin: 0 auto 48px;
693+
}
694+
695+
.examples-grid {
696+
display: grid;
697+
grid-template-columns: repeat(3, 1fr);
698+
gap: 20px;
699+
margin-bottom: 24px;
700+
}
701+
702+
.example-card {
703+
background: var(--surface);
704+
border: 1px solid var(--border);
705+
border-radius: 16px;
706+
padding: 16px;
707+
text-align: center;
708+
transition: all 0.3s;
709+
}
710+
711+
.example-card:hover {
712+
border-color: var(--accent);
713+
transform: translateY(-4px);
714+
}
715+
716+
.example-card img {
717+
width: 100%;
718+
height: 120px;
719+
object-fit: cover;
720+
border-radius: 8px;
721+
margin-bottom: 12px;
722+
background: #fff;
723+
}
724+
725+
.example-card span {
726+
font-weight: 600;
727+
font-size: 0.9rem;
728+
color: var(--text-secondary);
729+
}
730+
731+
.warning-box {
732+
display: flex;
733+
align-items: flex-start;
734+
gap: 16px;
735+
padding: 20px 24px;
736+
background: rgba(255, 200, 50, 0.1);
737+
border: 1px solid rgba(255, 200, 50, 0.3);
738+
border-radius: 12px;
739+
font-size: 0.95rem;
740+
color: var(--text-secondary);
741+
}
742+
743+
.warning-icon {
744+
font-size: 1.5rem;
745+
flex-shrink: 0;
746+
}
747+
748+
.warning-box strong {
749+
color: #ffc832;
750+
}
751+
689752
@media (max-width: 768px) {
690753
.nav-links {
691754
display: none;
@@ -881,6 +944,35 @@ <h2>Comparison</h2>
881944
<h2>Try It Now</h2>
882945
<p>Extract data from your chart in seconds</p>
883946
</div>
947+
948+
<!-- Supported Charts Examples -->
949+
<div class="examples-section">
950+
<h3 style="text-align: center; margin-bottom: 24px; color: var(--text-secondary);">✅ Supported Chart Types</h3>
951+
<div class="examples-grid">
952+
<div class="example-card">
953+
<img src="example_line.png" alt="Line chart example">
954+
<span>Line Chart</span>
955+
</div>
956+
<div class="example-card">
957+
<img src="example_bar.png" alt="Bar chart example">
958+
<span>Bar Chart</span>
959+
</div>
960+
<div class="example-card">
961+
<img src="example_scatter.png" alt="Scatter plot example">
962+
<span>Scatter Plot</span>
963+
</div>
964+
</div>
965+
966+
<div class="warning-box">
967+
<span class="warning-icon">⚠️</span>
968+
<div>
969+
<strong>Not Supported:</strong> Heatmaps, pie charts, GitHub contribution graphs, treemaps, and other
970+
non-standard visualizations.
971+
Charts must have clear X/Y axes with numerical labels.
972+
</div>
973+
</div>
974+
</div>
975+
884976
<div class="demo-container">
885977
<div class="api-key-box">
886978
<label for="apiKey">🔑 Mistral API Key</label>
@@ -891,7 +983,7 @@ <h2>Try It Now</h2>
891983
<div class="dropzone" id="dropzone">
892984
<div class="dropzone-icon">📊</div>
893985
<h3>Drop your chart here</h3>
894-
<p>or click to browse • PNG, JPG, WebP</p>
986+
<p>Line charts, bar charts, scatter plots only</p>
895987
<input type="file" id="fileInput" accept="image/*" hidden>
896988
</div>
897989

@@ -1010,7 +1102,21 @@ <h4>✅ Extracted Data</h4>
10101102
messages: [{
10111103
role: 'user',
10121104
content: [
1013-
{ type: 'text', text: `Extract all data points from this chart. Output ONLY CSV with headers (x,y for line/scatter, label,value for bar). No explanations.` },
1105+
{
1106+
type: 'text', text: `Analyze this image. You ONLY support: line charts, bar charts, and scatter plots with clear X/Y axes.
1107+
1108+
If this is NOT a supported chart type (e.g., heatmap, pie chart, GitHub contribution graph, treemap, dashboard, table, or any image without clear X and Y axes), respond ONLY with:
1109+
ERROR: Not a supported chart type. Please upload a line chart, bar chart, or scatter plot with clear X/Y axes.
1110+
1111+
If it IS a supported chart:
1112+
1. Identify the chart type
1113+
2. Read the X and Y axis labels/values
1114+
3. Extract ALL data points
1115+
4. Output ONLY CSV with headers:
1116+
- For line/scatter charts: x,y
1117+
- For bar charts: label,value
1118+
1119+
No explanations. Just CSV data or error message.` },
10141120
{ type: 'image_url', image_url: base64 }
10151121
]
10161122
}],
@@ -1023,6 +1129,11 @@ <h4>✅ Extracted Data</h4>
10231129
const data = await resp.json();
10241130
let csv = data.choices[0].message.content.trim().replace(/```csv\n?/g, '').replace(/```\n?/g, '').trim();
10251131

1132+
// Check if AI rejected the image
1133+
if (csv.startsWith('ERROR:')) {
1134+
throw new Error(csv.replace('ERROR:', '').trim());
1135+
}
1136+
10261137
currentCSV = csv;
10271138
csvOutput.textContent = csv;
10281139
pointCount.textContent = `📍 ${csv.trim().split('\n').length - 1} points`;

0 commit comments

Comments
 (0)