Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +769 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: graph-creator
|
| 3 |
+
emoji: ⚛️
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- QwenSite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,769 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Advanced Graph Creator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/luxon@3.0.2/build/global/luxon.min.js"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@1.2.0/dist/chartjs-adapter-luxon.min.js"></script>
|
| 11 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
| 12 |
+
<style>
|
| 13 |
+
.chart-container {
|
| 14 |
+
position: relative;
|
| 15 |
+
height: 60vh;
|
| 16 |
+
width: 100%;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
.hidden {
|
| 20 |
+
display: none;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.data-point {
|
| 24 |
+
display: flex;
|
| 25 |
+
margin-bottom: 8px;
|
| 26 |
+
align-items: center;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.data-point input {
|
| 30 |
+
margin-right: 8px;
|
| 31 |
+
padding: 6px;
|
| 32 |
+
border: 1px solid #ddd;
|
| 33 |
+
border-radius: 4px;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.remove-point {
|
| 37 |
+
color: #ef4444;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
margin-left: 8px;
|
| 40 |
+
font-size: 18px;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.custom-scrollbar {
|
| 44 |
+
scrollbar-width: thin;
|
| 45 |
+
scrollbar-color: #6b7280 #f3f4f6;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.custom-scrollbar::-webkit-scrollbar {
|
| 49 |
+
width: 6px;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
| 53 |
+
background: #f3f4f6;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
| 57 |
+
background-color: #6b7280;
|
| 58 |
+
border-radius: 20px;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.slide-in {
|
| 62 |
+
animation: slideIn 0.3s ease-out forwards;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.slide-out {
|
| 66 |
+
animation: slideOut 0.3s ease-out forwards;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
@keyframes slideIn {
|
| 70 |
+
from {
|
| 71 |
+
transform: translateX(100%);
|
| 72 |
+
opacity: 0;
|
| 73 |
+
}
|
| 74 |
+
to {
|
| 75 |
+
transform: translateX(0);
|
| 76 |
+
opacity: 1;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
@keyframes slideOut {
|
| 81 |
+
from {
|
| 82 |
+
transform: translateX(0);
|
| 83 |
+
opacity: 1;
|
| 84 |
+
}
|
| 85 |
+
to {
|
| 86 |
+
transform: translateX(100%);
|
| 87 |
+
opacity: 0;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.tooltip {
|
| 92 |
+
position: absolute;
|
| 93 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 94 |
+
color: white;
|
| 95 |
+
padding: 5px 10px;
|
| 96 |
+
border-radius: 4px;
|
| 97 |
+
font-size: 12px;
|
| 98 |
+
pointer-events: none;
|
| 99 |
+
z-index: 1000;
|
| 100 |
+
white-space: nowrap;
|
| 101 |
+
}
|
| 102 |
+
</style>
|
| 103 |
+
</head>
|
| 104 |
+
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen font-sans">
|
| 105 |
+
<div class="container mx-auto px-4 py-8">
|
| 106 |
+
<!-- Header -->
|
| 107 |
+
<header class="text-center mb-8">
|
| 108 |
+
<h1 class="text-4xl font-bold text-indigo-800 mb-2">📊 Graph Creator</h1>
|
| 109 |
+
<p class="text-lg text-gray-600">Create beautiful charts from your data with customizable options</p>
|
| 110 |
+
</header>
|
| 111 |
+
|
| 112 |
+
<div class="flex flex-col lg:flex-row gap-6">
|
| 113 |
+
<!-- Left Panel: Controls -->
|
| 114 |
+
<div class="lg:w-1/3">
|
| 115 |
+
<div class="bg-white rounded-xl shadow-lg p-6 mb-6 transition-all duration-300 hover:shadow-xl">
|
| 116 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
| 117 |
+
<i class="fas fa-cogs mr-2 text-indigo-600"></i> Configuration
|
| 118 |
+
</h2>
|
| 119 |
+
|
| 120 |
+
<!-- Data Input Method -->
|
| 121 |
+
<div class="mb-6">
|
| 122 |
+
<label class="block text-sm font-medium text-gray-700 mb-2">Data Input Method</label>
|
| 123 |
+
<div class="grid grid-cols-2 gap-2">
|
| 124 |
+
<button id="manual-input-btn" class="py-2 px-4 bg-indigo-100 text-indigo-800 rounded-lg font-medium transition-colors duration-200 flex items-center justify-center hover:bg-indigo-200 active:bg-indigo-300">
|
| 125 |
+
<i class="fas fa-keyboard mr-2"></i> Manual
|
| 126 |
+
</button>
|
| 127 |
+
<button id="file-input-btn" class="py-2 px-4 bg-gray-100 text-gray-700 rounded-lg font-medium transition-colors duration-200 flex items-center justify-center hover:bg-gray-200 active:bg-gray-300">
|
| 128 |
+
<i class="fas fa-file-upload mr-2"></i> Upload
|
| 129 |
+
</button>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<!-- Manual Input Section -->
|
| 134 |
+
<div id="manual-input" class="space-y-4">
|
| 135 |
+
<div>
|
| 136 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Chart Title</label>
|
| 137 |
+
<input type="text" id="chart-title" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter chart title">
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<div>
|
| 141 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">X-axis Label</label>
|
| 142 |
+
<input type="text" id="x-label" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter X-axis label">
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div>
|
| 146 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Y-axis Label</label>
|
| 147 |
+
<input type="text" id="y-label" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter Y-axis label">
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div>
|
| 151 |
+
<label class="block text-sm font-medium text-gray-700 mb-2">Data Points</label>
|
| 152 |
+
<div id="data-points-container" class="space-y-2 max-h-40 overflow-y-auto custom-scrollbar pr-2">
|
| 153 |
+
<div class="data-point">
|
| 154 |
+
<input type="text" class="x-value w-1/3" placeholder="X">
|
| 155 |
+
<input type="number" class="y-value w-1/3" placeholder="Y">
|
| 156 |
+
<i class="fas fa-trash remove-point"></i>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
<button id="add-point" class="mt-2 flex items-center text-sm text-indigo-600 hover:text-indigo-800">
|
| 160 |
+
<i class="fas fa-plus mr-1"></i> Add Data Point
|
| 161 |
+
</button>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<!-- File Upload Section (Hidden by default) -->
|
| 166 |
+
<div id="file-input" class="hidden space-y-4">
|
| 167 |
+
<div>
|
| 168 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Upload CSV File</label>
|
| 169 |
+
<input type="file" id="csv-file" accept=".csv" class="w-full px-3 py-2 border border-gray-300 rounded-lg file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-medium file:bg-indigo-50 file:text-indigo-700 hover:file:bg-indigo-100">
|
| 170 |
+
<p class="text-xs text-gray-500 mt-1">Upload a CSV file with two columns (X,Y)</p>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<div id="csv-preview" class="hidden">
|
| 174 |
+
<h3 class="text-sm font-medium text-gray-700 mb-2">Preview</h3>
|
| 175 |
+
<div id="csv-content" class="bg-gray-50 p-3 rounded-lg text-xs max-h-32 overflow-y-auto custom-scrollbar"></div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
|
| 180 |
+
<!-- Chart Settings -->
|
| 181 |
+
<div class="bg-white rounded-xl shadow-lg p-6 transition-all duration-300 hover:shadow-xl">
|
| 182 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
|
| 183 |
+
<i class="fas fa-sliders-h mr-2 text-indigo-600"></i> Chart Settings
|
| 184 |
+
</h2>
|
| 185 |
+
|
| 186 |
+
<div class="space-y-4">
|
| 187 |
+
<div>
|
| 188 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Chart Type</label>
|
| 189 |
+
<select id="chart-type" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
| 190 |
+
<option value="bar">Bar Chart</option>
|
| 191 |
+
<option value="line">Line Chart</option>
|
| 192 |
+
<option value="pie">Pie Chart</option>
|
| 193 |
+
<option value="doughnut">Doughnut Chart</option>
|
| 194 |
+
<option value="radar">Radar Chart</option>
|
| 195 |
+
<option value="polarArea">Polar Area</option>
|
| 196 |
+
<option value="bubble">Bubble Chart</option>
|
| 197 |
+
</select>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<div id="line-options" class="space-y-3">
|
| 201 |
+
<div class="flex items-center">
|
| 202 |
+
<input type="checkbox" id="show-lines" class="mr-2 h-4 w-4 text-indigo-600 rounded focus:ring-indigo-500">
|
| 203 |
+
<label for="show-lines" class="text-sm font-medium text-gray-700">Show Lines</label>
|
| 204 |
+
</div>
|
| 205 |
+
<div class="flex items-center">
|
| 206 |
+
<input type="checkbox" id="show-points" class="mr-2 h-4 w-4 text-indigo-600 rounded focus:ring-indigo-500">
|
| 207 |
+
<label for="show-points" class="text-sm font-medium text-gray-700">Show Points</label>
|
| 208 |
+
</div>
|
| 209 |
+
</div>
|
| 210 |
+
|
| 211 |
+
<div id="color-scheme">
|
| 212 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Color Scheme</label>
|
| 213 |
+
<div class="grid grid-cols-3 gap-2">
|
| 214 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#3B82F6", "#1D4ED8", "#1E40AF", "#1E3A8A", "#172554"]'>
|
| 215 |
+
<div class="w-6 h-6 bg-blue-500 rounded-full"></div>
|
| 216 |
+
</button>
|
| 217 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#EC4899", "#DB2777", "#BE185D", "#9D174D", "#7E113B"]'>
|
| 218 |
+
<div class="w-6 h-6 bg-pink-500 rounded-full"></div>
|
| 219 |
+
</button>
|
| 220 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#10B981", "#059669", "#047857", "#065F46", "#064E3B"]'>
|
| 221 |
+
<div class="w-6 h-6 bg-green-500 rounded-full"></div>
|
| 222 |
+
</button>
|
| 223 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#F59E0B", "#D97706", "#B45309", "#92400E", "#78350F"]'>
|
| 224 |
+
<div class="w-6 h-6 bg-amber-500 rounded-full"></div>
|
| 225 |
+
</button>
|
| 226 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#8B5CF6", "#7C3AED", "#6D28D9", "#5B21B6", "#4C1D95"]'>
|
| 227 |
+
<div class="w-6 h-6 bg-purple-500 rounded-full"></div>
|
| 228 |
+
</button>
|
| 229 |
+
<button class="color-option p-2 rounded-lg flex items-center justify-center" data-colors='["#06B6D4", "#0891B2", "#0E7490", "#155E75", "#164E63"]'>
|
| 230 |
+
<div class="w-6 h-6 bg-cyan-500 rounded-full"></div>
|
| 231 |
+
</button>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
|
| 235 |
+
<div>
|
| 236 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Animation Duration (ms)</label>
|
| 237 |
+
<input type="range" id="animation-duration" min="0" max="3000" value="1000" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer slider">
|
| 238 |
+
<div class="flex justify-between text-xs text-gray-500 mt-1">
|
| 239 |
+
<span>0ms</span>
|
| 240 |
+
<span id="duration-value">1000ms</span>
|
| 241 |
+
<span>3000ms</span>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
|
| 245 |
+
<button id="generate-btn" class="w-full py-3 px-4 bg-indigo-600 hover:bg-indigo-700 focus:ring-indigo-500 focus:ring-offset-indigo-200 text-white transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg">
|
| 246 |
+
<i class="fas fa-chart-line mr-2"></i> Generate Chart
|
| 247 |
+
</button>
|
| 248 |
+
|
| 249 |
+
<button id="download-btn" class="w-full py-2 px-4 bg-gray-600 hover:bg-gray-700 text-white transition ease-in duration-200 text-center text-sm font-semibold shadow-md focus:outline-none rounded-lg flex items-center justify-center">
|
| 250 |
+
<i class="fas fa-download mr-2"></i> Download Chart
|
| 251 |
+
</button>
|
| 252 |
+
</div>
|
| 253 |
+
</div>
|
| 254 |
+
</div>
|
| 255 |
+
|
| 256 |
+
<!-- Right Panel: Chart -->
|
| 257 |
+
<div class="lg:w-2/3">
|
| 258 |
+
<div class="bg-white rounded-xl shadow-lg p-6 h-full transition-all duration-300 hover:shadow-xl">
|
| 259 |
+
<div class="flex justify-between items-center mb-4">
|
| 260 |
+
<h2 class="text-xl font-semibold text-gray-800 flex items-center">
|
| 261 |
+
<i class="fas fa-chart-bar mr-2 text-indigo-600"></i> <span id="chart-title-display">Your Chart</span>
|
| 262 |
+
</h2>
|
| 263 |
+
<div class="flex space-x-2">
|
| 264 |
+
<button id="fullscreen-btn" class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors duration-200">
|
| 265 |
+
<i class="fas fa-expand"></i>
|
| 266 |
+
</button>
|
| 267 |
+
</div>
|
| 268 |
+
</div>
|
| 269 |
+
|
| 270 |
+
<div class="chart-container relative">
|
| 271 |
+
<canvas id="graph" class="w-full h-full"></canvas>
|
| 272 |
+
<div id="empty-state" class="absolute inset-0 flex flex-col items-center justify-center text-gray-400">
|
| 273 |
+
<i class="fas fa-chart-line text-6xl mb-4 opacity-50"></i>
|
| 274 |
+
<p class="text-lg font-medium">No data to display</p>
|
| 275 |
+
<p class="text-sm">Configure your data and settings, then click "Generate Chart"</p>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
|
| 282 |
+
<!-- Toast Notification -->
|
| 283 |
+
<div id="toast" class="fixed bottom-5 right-5 bg-gray-800 text-white px-4 py-3 rounded-lg shadow-lg flex items-center hidden transition-all duration-300 z-50">
|
| 284 |
+
<i class="fas fa-check-circle mr-2"></i>
|
| 285 |
+
<span id="toast-message">Chart downloaded successfully!</span>
|
| 286 |
+
</div>
|
| 287 |
+
|
| 288 |
+
<!-- Fullscreen Modal -->
|
| 289 |
+
<div id="fullscreen-modal" class="fixed inset-0 bg-black bg-opacity-90 z-50 hidden flex items-center justify-center p-4">
|
| 290 |
+
<div class="relative w-full max-w-5xl">
|
| 291 |
+
<button id="close-fullscreen" class="absolute -top-12 right-0 text-white text-2xl hover:text-gray-300 transition-colors duration-200">
|
| 292 |
+
<i class="fas fa-times"></i>
|
| 293 |
+
</button>
|
| 294 |
+
<h3 id="fullscreen-title" class="text-white text-xl mb-4 text-center"></h3>
|
| 295 |
+
<div class="bg-white rounded-lg p-2">
|
| 296 |
+
<canvas id="fullscreen-chart" class="w-full h-auto"></canvas>
|
| 297 |
+
</div>
|
| 298 |
+
</div>
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
|
| 302 |
+
<script>
|
| 303 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 304 |
+
// Elements
|
| 305 |
+
const manualInputBtn = document.getElementById('manual-input-btn');
|
| 306 |
+
const fileInputBtn = document.getElementById('file-input-btn');
|
| 307 |
+
const manualInput = document.getElementById('manual-input');
|
| 308 |
+
const fileInput = document.getElementById('file-input');
|
| 309 |
+
const csvFile = document.getElementById('csv-file');
|
| 310 |
+
const csvPreview = document.getElementById('csv-preview');
|
| 311 |
+
const csvContent = document.getElementById('csv-content');
|
| 312 |
+
const addPointBtn = document.getElementById('add-point');
|
| 313 |
+
const dataPointsContainer = document.getElementById('data-points-container');
|
| 314 |
+
const chartType = document.getElementById('chart-type');
|
| 315 |
+
const lineOptions = document.getElementById('line-options');
|
| 316 |
+
const showLines = document.getElementById('show-lines');
|
| 317 |
+
const showPoints = document.getElementById('show-points');
|
| 318 |
+
const colorScheme = document.getElementById('color-scheme');
|
| 319 |
+
const colorOptions = document.querySelectorAll('.color-option');
|
| 320 |
+
const animationDuration = document.getElementById('animation-duration');
|
| 321 |
+
const durationValue = document.getElementById('duration-value');
|
| 322 |
+
const generateBtn = document.getElementById('generate-btn');
|
| 323 |
+
const downloadBtn = document.getElementById('download-btn');
|
| 324 |
+
const chartTitle = document.getElementById('chart-title');
|
| 325 |
+
const xLabel = document.getElementById('x-label');
|
| 326 |
+
const yLabel = document.getElementById('y-label');
|
| 327 |
+
const chartTitleDisplay = document.getElementById('chart-title-display');
|
| 328 |
+
const emptyState = document.getElementById('empty-state');
|
| 329 |
+
const toast = document.getElementById('toast');
|
| 330 |
+
const toastMessage = document.getElementById('toast-message');
|
| 331 |
+
const fullscreenBtn = document.getElementById('fullscreen-btn');
|
| 332 |
+
const fullscreenModal = document.getElementById('fullscreen-modal');
|
| 333 |
+
const closeFullscreen = document.getElementById('close-fullscreen');
|
| 334 |
+
const fullscreenTitle = document.getElementById('fullscreen-title');
|
| 335 |
+
const graph = document.getElementById('graph');
|
| 336 |
+
const fullscreenChart = document.getElementById('fullscreen-chart');
|
| 337 |
+
|
| 338 |
+
// Chart instance
|
| 339 |
+
let chart = null;
|
| 340 |
+
let fullscreenChartInstance = null;
|
| 341 |
+
let currentColors = ['#3B82F6', '#1D4ED8', '#1E40AF', '#1E3A8A', '#172554'];
|
| 342 |
+
|
| 343 |
+
// Initialize chart with empty data
|
| 344 |
+
function initChart() {
|
| 345 |
+
return new Chart(graph, {
|
| 346 |
+
type: 'bar',
|
| 347 |
+
data: {
|
| 348 |
+
labels: [],
|
| 349 |
+
datasets: [{
|
| 350 |
+
label: 'Data',
|
| 351 |
+
data: [],
|
| 352 |
+
backgroundColor: currentColors[0],
|
| 353 |
+
borderColor: currentColors[0],
|
| 354 |
+
borderWidth: 1
|
| 355 |
+
}]
|
| 356 |
+
},
|
| 357 |
+
options: {
|
| 358 |
+
responsive: true,
|
| 359 |
+
maintainAspectRatio: false,
|
| 360 |
+
plugins: {
|
| 361 |
+
legend: {
|
| 362 |
+
display: false
|
| 363 |
+
},
|
| 364 |
+
tooltip: {
|
| 365 |
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
| 366 |
+
titleColor: '#fff',
|
| 367 |
+
bodyColor: '#fff',
|
| 368 |
+
borderColor: '#333',
|
| 369 |
+
borderWidth: 1,
|
| 370 |
+
cornerRadius: 6,
|
| 371 |
+
displayColors: false
|
| 372 |
+
}
|
| 373 |
+
},
|
| 374 |
+
scales: {
|
| 375 |
+
y: {
|
| 376 |
+
beginAtZero: true,
|
| 377 |
+
grid: {
|
| 378 |
+
color: 'rgba(0, 0, 0, 0.05)'
|
| 379 |
+
},
|
| 380 |
+
ticks: {
|
| 381 |
+
color: '#6b7280'
|
| 382 |
+
}
|
| 383 |
+
},
|
| 384 |
+
x: {
|
| 385 |
+
grid: {
|
| 386 |
+
color: 'rgba(0, 0, 0, 0.05)'
|
| 387 |
+
},
|
| 388 |
+
ticks: {
|
| 389 |
+
color: '#6b7280'
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
});
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
// Initialize chart
|
| 398 |
+
chart = initChart();
|
| 399 |
+
|
| 400 |
+
// Event Listeners
|
| 401 |
+
manualInputBtn.addEventListener('click', function() {
|
| 402 |
+
manualInputBtn.classList.add('bg-indigo-100', 'text-indigo-800');
|
| 403 |
+
manualInputBtn.classList.remove('bg-gray-100', 'text-gray-700');
|
| 404 |
+
fileInputBtn.classList.remove('bg-indigo-100', 'text-indigo-800');
|
| 405 |
+
fileInputBtn.classList.add('bg-gray-100', 'text-gray-700');
|
| 406 |
+
manualInput.classList.remove('hidden');
|
| 407 |
+
fileInput.classList.add('hidden');
|
| 408 |
+
});
|
| 409 |
+
|
| 410 |
+
fileInputBtn.addEventListener('click', function() {
|
| 411 |
+
fileInputBtn.classList.add('bg-indigo-100', 'text-indigo-800');
|
| 412 |
+
fileInputBtn.classList.remove('bg-gray-100', 'text-gray-700');
|
| 413 |
+
manualInputBtn.classList.remove('bg-indigo-100', 'text-indigo-800');
|
| 414 |
+
manualInputBtn.classList.add('bg-gray-100', 'text-gray-700');
|
| 415 |
+
fileInput.classList.remove('hidden');
|
| 416 |
+
manualInput.classList.add('hidden');
|
| 417 |
+
});
|
| 418 |
+
|
| 419 |
+
// Add new data point
|
| 420 |
+
addPointBtn.addEventListener('click', function() {
|
| 421 |
+
const point = document.createElement('div');
|
| 422 |
+
point.className = 'data-point';
|
| 423 |
+
point.innerHTML = `
|
| 424 |
+
<input type="text" class="x-value w-1/3" placeholder="X">
|
| 425 |
+
<input type="number" class="y-value w-1/3" placeholder="Y">
|
| 426 |
+
<i class="fas fa-trash remove-point"></i>
|
| 427 |
+
`;
|
| 428 |
+
dataPointsContainer.appendChild(point);
|
| 429 |
+
|
| 430 |
+
// Add event listener to remove button
|
| 431 |
+
point.querySelector('.remove-point').addEventListener('click', function() {
|
| 432 |
+
dataPointsContainer.removeChild(point);
|
| 433 |
+
});
|
| 434 |
+
});
|
| 435 |
+
|
| 436 |
+
// Remove data point
|
| 437 |
+
dataPointsContainer.addEventListener('click', function(e) {
|
| 438 |
+
if (e.target.classList.contains('remove-point')) {
|
| 439 |
+
const point = e.target.closest('.data-point');
|
| 440 |
+
if (dataPointsContainer.children.length > 1) {
|
| 441 |
+
dataPointsContainer.removeChild(point);
|
| 442 |
+
}
|
| 443 |
+
}
|
| 444 |
+
});
|
| 445 |
+
|
| 446 |
+
// Handle file upload
|
| 447 |
+
csvFile.addEventListener('change', function(e) {
|
| 448 |
+
const file = e.target.files[0];
|
| 449 |
+
if (!file) return;
|
| 450 |
+
|
| 451 |
+
const reader = new FileReader();
|
| 452 |
+
reader.onload = function(e) {
|
| 453 |
+
const content = e.target.result;
|
| 454 |
+
csvContent.textContent = content.split('\n').slice(0, 10).join('\n') + (content.split('\n').length > 10 ? '\n...' : '');
|
| 455 |
+
csvPreview.classList.remove('hidden');
|
| 456 |
+
};
|
| 457 |
+
reader.readAsText(file);
|
| 458 |
+
});
|
| 459 |
+
|
| 460 |
+
// Update animation duration display
|
| 461 |
+
animationDuration.addEventListener('input', function() {
|
| 462 |
+
durationValue.textContent = `${this.value}ms`;
|
| 463 |
+
});
|
| 464 |
+
|
| 465 |
+
// Apply color scheme
|
| 466 |
+
colorOptions.forEach(option => {
|
| 467 |
+
option.addEventListener('click', function() {
|
| 468 |
+
colorOptions.forEach(opt => {
|
| 469 |
+
opt.classList.remove('ring-2', 'ring-indigo-500');
|
| 470 |
+
});
|
| 471 |
+
this.classList.add('ring-2', 'ring-indigo-500');
|
| 472 |
+
currentColors = JSON.parse(this.dataset.colors);
|
| 473 |
+
});
|
| 474 |
+
});
|
| 475 |
+
|
| 476 |
+
// Set default color scheme
|
| 477 |
+
colorOptions[0].classList.add('ring-2', 'ring-indigo-500');
|
| 478 |
+
|
| 479 |
+
// Chart type change
|
| 480 |
+
chartType.addEventListener('change', function() {
|
| 481 |
+
if (this.value === 'line') {
|
| 482 |
+
lineOptions.classList.remove('hidden');
|
| 483 |
+
} else {
|
| 484 |
+
lineOptions.classList.add('hidden');
|
| 485 |
+
}
|
| 486 |
+
});
|
| 487 |
+
|
| 488 |
+
// Generate chart
|
| 489 |
+
generateBtn.addEventListener('click', function() {
|
| 490 |
+
// Get data based on input method
|
| 491 |
+
let labels = [];
|
| 492 |
+
let data = [];
|
| 493 |
+
|
| 494 |
+
if (manualInput.classList.contains('hidden')) {
|
| 495 |
+
// File input method
|
| 496 |
+
const file = csvFile.files[0];
|
| 497 |
+
if (!file) {
|
| 498 |
+
showToast('Please select a CSV file');
|
| 499 |
+
return;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
const reader = new FileReader();
|
| 503 |
+
reader.onload = function(e) {
|
| 504 |
+
const content = e.target.result;
|
| 505 |
+
const rows = content.split('\n');
|
| 506 |
+
|
| 507 |
+
for (let i = 0; i < rows.length; i++) {
|
| 508 |
+
if (rows[i].trim() === '') continue;
|
| 509 |
+
|
| 510 |
+
const cols = rows[i].split(',');
|
| 511 |
+
if (cols.length >= 2) {
|
| 512 |
+
labels.push(cols[0].trim());
|
| 513 |
+
data.push(parseFloat(cols[1].trim()));
|
| 514 |
+
}
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
createChart(labels, data);
|
| 518 |
+
};
|
| 519 |
+
reader.readAsText(file);
|
| 520 |
+
} else {
|
| 521 |
+
// Manual input method
|
| 522 |
+
const points = dataPointsContainer.querySelectorAll('.data-point');
|
| 523 |
+
let isValid = true;
|
| 524 |
+
|
| 525 |
+
points.forEach(point => {
|
| 526 |
+
const xValue = point.querySelector('.x-value').value;
|
| 527 |
+
const yValue = point.querySelector('.y-value').value;
|
| 528 |
+
|
| 529 |
+
if (xValue && yValue !== '') {
|
| 530 |
+
labels.push(xValue);
|
| 531 |
+
data.push(parseFloat(yValue));
|
| 532 |
+
} else if (xValue || yValue !== '') {
|
| 533 |
+
isValid = false;
|
| 534 |
+
}
|
| 535 |
+
});
|
| 536 |
+
|
| 537 |
+
if (!isValid) {
|
| 538 |
+
showToast('Please fill in all data points');
|
| 539 |
+
return;
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
if (labels.length === 0) {
|
| 543 |
+
showToast('Please add at least one data point');
|
| 544 |
+
return;
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
createChart(labels, data);
|
| 548 |
+
}
|
| 549 |
+
});
|
| 550 |
+
|
| 551 |
+
// Create chart with data
|
| 552 |
+
function createChart(labels, data) {
|
| 553 |
+
// Update chart title
|
| 554 |
+
const title = chartTitle.value || 'Your Chart';
|
| 555 |
+
chartTitleDisplay.textContent = title;
|
| 556 |
+
|
| 557 |
+
// Destroy existing chart
|
| 558 |
+
if (chart) {
|
| 559 |
+
chart.destroy();
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
// Chart configuration
|
| 563 |
+
const chartConfig = {
|
| 564 |
+
type: chartType.value,
|
| 565 |
+
data: {
|
| 566 |
+
labels: labels,
|
| 567 |
+
datasets: [{
|
| 568 |
+
label: 'Data',
|
| 569 |
+
data: data,
|
| 570 |
+
backgroundColor: currentColors[0],
|
| 571 |
+
borderColor: currentColors[0],
|
| 572 |
+
borderWidth: 1
|
| 573 |
+
}]
|
| 574 |
+
},
|
| 575 |
+
options: {
|
| 576 |
+
responsive: true,
|
| 577 |
+
maintainAspectRatio: false,
|
| 578 |
+
animation: {
|
| 579 |
+
duration: parseInt(animationDuration.value)
|
| 580 |
+
},
|
| 581 |
+
plugins: {
|
| 582 |
+
title: {
|
| 583 |
+
display: true,
|
| 584 |
+
text: title,
|
| 585 |
+
font: {
|
| 586 |
+
size: 16
|
| 587 |
+
}
|
| 588 |
+
},
|
| 589 |
+
legend: {
|
| 590 |
+
display: false
|
| 591 |
+
},
|
| 592 |
+
tooltip: {
|
| 593 |
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
| 594 |
+
titleColor: '#fff',
|
| 595 |
+
bodyColor: '#fff',
|
| 596 |
+
borderColor: '#333',
|
| 597 |
+
borderWidth: 1,
|
| 598 |
+
cornerRadius: 6,
|
| 599 |
+
displayColors: false
|
| 600 |
+
}
|
| 601 |
+
},
|
| 602 |
+
scales: {
|
| 603 |
+
y: {
|
| 604 |
+
beginAtZero: true,
|
| 605 |
+
grid: {
|
| 606 |
+
color: 'rgba(0, 0, 0, 0.05)'
|
| 607 |
+
},
|
| 608 |
+
ticks: {
|
| 609 |
+
color: '#6b7280'
|
| 610 |
+
},
|
| 611 |
+
title: {
|
| 612 |
+
display: true,
|
| 613 |
+
text: yLabel.value || 'Value',
|
| 614 |
+
color: '#6b7280'
|
| 615 |
+
}
|
| 616 |
+
},
|
| 617 |
+
x: {
|
| 618 |
+
grid: {
|
| 619 |
+
color: 'rgba(0, 0, 0, 0.05)'
|
| 620 |
+
},
|
| 621 |
+
ticks: {
|
| 622 |
+
color: '#6b7280'
|
| 623 |
+
},
|
| 624 |
+
title: {
|
| 625 |
+
display: true,
|
| 626 |
+
text: xLabel.value || 'Category',
|
| 627 |
+
color: '#6b7280'
|
| 628 |
+
}
|
| 629 |
+
}
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
};
|
| 633 |
+
|
| 634 |
+
// Special configurations for different chart types
|
| 635 |
+
if (chartType.value === 'bar') {
|
| 636 |
+
chartConfig.data.datasets[0].backgroundColor = currentColors.map(color =>
|
| 637 |
+
typeof color === 'string' ? color : color.backgroundColor
|
| 638 |
+
).slice(0, data.length);
|
| 639 |
+
} else if (chartType.value === 'pie' || chartType.value === 'doughnut') {
|
| 640 |
+
chartConfig.data.datasets[0].backgroundColor = currentColors.slice(0, data.length);
|
| 641 |
+
chartConfig.data.datasets[0].borderColor = currentColors.slice(0, data.length).map(c => '#ffffff');
|
| 642 |
+
chartConfig.options.plugins.legend = {
|
| 643 |
+
display: true,
|
| 644 |
+
position: 'bottom'
|
| 645 |
+
};
|
| 646 |
+
chartConfig.options.scales = {};
|
| 647 |
+
} else if (chartType.value === 'radar') {
|
| 648 |
+
chartConfig.data.datasets[0].backgroundColor = 'rgba(59, 130, 246, 0.2)';
|
| 649 |
+
chartConfig.data.datasets[0].borderColor = currentColors[0];
|
| 650 |
+
} else if (chartType.value === 'polarArea') {
|
| 651 |
+
chartConfig.data.datasets[0].backgroundColor = currentColors.slice(0, data.length);
|
| 652 |
+
} else if (chartType.value === 'line') {
|
| 653 |
+
chartConfig.data.datasets[0].backgroundColor = 'rgba(59, 130, 246, 0.1)';
|
| 654 |
+
chartConfig.data.datasets[0].borderColor = currentColors[0];
|
| 655 |
+
chartConfig.data.datasets[0].borderWidth = 3;
|
| 656 |
+
chartConfig.data.datasets[0].pointBackgroundColor = currentColors[0];
|
| 657 |
+
chartConfig.data.datasets[0].pointBorderColor = '#fff';
|
| 658 |
+
chartConfig.data.datasets[0].pointBorderWidth = 2;
|
| 659 |
+
chartConfig.data.datasets[0].pointRadius = showPoints.checked ? 4 : 0;
|
| 660 |
+
chartConfig.options.scales.x.title.display = true;
|
| 661 |
+
|
| 662 |
+
if (!showLines.checked) {
|
| 663 |
+
chartConfig.data.datasets[0].borderWidth = 0;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
if (!showPoints.checked) {
|
| 667 |
+
chartConfig.data.datasets[0].pointRadius = 0;
|
| 668 |
+
}
|
| 669 |
+
} else if (chartType.value === 'bubble') {
|
| 670 |
+
// Convert data to bubble format
|
| 671 |
+
const bubbleData = [];
|
| 672 |
+
for (let i = 0; i < data.length; i++) {
|
| 673 |
+
bubbleData.push({
|
| 674 |
+
x: i,
|
| 675 |
+
y: data[i],
|
| 676 |
+
r: Math.abs(data[i]) * 2 + 5
|
| 677 |
+
});
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
chartConfig.data.datasets[0].data = bubbleData;
|
| 681 |
+
chartConfig.data.datasets[0].backgroundColor = currentColors[0];
|
| 682 |
+
chartConfig.data.labels = [];
|
| 683 |
+
chartConfig.options.scales.x.min = -1;
|
| 684 |
+
chartConfig.options.scales.x.max = data.length;
|
| 685 |
+
}
|
| 686 |
+
|
| 687 |
+
// Create new chart
|
| 688 |
+
chart = new Chart(graph, chartConfig);
|
| 689 |
+
|
| 690 |
+
// Hide empty state
|
| 691 |
+
emptyState.classList.add('hidden');
|
| 692 |
+
|
| 693 |
+
// Show success message
|
| 694 |
+
showToast('Chart generated successfully!');
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
// Download chart
|
| 698 |
+
downloadBtn.addEventListener('click', function() {
|
| 699 |
+
if (!chart) {
|
| 700 |
+
showToast('No chart to download');
|
| 701 |
+
return;
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
const now = new Date();
|
| 705 |
+
const timestamp = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}-${String(now.getMinutes()).padStart(2, '0')}`;
|
| 706 |
+
const filename = `chart_${timestamp}.png`;
|
| 707 |
+
|
| 708 |
+
const link = document.createElement('a');
|
| 709 |
+
link.download = filename;
|
| 710 |
+
link.href = chart.toBase64Image();
|
| 711 |
+
link.click();
|
| 712 |
+
|
| 713 |
+
showToast(`Chart downloaded as ${filename}`);
|
| 714 |
+
});
|
| 715 |
+
|
| 716 |
+
// Fullscreen functionality
|
| 717 |
+
fullscreenBtn.addEventListener('click', function() {
|
| 718 |
+
fullscreenModal.classList.remove('hidden');
|
| 719 |
+
fullscreenModal.classList.add('slide-in');
|
| 720 |
+
|
| 721 |
+
// Create fullscreen chart
|
| 722 |
+
if (fullscreenChartInstance) {
|
| 723 |
+
fullscreenChartInstance.destroy();
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
fullscreenTitle.textContent = chartTitleDisplay.textContent;
|
| 727 |
+
|
| 728 |
+
fullscreenChartInstance = new Chart(fullscreenChart, JSON.parse(JSON.stringify(chart.config)));
|
| 729 |
+
});
|
| 730 |
+
|
| 731 |
+
closeFullscreen.addEventListener('click', function() {
|
| 732 |
+
fullscreenModal.classList.remove('slide-in');
|
| 733 |
+
fullscreenModal.classList.add('slide-out');
|
| 734 |
+
|
| 735 |
+
setTimeout(() => {
|
| 736 |
+
fullscreenModal.classList.add('hidden');
|
| 737 |
+
fullscreenModal.classList.remove('slide-out');
|
| 738 |
+
if (fullscreenChartInstance) {
|
| 739 |
+
fullscreenChartInstance.destroy();
|
| 740 |
+
fullscreenChartInstance = null;
|
| 741 |
+
}
|
| 742 |
+
}, 300);
|
| 743 |
+
});
|
| 744 |
+
|
| 745 |
+
// Toast notification
|
| 746 |
+
function showToast(message) {
|
| 747 |
+
toastMessage.textContent = message;
|
| 748 |
+
toast.classList.remove('hidden');
|
| 749 |
+
toast.classList.add('slide-in');
|
| 750 |
+
|
| 751 |
+
setTimeout(() => {
|
| 752 |
+
toast.classList.remove('slide-in');
|
| 753 |
+
toast.classList.add('slide-out');
|
| 754 |
+
|
| 755 |
+
setTimeout(() => {
|
| 756 |
+
toast.classList.add('hidden');
|
| 757 |
+
toast.classList.remove('slide-out');
|
| 758 |
+
}, 300);
|
| 759 |
+
}, 3000);
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
// Initialize with empty data point if none exists
|
| 763 |
+
if (dataPointsContainer.children.length === 0) {
|
| 764 |
+
addPointBtn.click();
|
| 765 |
+
}
|
| 766 |
+
});
|
| 767 |
+
</script>
|
| 768 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-qwensite.hf.space/logo.svg" alt="qwensite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-qwensite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >QwenSite</a> - 🧬 <a href="https://enzostvs-qwensite.hf.space?remix=alterzick/graph-creator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 769 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
tolong buatkan grafik creator yang memiliki beberapa fitur pengaturan dan bentuk grafik yang bisa di pilih. baik dengan cara upload data atau dengan inputing data
|