Spaces:
Running
Running
IT SHOULD BE AN ANDROID AND IOS APP AND I WANT TO USE THE PHONE CAMERA TO TAKE PICTURE OF THE RECEIT AND IT TRANSORMS INTO INFORMATION TO BE STORED
7b78975 verified Download components/spending-chart.js from eddygonzalez/snapspend-wizard: direct link, hf CLI and curl.
- Browser
- Download file 3.48 kB
-
https://huggingface.co/spaces/eddygonzalez/snapspend-wizard/resolve/main/components/spending-chart.js
- Command line
-
hf download hf://spaces/eddygonzalez/snapspend-wizard/components/spending-chart.js
-
curl -L -o spending-chart.js https://huggingface.co/spaces/eddygonzalez/snapspend-wizard/resolve/main/components/spending-chart.js
3.48 kB
| class CustomSpendingChart extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .chart-container { | |
| position: relative; | |
| height: 300px; | |
| } | |
| </style> | |
| <div> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold text-gray-800">Spending Overview</h2> | |
| <select class="px-3 py-1 border rounded-lg text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> | |
| <option>Last 6 Months</option> | |
| <option>This Year</option> | |
| <option>Last Year</option> | |
| </select> | |
| </div> | |
| <div class="chart-container"> | |
| <canvas id="spendingChart"></canvas> | |
| </div> | |
| </div> | |
| `; | |
| // Initialize chart after the element is rendered | |
| setTimeout(() => { | |
| this.initChart(); | |
| }, 0); | |
| } | |
| initChart() { | |
| const canvas = this.shadowRoot.getElementById('spendingChart'); | |
| if (!canvas) return; | |
| const ctx = canvas.getContext('2d'); | |
| // Chart data (would normally come from props or API) | |
| const data = { | |
| labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'], | |
| datasets: [ | |
| { | |
| label: 'Food', | |
| data: [120, 190, 150, 200, 180, 220], | |
| backgroundColor: '#6366F1', | |
| borderRadius: 4 | |
| }, | |
| { | |
| label: 'Transport', | |
| data: [80, 90, 70, 85, 75, 95], | |
| backgroundColor: '#10B981', | |
| borderRadius: 4 | |
| }, | |
| { | |
| label: 'Shopping', | |
| data: [200, 150, 180, 220, 250, 200], | |
| backgroundColor: '#8B5CF6', | |
| borderRadius: 4 | |
| }, | |
| { | |
| label: 'Entertainment', | |
| data: [50, 60, 70, 65, 80, 75], | |
| backgroundColor: '#F59E0B', | |
| borderRadius: 4 | |
| } | |
| ] | |
| }; | |
| new Chart(ctx, { | |
| type: 'bar', | |
| data: data, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| plugins: { | |
| legend: { | |
| position: 'bottom', | |
| }, | |
| tooltip: { | |
| mode: 'index', | |
| intersect: false, | |
| } | |
| }, | |
| scales: { | |
| x: { | |
| stacked: true, | |
| grid: { | |
| display: false | |
| } | |
| }, | |
| y: { | |
| stacked: true, | |
| beginAtZero: true, | |
| ticks: { | |
| callback: function(value) { | |
| return '$' + value; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| } | |
| customElements.define('custom-spending-chart', CustomSpendingChart); |