Examups commited on
Commit
9a43e19
·
verified ·
1 Parent(s): 8face39

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +142 -60
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Modern Advanced Chart Maker with All Features</title>
7
  <!-- Bootstrap CSS -->
8
  <link
9
  href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
@@ -31,14 +31,58 @@
31
  border: none;
32
  padding: 0;
33
  }
 
 
 
 
 
34
  #myChart {
35
  background-color: white;
36
  border-radius: 8px;
37
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  </style>
40
  </head>
41
  <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  <div class="container my-4">
43
  <h2 class="text-center mb-4">Modern Advanced Chart Maker</h2>
44
 
@@ -59,23 +103,19 @@
59
  </div>
60
  <div class="col-md-8">
61
  <label for="tableDataInput" class="form-label">Enter Tabular Data:</label>
62
- <textarea
63
- id="tableDataInput"
64
- rows="6"
65
- class="form-control"
66
- placeholder="Paste your tabular data here...">| Year | Profit (in lakhs) | Revenue (in crores) | Expenses (in lakhs) |
67
  |-------|------------------|---------------------|---------------------|
68
  | Year 1 | 80 | 10 | 50 |
69
  | Year 2 | 90 | 15 | 60 |
70
  | Year 3 | 85 | 13 | 55 |
71
  | Year 4 | 95 | 18 | 70 |
72
- | Year 5 | 100 | 20 | 80 |</textarea>
 
73
  </div>
74
  </div>
75
  <div class="mt-3 text-center">
76
- <button onclick="generateChart()" class="btn btn-primary">
77
- Generate Chart
78
- </button>
79
  </div>
80
  </div>
81
  </div>
@@ -92,7 +132,28 @@
92
  <div class="card shadow-sm mb-4">
93
  <div class="card-header">Chart</div>
94
  <div class="card-body">
95
- <canvas id="myChart" height="150"></canvas>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  </div>
97
  </div>
98
 
@@ -133,21 +194,15 @@
133
  <div class="row g-3 mt-2">
134
  <div class="col-md-6 form-check">
135
  <input class="form-check-input" type="checkbox" id="toggleLegend" checked>
136
- <label class="form-check-label" for="toggleLegend">
137
- Show Legend
138
- </label>
139
  </div>
140
  <div class="col-md-6 form-check">
141
  <input class="form-check-input" type="checkbox" id="toggleGrid" checked>
142
- <label class="form-check-label" for="toggleGrid">
143
- Show Gridlines
144
- </label>
145
  </div>
146
  </div>
147
  <div class="mt-3 text-center">
148
- <button onclick="updateChartOptions()" class="btn btn-secondary">
149
- Update Chart Options
150
- </button>
151
  </div>
152
  </div>
153
  </div>
@@ -193,7 +248,7 @@
193
  <div class="card shadow-sm mb-4">
194
  <div class="card-header">Export Options</div>
195
  <div class="card-body">
196
- <!-- New: Chart File Name Option -->
197
  <div class="row g-3 mb-3">
198
  <div class="col-md-12">
199
  <label for="chartFileName" class="form-label">Chart File Name:</label>
@@ -201,26 +256,32 @@
201
  </div>
202
  </div>
203
  <div class="text-center">
204
- <button onclick="downloadChart('png')" class="btn btn-success me-2">
205
- Download as PNG
206
- </button>
207
- <button onclick="downloadChart('jpeg')" class="btn btn-success me-2">
208
- Download as JPEG
209
- </button>
210
- <button onclick="copyChartToClipboard()" class="btn btn-warning me-2">
211
- Copy to Clipboard
212
- </button>
213
- <button onclick="exportDataAsCSV()" class="btn btn-info me-2">
214
- Export Data as CSV
215
- </button>
216
- <button onclick="exportChartConfigAsJSON()" class="btn btn-info">
217
- Export Config as JSON
218
- </button>
219
  </div>
220
  </div>
221
  </div>
222
  </div>
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  <script>
225
  let chartInstance = null;
226
  let currentChartConfig = {};
@@ -244,10 +305,7 @@
244
  // Parse tabular data (first column as labels).
245
  function parseTableData(input) {
246
  const rows = input.trim().split("\n");
247
- const headers = rows[0]
248
- .split("|")
249
- .map(h => h.trim())
250
- .filter(h => h.length > 0);
251
  const labels = [];
252
  const datasets = headers.slice(1).map(header => ({
253
  label: header,
@@ -256,10 +314,7 @@
256
  borderWidth: 1,
257
  }));
258
  for (let i = 2; i < rows.length; i++) {
259
- const cells = rows[i]
260
- .split("|")
261
- .map(cell => cell.trim())
262
- .filter(cell => cell.length > 0);
263
  if (cells.length === headers.length) {
264
  labels.push(cells[0]);
265
  for (let j = 1; j < cells.length; j++) {
@@ -293,8 +348,7 @@
293
 
294
  // Generate HTML table for parsed data.
295
  function generateTable(headers, labels, datasets) {
296
- let tableHTML = `<div class="table-responsive"><table class="table table-bordered">
297
- <thead class="table-light"><tr>`;
298
  headers.forEach(header => { tableHTML += `<th>${header}</th>`; });
299
  tableHTML += `</tr></thead><tbody>`;
300
  for (let i = 0; i < labels.length; i++) {
@@ -328,6 +382,7 @@
328
  data: { labels: labels, datasets: datasets },
329
  options: {
330
  responsive: true,
 
331
  plugins: {
332
  legend: { display: true, position: "top" },
333
  title: { display: true, text: `${headers[0]} vs Multiple Columns` },
@@ -447,7 +502,26 @@
447
  return { x, y };
448
  }
449
 
450
- // Download chart with watermark (image or text), using custom file name.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  function downloadChart(format) {
452
  const originalCanvas = document.getElementById("myChart");
453
  const offscreenCanvas = document.createElement("canvas");
@@ -461,6 +535,11 @@
461
  }
462
  offCtx.drawImage(originalCanvas, 0, 0);
463
 
 
 
 
 
 
464
  const watermarkImageInput = document.getElementById("watermarkImage");
465
  const watermarkOpacity = document.getElementById("watermarkOpacity").value;
466
 
@@ -491,10 +570,10 @@
491
  offCtx.fillStyle = `rgba(255,165,0,${watermarkOpacity})`;
492
 
493
  let textAlign = "center", textBaseline = "middle";
494
- if(watermarkPosition.includes("left")) { textAlign = "left"; }
495
- else if(watermarkPosition.includes("right")) { textAlign = "right"; }
496
- if(watermarkPosition.includes("top")) { textBaseline = "top"; }
497
- else if(watermarkPosition.includes("bottom")) { textBaseline = "bottom"; }
498
  offCtx.textAlign = textAlign;
499
  offCtx.textBaseline = textBaseline;
500
 
@@ -509,7 +588,7 @@
509
  }
510
  }
511
 
512
- // Copy chart to clipboard with watermark (PNG), using custom file name if needed.
513
  async function copyChartToClipboard() {
514
  const originalCanvas = document.getElementById("myChart");
515
  const offscreenCanvas = document.createElement("canvas");
@@ -518,6 +597,11 @@
518
  const offCtx = offscreenCanvas.getContext("2d");
519
  offCtx.drawImage(originalCanvas, 0, 0);
520
 
 
 
 
 
 
521
  const watermarkImageInput = document.getElementById("watermarkImage");
522
  const watermarkOpacity = document.getElementById("watermarkOpacity").value;
523
 
@@ -548,10 +632,10 @@
548
  offCtx.fillStyle = `rgba(255,165,0,${watermarkOpacity})`;
549
 
550
  let textAlign = "center", textBaseline = "middle";
551
- if(watermarkPosition.includes("left")) { textAlign = "left"; }
552
- else if(watermarkPosition.includes("right")) { textAlign = "right"; }
553
- if(watermarkPosition.includes("top")) { textBaseline = "top"; }
554
- else if(watermarkPosition.includes("bottom")) { textBaseline = "bottom"; }
555
  offCtx.textAlign = textAlign;
556
  offCtx.textBaseline = textBaseline;
557
 
@@ -597,8 +681,6 @@
597
  }
598
  </script>
599
  <!-- Bootstrap Bundle with Popper -->
600
- <script
601
- src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
602
- ></script>
603
  </body>
604
  </html>
 
3
  <head>
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Modern Advanced Chart Maker with Tooltip Export</title>
7
  <!-- Bootstrap CSS -->
8
  <link
9
  href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
 
31
  border: none;
32
  padding: 0;
33
  }
34
+ .chart-container {
35
+ position: relative;
36
+ width: 100%;
37
+ height: 300px; /* Adjust height as needed */
38
+ }
39
  #myChart {
40
  background-color: white;
41
  border-radius: 8px;
42
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
43
+ }
44
+ .ad-container {
45
+ text-align: center;
46
+ margin: 20px 0;
47
+ }
48
+ /* Mobile responsive adjustments */
49
+ @media (max-width: 576px) {
50
+ .color-picker-container {
51
+ display: block;
52
+ margin: 10px 0;
53
+ }
54
+ .card {
55
+ margin-bottom: 15px;
56
+ }
57
+ .card-header, .card-body {
58
+ padding: 10px;
59
+ }
60
+ h2 {
61
+ font-size: 1.5rem;
62
+ }
63
+ .chart-container {
64
+ height: 250px;
65
+ }
66
  }
67
  </style>
68
  </head>
69
  <body>
70
+ <!-- Top Google Ad -->
71
+ <div class="ad-container">
72
+ <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2810665891608163"
73
+ crossorigin="anonymous"></script>
74
+ <!-- Examups Top -->
75
+ <ins class="adsbygoogle"
76
+ style="display:block"
77
+ data-ad-client="ca-pub-2810665891608163"
78
+ data-ad-slot="8588732226"
79
+ data-ad-format="auto"
80
+ data-full-width-responsive="true"></ins>
81
+ <script>
82
+ (adsbygoogle = window.adsbygoogle || []).push({});
83
+ </script>
84
+ </div>
85
+
86
  <div class="container my-4">
87
  <h2 class="text-center mb-4">Modern Advanced Chart Maker</h2>
88
 
 
103
  </div>
104
  <div class="col-md-8">
105
  <label for="tableDataInput" class="form-label">Enter Tabular Data:</label>
106
+ <textarea id="tableDataInput" rows="6" class="form-control" placeholder="Paste your tabular data here...">
107
+ | Year | Profit (in lakhs) | Revenue (in crores) | Expenses (in lakhs) |
 
 
 
108
  |-------|------------------|---------------------|---------------------|
109
  | Year 1 | 80 | 10 | 50 |
110
  | Year 2 | 90 | 15 | 60 |
111
  | Year 3 | 85 | 13 | 55 |
112
  | Year 4 | 95 | 18 | 70 |
113
+ | Year 5 | 100 | 20 | 80 |
114
+ </textarea>
115
  </div>
116
  </div>
117
  <div class="mt-3 text-center">
118
+ <button onclick="generateChart()" class="btn btn-primary">Generate Chart</button>
 
 
119
  </div>
120
  </div>
121
  </div>
 
132
  <div class="card shadow-sm mb-4">
133
  <div class="card-header">Chart</div>
134
  <div class="card-body">
135
+ <div class="chart-container">
136
+ <canvas id="myChart"></canvas>
137
+ </div>
138
+ </div>
139
+ </div>
140
+
141
+ <!-- Middle Google Ad (as a card) -->
142
+ <div class="card shadow-sm mb-4">
143
+ <div class="card-header">Sponsored</div>
144
+ <div class="card-body ad-container">
145
+ <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2810665891608163"
146
+ crossorigin="anonymous"></script>
147
+ <!-- Examups Middle -->
148
+ <ins class="adsbygoogle"
149
+ style="display:block"
150
+ data-ad-client="ca-pub-2810665891608163"
151
+ data-ad-slot="8588732226"
152
+ data-ad-format="auto"
153
+ data-full-width-responsive="true"></ins>
154
+ <script>
155
+ (adsbygoogle = window.adsbygoogle || []).push({});
156
+ </script>
157
  </div>
158
  </div>
159
 
 
194
  <div class="row g-3 mt-2">
195
  <div class="col-md-6 form-check">
196
  <input class="form-check-input" type="checkbox" id="toggleLegend" checked>
197
+ <label class="form-check-label" for="toggleLegend">Show Legend</label>
 
 
198
  </div>
199
  <div class="col-md-6 form-check">
200
  <input class="form-check-input" type="checkbox" id="toggleGrid" checked>
201
+ <label class="form-check-label" for="toggleGrid">Show Gridlines</label>
 
 
202
  </div>
203
  </div>
204
  <div class="mt-3 text-center">
205
+ <button onclick="updateChartOptions()" class="btn btn-secondary">Update Chart Options</button>
 
 
206
  </div>
207
  </div>
208
  </div>
 
248
  <div class="card shadow-sm mb-4">
249
  <div class="card-header">Export Options</div>
250
  <div class="card-body">
251
+ <!-- Chart File Name Option -->
252
  <div class="row g-3 mb-3">
253
  <div class="col-md-12">
254
  <label for="chartFileName" class="form-label">Chart File Name:</label>
 
256
  </div>
257
  </div>
258
  <div class="text-center">
259
+ <button onclick="downloadChart('png')" class="btn btn-success me-2">Download as PNG</button>
260
+ <button onclick="downloadChart('jpeg')" class="btn btn-success me-2">Download as JPEG</button>
261
+ <button onclick="copyChartToClipboard()" class="btn btn-warning me-2">Copy to Clipboard</button>
262
+ <button onclick="exportDataAsCSV()" class="btn btn-info me-2">Export Data as CSV</button>
263
+ <button onclick="exportChartConfigAsJSON()" class="btn btn-info">Export Config as JSON</button>
 
 
 
 
 
 
 
 
 
 
264
  </div>
265
  </div>
266
  </div>
267
  </div>
268
 
269
+ <!-- Footer Google Ad -->
270
+ <div class="ad-container">
271
+ <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2810665891608163"
272
+ crossorigin="anonymous"></script>
273
+ <!-- Examups Footer -->
274
+ <ins class="adsbygoogle"
275
+ style="display:block"
276
+ data-ad-client="ca-pub-2810665891608163"
277
+ data-ad-slot="8588732226"
278
+ data-ad-format="auto"
279
+ data-full-width-responsive="true"></ins>
280
+ <script>
281
+ (adsbygoogle = window.adsbygoogle || []).push({});
282
+ </script>
283
+ </div>
284
+
285
  <script>
286
  let chartInstance = null;
287
  let currentChartConfig = {};
 
305
  // Parse tabular data (first column as labels).
306
  function parseTableData(input) {
307
  const rows = input.trim().split("\n");
308
+ const headers = rows[0].split("|").map(h => h.trim()).filter(h => h.length > 0);
 
 
 
309
  const labels = [];
310
  const datasets = headers.slice(1).map(header => ({
311
  label: header,
 
314
  borderWidth: 1,
315
  }));
316
  for (let i = 2; i < rows.length; i++) {
317
+ const cells = rows[i].split("|").map(cell => cell.trim()).filter(cell => cell.length > 0);
 
 
 
318
  if (cells.length === headers.length) {
319
  labels.push(cells[0]);
320
  for (let j = 1; j < cells.length; j++) {
 
348
 
349
  // Generate HTML table for parsed data.
350
  function generateTable(headers, labels, datasets) {
351
+ let tableHTML = `<div class="table-responsive"><table class="table table-bordered"><thead class="table-light"><tr>`;
 
352
  headers.forEach(header => { tableHTML += `<th>${header}</th>`; });
353
  tableHTML += `</tr></thead><tbody>`;
354
  for (let i = 0; i < labels.length; i++) {
 
382
  data: { labels: labels, datasets: datasets },
383
  options: {
384
  responsive: true,
385
+ maintainAspectRatio: false,
386
  plugins: {
387
  legend: { display: true, position: "top" },
388
  title: { display: true, text: `${headers[0]} vs Multiple Columns` },
 
502
  return { x, y };
503
  }
504
 
505
+ // Function to draw tooltips (percentage labels) on pie/doughnut charts.
506
+ function drawPieTooltips(ctx) {
507
+ if (chartInstance.config.type === "pie" || chartInstance.config.type === "doughnut") {
508
+ const meta = chartInstance.getDatasetMeta(0);
509
+ const dataset = chartInstance.data.datasets[0];
510
+ const total = dataset.data.reduce((sum, val) => sum + val, 0);
511
+ meta.data.forEach((arc, index) => {
512
+ const pos = arc.tooltipPosition();
513
+ const value = dataset.data[index];
514
+ const percentage = ((value / total) * 100).toFixed(1) + "%";
515
+ ctx.fillStyle = "black";
516
+ ctx.font = "bold 12px Arial";
517
+ ctx.textAlign = "center";
518
+ ctx.textBaseline = "middle";
519
+ ctx.fillText(percentage, pos.x, pos.y);
520
+ });
521
+ }
522
+ }
523
+
524
+ // Download chart with watermark (image or text), including pie chart tooltips.
525
  function downloadChart(format) {
526
  const originalCanvas = document.getElementById("myChart");
527
  const offscreenCanvas = document.createElement("canvas");
 
535
  }
536
  offCtx.drawImage(originalCanvas, 0, 0);
537
 
538
+ // If chart is pie/doughnut, draw tooltip percentages on image.
539
+ if (chartInstance.config.type === "pie" || chartInstance.config.type === "doughnut") {
540
+ drawPieTooltips(offCtx);
541
+ }
542
+
543
  const watermarkImageInput = document.getElementById("watermarkImage");
544
  const watermarkOpacity = document.getElementById("watermarkOpacity").value;
545
 
 
570
  offCtx.fillStyle = `rgba(255,165,0,${watermarkOpacity})`;
571
 
572
  let textAlign = "center", textBaseline = "middle";
573
+ if (watermarkPosition.includes("left")) { textAlign = "left"; }
574
+ else if (watermarkPosition.includes("right")) { textAlign = "right"; }
575
+ if (watermarkPosition.includes("top")) { textBaseline = "top"; }
576
+ else if (watermarkPosition.includes("bottom")) { textBaseline = "bottom"; }
577
  offCtx.textAlign = textAlign;
578
  offCtx.textBaseline = textBaseline;
579
 
 
588
  }
589
  }
590
 
591
+ // Copy chart to clipboard with watermark (PNG), including pie chart tooltips.
592
  async function copyChartToClipboard() {
593
  const originalCanvas = document.getElementById("myChart");
594
  const offscreenCanvas = document.createElement("canvas");
 
597
  const offCtx = offscreenCanvas.getContext("2d");
598
  offCtx.drawImage(originalCanvas, 0, 0);
599
 
600
+ // If chart is pie/doughnut, draw tooltip percentages.
601
+ if (chartInstance.config.type === "pie" || chartInstance.config.type === "doughnut") {
602
+ drawPieTooltips(offCtx);
603
+ }
604
+
605
  const watermarkImageInput = document.getElementById("watermarkImage");
606
  const watermarkOpacity = document.getElementById("watermarkOpacity").value;
607
 
 
632
  offCtx.fillStyle = `rgba(255,165,0,${watermarkOpacity})`;
633
 
634
  let textAlign = "center", textBaseline = "middle";
635
+ if (watermarkPosition.includes("left")) { textAlign = "left"; }
636
+ else if (watermarkPosition.includes("right")) { textAlign = "right"; }
637
+ if (watermarkPosition.includes("top")) { textBaseline = "top"; }
638
+ else if (watermarkPosition.includes("bottom")) { textBaseline = "bottom"; }
639
  offCtx.textAlign = textAlign;
640
  offCtx.textBaseline = textBaseline;
641
 
 
681
  }
682
  </script>
683
  <!-- Bootstrap Bundle with Popper -->
684
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
 
 
685
  </body>
686
  </html>