Hello, I would like to create a DASHBOARD in my system, I thought about doing it in WEBVIEW2. Could someone provide some example of graphs using WEBVIEW?
Thanks
Webview2 + GRAPHIC
- Antonio Linares
- Site Admin
- Posts: 42723
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 93 times
- Been thanked: 106 times
- Contact:
Re: Webview2 + GRAPHIC
dashboard.prg
dashboard.html
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWnd, oWebView
DEFINE WINDOW oWnd TITLE "Dashboard"
oWebView = TWebView2():New( oWnd )
oWebView:SetHtml( memoRead( "dashboard.html" ) )
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON RESIZE oWebView:SetSize( nWidth, nHeight )
return nil
Code: Select all | Expand
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Professional Dashboard with Charts</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
body {
background: #f0f2f5;
color: #333;
line-height: 1.6;
}
.container {
display: flex;
min-height: 100vh;
}
.sidebar {
width: 250px;
background: #2c3e50;
color: white;
position: fixed;
height: 100%;
padding: 20px;
}
.sidebar h2 {
font-size: 24px;
margin-bottom: 30px;
text-align: center;
}
.sidebar ul {
list-style: none;
}
.sidebar ul li {
margin: 20px 0;
}
.sidebar ul li a {
color: white;
text-decoration: none;
display: flex;
align-items: center;
padding: 10px;
border-radius: 5px;
transition: background 0.3s;
}
.sidebar ul li a:hover {
background: #34495e;
}
.sidebar ul li a i {
margin-right: 10px;
font-size: 18px;
}
.main-content {
flex: 1;
margin-left: 250px;
padding: 20px;
}
.dashboard-container {
max-width: 1400px;
margin: 0 auto;
}
.header {
background: #2c3e50;
color: white;
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
}
.header h1 {
font-size: 24px;
}
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}
.card {
background: white;
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s;
}
.card:hover {
transform: translateY(-5px);
}
.card h3 {
margin-bottom: 15px;
color: #2c3e50;
}
.stats-card {
display: flex;
align-items: center;
gap: 15px;
}
.stats-icon {
width: 50px;
height: 50px;
background: #3498db;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
}
.chart-container {
height: 200px;
position: relative;
}
.progress-bar {
width: 100%;
height: 20px;
background: #eee;
border-radius: 10px;
overflow: hidden;
margin-top: 10px;
}
.progress {
height: 100%;
background: #2ecc71;
width: 0;
}
.progress-75 { width: 75%; }
.progress-50 { width: 50%; }
.progress-25 { width: 25%; }
@media (max-width: 768px) {
.sidebar {
width: 200px;
}
.main-content {
margin-left: 200px;
}
.grid-container {
grid-template-columns: 1fr;
}
}
@media (max-width: 480px) {
.sidebar {
width: 70px;
}
.sidebar h2,
.sidebar ul li a span {
display: none;
}
.main-content {
margin-left: 70px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="sidebar">
<h2>Menu</h2>
<ul>
<li><a href="#"><i>🏠</i><span>Dashboard</span></a></li>
<li><a href="#"><i>📊</i><span>Analytics</span></a></li>
<li><a href="#"><i>👥</i><span>Users</span></a></li>
<li><a href="#"><i>⚙️</i><span>Settings</span></a></li>
<li><a href="#"><i>🚪</i><span>Logout</span></a></li>
</ul>
</div>
<div class="main-content">
<div class="dashboard-container">
<div class="header">
<h1>Dashboard Overview</h1>
</div>
<div class="grid-container">
<div class="card stats-card">
<div class="stats-icon">📊</div>
<div>
<h3>Revenue</h3>
<p>$24,500</p>
</div>
</div>
<div class="card stats-card">
<div class="stats-icon">👥</div>
<div>
<h3>Users</h3>
<p>1,234</p>
</div>
</div>
<div class="card stats-card">
<div class="stats-icon">⭐</div>
<div>
<h3>Rating</h3>
<p>4.8/5</p>
</div>
</div>
<div class="card">
<h3>Sales Trend (Monthly)</h3>
<div class="chart-container">
<canvas id="salesChart"></canvas>
</div>
</div>
<div class="card">
<h3>Project Progress</h3>
<p>Development</p>
<div class="progress-bar"><div class="progress progress-75"></div></div>
<p>Design</p>
<div class="progress-bar"><div class="progress progress-50"></div></div>
<p>Testing</p>
<div class="progress-bar"><div class="progress progress-25"></div></div>
</div>
<div class="card">
<h3>User Distribution</h3>
<div class="chart-container">
<canvas id="userChart"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Sales Trend Line Chart
const salesCtx = document.getElementById('salesChart').getContext('2d');
new Chart(salesCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Sales ($)',
data: [12000, 19000, 15000, 25000, 22000, 30000],
borderColor: '#3498db',
backgroundColor: 'rgba(52, 152, 219, 0.2)',
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
}
}
});
// User Distribution Bar Chart
const userCtx = document.getElementById('userChart').getContext('2d');
new Chart(userCtx, {
type: 'bar',
data: {
labels: ['New', 'Returning', 'Inactive'],
datasets: [{
label: 'Users',
data: [500, 600, 134],
backgroundColor: [
'#2ecc71',
'#3498db',
'#e74c3c'
]
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>
Re: Webview2 + GRAPHIC
Mr Antonio, thank you for responding, I believe the HTML has a formatting problem, can you send it to my email? ubiratanmga gmail com
- Antonio Linares
- Site Admin
- Posts: 42723
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 93 times
- Been thanked: 106 times
- Contact: