Liveweave: Generative AI Web Editor & HTML/CSS/JS Playground
Initializing
Liveweave
Web
expand_more
home
Home
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
frame_source
Python Playground
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Fork
account_circle
Login
settings
Settings
expand_more
Editor font
14
px
A
A
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
left_panel_close
AI Assistant
dashboard
All
HTML
CSS
JS
visibility
Preview
bolt
Live Preview
terminal
JS Console
<!DOCTYPE html> <html> <head> <title>Analytics dashboard template</title> </head> <body> <!-- Start your code here --> <div class="nexus"> <header class="topbar"> <div class="brand"> <div class="brand-symbol">N</div> <div class="brand-name">NEXUS<span> / INTELLIGENCE</span></div> <div class="environment"><i></i> PRODUCTION</div> </div> <div class="top-actions"> <div class="live-indicator"><i></i><span id="live-status">LIVE DATA</span></div> <button id="pause-live" class="icon-button" title="Pause live updates">Ⅱ</button> <div class="user-avatar">NX</div> </div> </header> <div class="dashboard-heading"> <div> <div class="breadcrumb">OVERVIEW <span>/</span> COMMAND CENTER</div> <h1>Performance <span>Overview</span></h1> <p>Monitor your business performance across every dimension.</p> </div> <div class="heading-controls"> <div class="date-control"> <span>◷</span> <button class="range active" data-range="24H">24H</button> <button class="range" data-range="7D">7D</button> <button class="range" data-range="30D">30D</button> <button class="range" data-range="90D">90D</button> </div> <div class="updated">LAST UPDATED <strong id="last-updated">--:--:--</strong></div> </div> </div> <section class="kpi-grid"> <article class="kpi-card"> <div class="kpi-top"><span>TOTAL REVENUE</span><span class="kpi-icon purple">$</span></div> <div class="kpi-value" id="revenue">$284,590</div> <div class="kpi-bottom"><span class="positive">↗ 12.8%</span><span>vs previous period</span></div> <svg class="sparkline" viewBox="0 0 180 38" preserveAspectRatio="none"><path id="spark-1" d="" /></svg> </article> <article class="kpi-card"> <div class="kpi-top"><span>ACTIVE USERS</span><span class="kpi-icon cyan">◎</span></div> <div class="kpi-value" id="users">48,294</div> <div class="kpi-bottom"><span class="positive">↗ 8.4%</span><span>vs previous period</span></div> <svg class="sparkline cyan-line" viewBox="0 0 180 38" preserveAspectRatio="none"><path id="spark-2" d="" /></svg> </article> <article class="kpi-card"> <div class="kpi-top"><span>CONVERSION RATE</span><span class="kpi-icon green">↗</span></div> <div class="kpi-value" id="conversion">4.82%</div> <div class="kpi-bottom"><span class="positive">↗ 0.6%</span><span>vs previous period</span></div> <svg class="sparkline green-line" viewBox="0 0 180 38" preserveAspectRatio="none"><path id="spark-3" d="" /></svg> </article> <article class="kpi-card"> <div class="kpi-top"><span>AVG. SESSION</span><span class="kpi-icon orange">◷</span></div> <div class="kpi-value" id="session">06:42</div> <div class="kpi-bottom"><span class="negative">↘ 2.1%</span><span>vs previous period</span></div> <svg class="sparkline orange-line" viewBox="0 0 180 38" preserveAspectRatio="none"><path id="spark-4" d="" /></svg> </article> </section> <section class="main-grid"> <article class="panel traffic-panel"> <div class="panel-header"> <div> <div class="panel-label">PERFORMANCE ANALYTICS</div> <h2>Traffic & engagement</h2> <p>Monitor activity over time</p> </div> <div class="chart-legend"> <span><i class="legend-purple"></i> Visitors</span> <span><i class="legend-cyan"></i> Sessions</span> </div> </div> <div class="chart-summary"> <strong id="chart-total">48,294</strong> <span>visitors <b class="positive">+8.4%</b></span> <select id="chart-metric" aria-label="Chart metric"> <option value="traffic">Traffic</option> <option value="revenue">Revenue</option> <option value="engagement">Engagement</option> </select> </div> <div class="chart-area"> <div class="y-labels" id="y-labels"> <span>60k</span><span>45k</span><span>30k</span><span>15k</span><span>0</span> </div> <div class="plot"> <svg id="main-chart" viewBox="0 0 720 250" preserveAspectRatio="none" role="img" aria-label="Interactive performance line chart"> <defs> <linearGradient id="purple-fill" x1="0" y1="0" x2="0" y2="1"> <stop offset="0%" stop-color="#9875ff" stop-opacity=".28"/> <stop offset="100%" stop-color="#9875ff" stop-opacity="0"/> </linearGradient> <linearGradient id="cyan-fill" x1="0" y1="0" x2="0" y2="1"> <stop offset="0%" stop-color="#42c8d9" stop-opacity=".15"/> <stop offset="100%" stop-color="#42c8d9" stop-opacity="0"/> </linearGradient> </defs> <g id="chart-grid"></g> <path id="area-cyan" fill="url(#cyan-fill)"></path> <path id="area-purple" fill="url(#purple-fill)"></path> <path id="line-cyan" fill="none" stroke="#42c8d9" stroke-width="2.2" stroke-linecap="round"></path> <path id="line-purple" fill="none" stroke="#9875ff" stroke-width="2.5" stroke-linecap="round"></path> <g id="chart-points"></g> <line id="chart-crosshair" y1="0" y2="250" stroke="#aab0c8" stroke-dasharray="4 5" opacity="0"></line> <rect id="chart-hitbox" x="0" y="0" width="720" height="250" fill="transparent"></rect> </svg> <div class="x-labels" id="x-labels"></div> <div class="chart-tooltip" id="chart-tooltip"></div> </div> </div> </article> <article class="panel activity-panel"> <div class="panel-header"> <div> <div class="panel-label">LIVE MONITOR</div> <h2>Real-time activity</h2> <p><span class="live-dot"></span> Incoming events</p> </div> <span class="event-count" id="event-count">LIVE</span> </div> <div class="activity-total"> <strong id="live-events">1,284</strong> <span>events processed today</span> </div> <div class="event-list" id="event-list"></div> <div class="activity-footer"><span class="live-dot"></span> STREAM CONNECTED <span id="stream-time">NOW</span></div> </article> </section> <section class="secondary-grid"> <article class="panel"> <div class="panel-header"> <div><div class="panel-label">ACQUISITION</div><h2>Traffic sources</h2><p>Where visitors come from</p></div> <span class="panel-menu">•••</span> </div> <div class="source-content"> <div class="donut-wrap"> <svg viewBox="0 0 180 180" class="donut"> <circle cx="90" cy="90" r="67" fill="none" stroke="#28303d" stroke-width="19"/> <circle id="donut-1" cx="90" cy="90" r="67" fill="none" stroke="#9875ff" stroke-width="19" stroke-dasharray="0 421" transform="rotate(-90 90 90)"/> <circle id="donut-2" cx="90" cy="90" r="67" fill="none" stroke="#42c8d9" stroke-width="19" stroke-dasharray="0 421" transform="rotate(-90 90 90)"/> <circle id="donut-3" cx="90" cy="90" r="67" fill="none" stroke="#6bc99a" stroke-width="19" stroke-dasharray="0 421" transform="rotate(-90 90 90)"/> <circle id="donut-4" cx="90" cy="90" r="67" fill="none" stroke="#e7ad65" stroke-width="19" stroke-dasharray="0 421" transform="rotate(-90 90 90)"/> <text x="90" y="85" text-anchor="middle" fill="#f1f2f7" font-size="23" font-weight="700" id="donut-total">48k</text> <text x="90" y="103" text-anchor="middle" fill="#8993a5" font-size="9">VISITORS</text> </svg> </div> <div class="source-legend" id="source-legend"></div> </div> </article> <article class="panel"> <div class="panel-header"> <div><div class="panel-label">GEOGRAPHIC DISTRIBUTION</div><h2>Top regions</h2><p>Visitors by location</p></div> <span class="panel-menu">•••</span> </div> <div class="region-list" id="region-list"></div> </article> <article class="panel"> <div class="panel-header"> <div><div class="panel-label">DEVICE INTELLIGENCE</div><h2>Device breakdown</h2><p>Sessions by device type</p></div> <span class="panel-menu">•••</span> </div> <div class="device-content" id="device-content"></div> </article> </section> <section class="bottom-grid"> <article class="panel bars-panel"> <div class="panel-header"> <div><div class="panel-label">CONVERSION FUNNEL</div><h2>Customer journey</h2><p>From discovery to purchase</p></div> <span class="panel-menu">•••</span> </div> <div class="funnel" id="funnel"></div> </article> <article class="panel bars-panel"> <div class="panel-header"> <div><div class="panel-label">CONTENT PERFORMANCE</div><h2>Top categories</h2><p>Engagement by category</p></div> <span class="panel-menu">•••</span> </div> <div id="category-bars" class="category-bars"></div> </article> </section> <footer class="footer"> <span>NEXUS INTELLIGENCE PLATFORM <b>●</b> DEMO ENVIRONMENT</span> <span>ALL METRICS ARE SIMULATED <span id="footer-time"></span></span> </footer> </div> <!-- End your code here --> </body> </html>
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700;800&display=swap'); :root { --bg: #0b0e14; --panel: #121722; --panel2: #171e2b; --border: #252e3c; --text: #e8ebf2; --muted: #8792a5; --faint: #586477; --purple: #9875ff; --cyan: #42c8d9; --green: #6bc99a; --orange: #e7ad65; } * { box-sizing: border-box; } body { margin: 0; background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; } button, select { font: inherit; } button { cursor: pointer; } .nexus { max-width: 1440px; margin: auto; padding: 0 30px 20px; } .topbar { height: 68px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); } .brand, .top-actions, .brand-name, .environment, .live-indicator { display: flex; align-items: center; } .brand { gap: 12px; } .brand-symbol { display: grid; place-items: center; width: 32px; height: 32px; background: linear-gradient(140deg,#9875ff,#5946ba); border-radius: 8px; color: white; font-weight: 900; font-size: 18px; box-shadow: 0 0 20px #9875ff35; } .brand-name { font-size: 14px; font-weight: 800; letter-spacing: 1.4px; } .brand-name span { color: #768397; font-size: 10px; margin-left: 7px; font-weight: 500; } .environment { gap: 7px; padding: 5px 9px; border: 1px solid #315344; border-radius: 5px; color: #75c99c; font: 8px 'DM Mono',monospace; margin-left: 13px; letter-spacing: .7px; } .environment i, .live-indicator i, .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px #6bc99a; } .top-actions { gap: 17px; } .live-indicator { gap: 8px; color: #8d9caa; font: 9px 'DM Mono',monospace; letter-spacing: .8px; } .icon-button { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--panel); color: #a5b0bf; border-radius: 7px; } .user-avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: #34304d; border: 1px solid #64529c; color: #c2b2ff; font-size: 9px; font-weight: 800; } .dashboard-heading { display: flex; justify-content: space-between; align-items: end; padding: 27px 0 20px; } .breadcrumb, .panel-label { color: #78869a; font: 9px 'DM Mono',monospace; letter-spacing: 1.3px; } .breadcrumb span { color: var(--purple); margin: 0 7px; } .dashboard-heading h1 { font-size: 25px; margin: 8px 0 5px; letter-spacing: -.8px; } .dashboard-heading h1 span { color: #9eabc0; font-weight: 400; } .dashboard-heading p { color: var(--muted); font-size: 11px; margin: 0; } .heading-controls { text-align: right; } .date-control { display: flex; align-items: center; gap: 3px; border: 1px solid var(--border); background: var(--panel); border-radius: 7px; padding: 4px; } .date-control > span { color: var(--faint); padding: 0 8px; } .range { border: 0; border-radius: 5px; background: transparent; color: #8490a2; padding: 7px 10px; font: 9px 'DM Mono',monospace; } .range.active { background: #332a54; color: #c3b2ff; } .updated { color: #667487; font: 8px 'DM Mono',monospace; margin-top: 8px; letter-spacing: .5px; } .updated strong { color: #b4c0cd; font-weight: 500; margin-left: 5px; } .kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; } .kpi-card, .panel { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; } .kpi-card { min-width: 0; position: relative; padding: 16px 17px 12px; overflow: hidden; } .kpi-top { display: flex; align-items: center; justify-content: space-between; color: #8c99aa; font: 9px 'DM Mono',monospace; letter-spacing: .6px; } .kpi-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; font-weight: 800; font-size: 13px; } .kpi-icon.purple { background: #342a53; color: #b39bff; } .kpi-icon.cyan { background: #1b3c47; color: #5dd5e1; } .kpi-icon.green { background: #203d34; color: #83d7ac; } .kpi-icon.orange { background: #473727; color: #edbc79; } .kpi-value { font-size: clamp(22px,2.4vw,30px); font-weight: 700; letter-spacing: -1.2px; margin: 11px 0 7px; font-variant-numeric: tabular-nums; } .kpi-bottom { display: flex; gap: 8px; align-items: center; font-size: 9px; color: #758296; } .positive { color: #6dce9e !important; } .negative { color: #e28c8c !important; } .sparkline { position: absolute; bottom: 8px; right: 12px; width: 38%; height: 35px; overflow: visible; opacity: .8; } .sparkline path { fill: none; stroke: var(--purple); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } .sparkline.cyan-line path { stroke: var(--cyan); } .sparkline.green-line path { stroke: var(--green); } .sparkline.orange-line path { stroke: var(--orange); } .main-grid { display: grid; grid-template-columns: minmax(0,1.9fr) minmax(300px,1fr); gap: 12px; margin-top: 12px; } .panel { min-width: 0; padding: 17px; } .panel-header { display: flex; justify-content: space-between; align-items: start; gap: 10px; } .panel-header h2 { margin: 6px 0 4px; font-size: 14px; letter-spacing: -.2px; } .panel-header p { color: var(--muted); font-size: 9px; margin: 0; } .chart-legend { display: flex; gap: 13px; align-items: center; color: #8e9aab; font-size: 9px; padding-top: 8px; white-space: nowrap; } .chart-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; } .legend-purple { background: var(--purple); } .legend-cyan { background: var(--cyan); } .chart-summary { display: flex; align-items: baseline; gap: 9px; margin: 17px 0 8px; } .chart-summary > strong { font-size: 24px; letter-spacing: -.8px; font-variant-numeric: tabular-nums; } .chart-summary > span { color: #8995a6; font-size: 9px; } .chart-summary b { margin-left: 5px; } .chart-summary select { margin-left: auto; border: 1px solid var(--border); background: #192130; color: #aeb9c8; border-radius: 5px; padding: 6px 8px; font-size: 9px; outline: none; } .chart-area { height: 248px; display: flex; position: relative; } .y-labels { flex: 0 0 38px; display: flex; flex-direction: column; justify-content: space-between; color: #647286; font: 8px 'DM Mono',monospace; padding: 7px 0 21px; text-align: right; } .plot { position: relative; flex: 1; min-width: 0; } .plot svg { width: 100%; height: 220px; overflow: visible; } #chart-grid line { stroke: #28313f; stroke-width: 1; stroke-dasharray: 3 5; } #chart-hitbox { cursor: crosshair; } #chart-points circle { stroke: #121722; stroke-width: 3; fill: var(--purple); } .x-labels { display: flex; justify-content: space-between; color: #657286; font: 8px 'DM Mono',monospace; padding-top: 5px; } .chart-tooltip { display: none; position: absolute; z-index: 4; min-width: 115px; background: #252d3b; border: 1px solid #46516a; border-radius: 6px; padding: 8px 10px; color: #e9edf4; font-size: 9px; pointer-events: none; box-shadow: 0 8px 20px #0006; } .chart-tooltip strong { display: block; margin: 4px 0; font-size: 12px; } .chart-tooltip span { color: #9aa8b9; display: block; margin-top: 3px; } .activity-panel { display: flex; flex-direction: column; min-height: 355px; } .activity-panel .panel-header p { display: flex; gap: 7px; align-items: center; margin-top: 7px; } .live-dot { display: inline-block; width: 5px; height: 5px; } .event-count { background: #1c3c32; color: #79d1a3; padding: 5px 7px; border-radius: 4px; font: 8px 'DM Mono',monospace; } .activity-total { display: flex; align-items: baseline; gap: 8px; padding: 15px 0 10px; border-bottom: 1px solid var(--border); } .activity-total strong { font-size: 24px; font-variant-numeric: tabular-nums; } .activity-total span { color: #8794a6; font-size: 9px; } .event-list { flex: 1; overflow: hidden; } .event { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #222b37; animation: event-in .35s ease both; } @keyframes event-in { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } } .event-icon { flex: 0 0 27px; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: #242c3c; font-size: 12px; } .event-text { min-width: 0; flex: 1; } .event-text strong { display: block; color: #c9d0db; font-size: 9px; font-weight: 600; } .event-text span { display: block; color: #778599; font-size: 8px; margin-top: 3px; } .event-time { color: #738094; font: 8px 'DM Mono',monospace; white-space: nowrap; } .activity-footer { display: flex; gap: 8px; align-items: center; padding-top: 12px; color: #6f8090; font: 8px 'DM Mono',monospace; letter-spacing: .7px; } .activity-footer #stream-time { margin-left: auto; } .secondary-grid { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 12px; margin-top: 12px; } .secondary-grid .panel { min-height: 245px; } .panel-menu { color: #68768a; letter-spacing: 2px; font-size: 13px; } .source-content { display: flex; align-items: center; justify-content: space-around; gap: 10px; padding-top: 10px; } .donut-wrap { width: 160px; flex: 0 1 160px; } .donut { width: 100%; overflow: visible; } .source-legend { flex: 1; display: flex; flex-direction: column; gap: 12px; } .source-item { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: #9ca7b6; font-size: 9px; } .source-item span:first-child { white-space: nowrap; } .source-item i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; } .source-item strong { color: #d5dbe4; font-size: 9px; } .region-list { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; } .region-top { display: flex; justify-content: space-between; color: #b5bfcc; font-size: 9px; margin-bottom: 6px; } .region-top strong { color: #e0e5eb; font-size: 9px; } .region-track { height: 5px; background: #252e3c; border-radius: 5px; overflow: hidden; } .region-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg,#8061e8,#53c6d7); } .device-content { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; } .device-row { display: grid; grid-template-columns: 27px 1fr auto; align-items: center; gap: 9px; } .device-icon { width: 27px; height: 27px; border-radius: 7px; display: grid; place-items: center; background: #222c3b; color: #a5b4c7; font-size: 12px; } .device-label { color: #bdc6d2; font-size: 9px; } .device-percent { color: #e2e7ed; font: 10px 'DM Mono',monospace; } .device-track { grid-column: 2/4; height: 4px; border-radius: 5px; background: #27313f; margin-top: -3px; } .device-fill { height: 100%; border-radius: 5px; background: var(--cyan); } .bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; } .bars-panel { min-height: 235px; } .funnel { display: flex; align-items: end; gap: 12px; height: 130px; padding: 14px 10px 0; } .funnel-step { flex: 1; text-align: center; min-width: 0; } .funnel-bar { height: 75px; display: flex; align-items: start; justify-content: center; padding-top: 8px; border-radius: 5px 5px 0 0; color: #f0edff; font: 9px 'DM Mono',monospace; margin: auto auto 8px; min-width: 35px; } .funnel-step strong { display: block; color: #b6c0ce; font-size: 9px; } .funnel-step small { color: #718096; font-size: 8px; } .category-bars { display: flex; flex-direction: column; gap: 14px; margin-top: 19px; } .category-row { display: grid; grid-template-columns: 85px 1fr 34px; align-items: center; gap: 10px; } .category-row > span { color: #aab5c4; font-size: 9px; } .category-track { height: 7px; background: #26303d; border-radius: 6px; overflow: hidden; } .category-track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg,#8968ed,#46c4d8); } .category-row strong { color: #c9d1dd; text-align: right; font: 9px 'DM Mono',monospace; } .footer { display: flex; justify-content: space-between; gap: 12px; color: #647185; font: 8px 'DM Mono',monospace; letter-spacing: .6px; padding: 18px 2px 5px; } .footer b { color: var(--green); margin: 0 5px; } .footer #footer-time { margin-left: 12px; color: #8693a4; } @media(max-width: 950px) { .nexus { padding: 0 17px 18px; } .main-grid { grid-template-columns: 1fr; } .activity-panel { min-height: auto; } .event-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; } .secondary-grid { grid-template-columns: 1fr 1fr; } .secondary-grid .panel:first-child { grid-column: span 2; } .source-content { justify-content: center; } .donut-wrap { max-width: 150px; } } @media(max-width: 600px) { .nexus { padding: 0 11px 15px; } .topbar { height: 58px; } .brand-name { font-size: 11px; } .brand-name span { font-size: 8px; } .environment { display: none; } .top-actions { gap: 10px; } .dashboard-heading { align-items: start; flex-direction: column; gap: 16px; } .heading-controls { width: 100%; text-align: left; } .date-control { width: fit-content; } .updated { margin-top: 7px; } .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .kpi-card { padding: 12px; } .kpi-top { font-size: 8px; } .kpi-value { font-size: 22px; } .kpi-bottom { font-size: 8px; gap: 5px; } .sparkline { opacity: .4; } .panel { padding: 13px; } .chart-legend { gap: 8px; font-size: 8px; } .chart-summary > strong { font-size: 20px; } .chart-area { height: 220px; } .plot svg { height: 195px; } .event-list { grid-template-columns: 1fr; } .secondary-grid { grid-template-columns: 1fr; } .secondary-grid .panel:first-child { grid-column: auto; } .secondary-grid .panel { min-height: auto; } .bottom-grid { grid-template-columns: 1fr; } .footer { flex-direction: column; line-height: 1.8; } }
const $ = id => document.getElementById(id); let currentRange = "24H"; let currentMetric = "traffic"; let livePaused = false; let liveCount = 1284; let liveTimer; let eventTimer; const metricConfig = { traffic: { title: "visitors", total: 48294, max: 60000, suffix: "", primary: [31,35,29,40,37,46,42,52,48,57,49,55,62,54,66,61,73,68,78,71,83,77,88,80], secondary: [23,26,24,30,28,33,31,38,34,40,37,42,45,40,49,46,54,51,58,55,62,58,66,61] }, revenue: { title: "revenue", total: 284590, max: 350000, suffix: "$", primary: [20,24,21,31,29,37,33,41,38,47,42,52,48,56,54,63,60,69,65,75,70,82,77,88], secondary: [14,18,16,22,20,27,24,30,28,34,31,39,35,42,40,47,44,52,49,56,53,62,58,65] }, engagement: { title: "engagement", total: 6.42, max: 10, suffix: "", primary: [40,43,38,46,48,45,53,49,57,54,62,58,64,61,68,65,72,69,76,73,80,76,85,82], secondary: [25,28,24,32,30,35,33,39,35,42,39,45,42,48,45,52,49,56,53,59,56,63,60,67] } }; const rangeLabels = { "24H": ["00:00","02:00","04:00","06:00","08:00","10:00","12:00","14:00","16:00","18:00","20:00","22:00"], "7D": ["MON","TUE","WED","THU","FRI","SAT","SUN"], "30D": ["01","04","07","10","13","16","19","22","25","28","30"], "90D": ["SEP","OCT","NOV","DEC"] }; function makePath(values, width, height) { return values.map((value, i) => { const x = i / (values.length - 1) * width; const y = height - value / 100 * height; return `${i === 0 ? "M" : "L"} ${x.toFixed(1)} ${y.toFixed(1)}`; }).join(" "); } function makeArea(values, width, height) { return makePath(values, width, height) + ` L ${width} ${height} L 0 ${height} Z`; } function scaledValues(values, count) { return Array.from({ length: count }, (_, i) => { const position = i / (count - 1) * (values.length - 1); const low = Math.floor(position); const high = Math.min(values.length - 1, low + 1); const blend = position - low; return values[low] * (1 - blend) + values[high] * blend; }); } function getChartData() { const config = metricConfig[currentMetric]; let count = { "24H": 24, "7D": 28, "30D": 30, "90D": 36 }[currentRange]; let primary = scaledValues(config.primary, count); let secondary = scaledValues(config.secondary, count); // Range variations make each view visually distinct. const rangeMultiplier = { "24H": 1, "7D": .94, "30D": 1.05, "90D": .91 }[currentRange]; primary = primary.map(v => Math.max(4, Math.min(98, v * rangeMultiplier))); secondary = secondary.map(v => Math.max(3, Math.min(92, v * rangeMultiplier))); return { primary, secondary, config }; } function drawChart() { const { primary, secondary, config } = getChartData(); const width = 720; const height = 220; const grid = $("chart-grid"); grid.innerHTML = Array.from({ length: 5 }, (_, i) => { const y = i * height / 4; return `<line x1="0" y1="${y}" x2="${width}" y2="${y}"/>`; }).join(""); $("line-purple").setAttribute("d", makePath(primary, width, height)); $("line-cyan").setAttribute("d", makePath(secondary, width, height)); $("area-purple").setAttribute("d", makeArea(primary, width, height)); $("area-cyan").setAttribute("d", makeArea(secondary, width, height)); const labels = rangeLabels[currentRange]; $("x-labels").innerHTML = labels.map(label => `<span>${label}</span>`).join(""); const scale = config.max / 4; $("y-labels").innerHTML = Array.from({ length: 5 }, (_, i) => { const value = scale * (4 - i); return `<span>${currentMetric === "revenue" ? "$" + Math.round(value / 1000) + "k" : currentMetric === "engagement" ? value.toFixed(1) + "m" : Math.round(value / 1000) + "k"}</span>`; }).join(""); const points = primary.map((v, i) => { if (i % Math.ceil(primary.length / 12) !== 0 && i !== primary.length - 1) return ""; const x = i / (primary.length - 1) * width; const y = height - v / 100 * height; return `<circle cx="${x}" cy="${y}" r="4"/>`; }).join(""); $("chart-points").innerHTML = points; const displayTotal = currentMetric === "revenue" ? "$284,590" : currentMetric === "engagement" ? "6.42m" : "48,294"; $("chart-total").textContent = displayTotal; } function updateSparklines() { const samples = [ [20,35,29,45,39,55,46,62,54,72,66,82,76,91], [30,26,40,34,49,42,56,48,67,61,73,68,86,81], [25,38,31,45,39,52,46,61,56,72,66,78,73,88], [85,76,80,68,73,60,66,54,62,47,53,39,44,35] ]; samples.forEach((values, index) => { const path = values.map((value, i) => { const x = i / (values.length - 1) * 180; const y = 35 - value / 100 * 31; return `${i ? "L" : "M"}${x},${y}`; }).join(" "); $("spark-" + (index + 1)).setAttribute("d", path); }); } // Interactive chart tooltip function setupChartInteraction() { const hitbox = $("chart-hitbox"); const crosshair = $("chart-crosshair"); const tooltip = $("chart-tooltip"); hitbox.addEventListener("pointermove", event => { const rect = hitbox.getBoundingClientRect(); const x = (event.clientX - rect.left) / rect.width * 720; const index = Math.round(x / 720 * (getChartData().primary.length - 1)); const data = getChartData(); const value = data.primary[index]; const second = data.secondary[index]; const px = index / (data.primary.length - 1) * 720; crosshair.setAttribute("x1", px); crosshair.setAttribute("x2", px); crosshair.setAttribute("opacity", ".7"); const formatted = currentMetric === "revenue" ? "$" + Math.round(value / 100 * data.config.max).toLocaleString() : currentMetric === "engagement" ? (value / 100 * data.config.max).toFixed(2) + "m" : Math.round(value / 100 * data.config.max).toLocaleString(); const secondFormatted = currentMetric === "revenue" ? "$" + Math.round(second / 100 * data.config.max).toLocaleString() : currentMetric === "engagement" ? (second / 100 * data.config.max).toFixed(2) + "m" : Math.round(second / 100 * data.config.max).toLocaleString(); tooltip.innerHTML = `<span>${rangeLabels[currentRange][Math.min(rangeLabels[currentRange].length - 1, Math.floor(index / data.primary.length * rangeLabels[currentRange].length))]}</span> <strong>${formatted}</strong><span>Secondary: ${secondFormatted}</span>`; tooltip.style.display = "block"; tooltip.style.left = Math.min(rect.width - 130, Math.max(0, event.clientX - rect.left + 10)) + "px"; tooltip.style.top = Math.max(0, event.clientY - rect.top - 15) + "px"; }); hitbox.addEventListener("pointerleave", () => { tooltip.style.display = "none"; crosshair.setAttribute("opacity", "0"); }); } $("chart-metric").addEventListener("change", event => { currentMetric = event.target.value; drawChart(); }); document.querySelectorAll(".range").forEach(button => { button.addEventListener("click", () => { document.querySelectorAll(".range").forEach(b => b.classList.remove("active")); button.classList.add("active"); currentRange = button.dataset.range; drawChart(); }); }); // Traffic source donut const sources = [ { name: "Organic search", value: 42, color: "#9875ff" }, { name: "Direct", value: 27, color: "#42c8d9" }, { name: "Social media", value: 19, color: "#6bc99a" }, { name: "Referral", value: 12, color: "#e7ad65" } ]; function drawDonut() { let offset = 0; const circumference = 2 * Math.PI * 67; sources.forEach((source, index) => { const circle = $("donut-" + (index + 1)); const length = source.value / 100 * circumference; circle.setAttribute("stroke-dasharray", `${length} ${circumference - length}`); circle.setAttribute("stroke-dashoffset", -offset); offset += length; }); $("source-legend").innerHTML = sources.map(source => ` <div class="source-item"> <span><i style="background:${source.color}"></i>${source.name}</span> <strong>${source.value}%</strong> </div> `).join(""); } // Regions const regions = [ ["North America", 38, "18.4k"], ["Europe", 27, "13.1k"], ["Asia Pacific", 21, "10.2k"], ["South America", 9, "4.3k"], ["Other", 5, "2.2k"] ]; function drawRegions() { $("region-list").innerHTML = regions.map(([name, value, count]) => ` <div class="region-item"> <div class="region-top"><span>${name}</span><strong>${count} <small>${value}%</small></strong></div> <div class="region-track"><div class="region-fill" style="width:${value}%"></div></div> </div> `).join(""); } // Devices const devices = [ { name: "Desktop", value: 54, icon: "▣", color: "#9875ff" }, { name: "Mobile", value: 36, icon: "▯", color: "#42c8d9" }, { name: "Tablet", value: 10, icon: "▤", color: "#6bc99a" } ]; function drawDevices() { $("device-content").innerHTML = devices.map(device => ` <div class="device-row"> <div class="device-icon">${device.icon}</div> <span class="device-label">${device.name}</span> <strong class="device-percent">${device.value}%</strong> <div class="device-track"><div class="device-fill" style="width:${device.value}%;background:${device.color}"></div></div> </div> `).join(""); } // Conversion funnel const funnelData = [ { label: "Visitors", count: "48.2k", percent: 100, color: "#8061e8" }, { label: "Product views", count: "32.4k", percent: 67, color: "#715fce" }, { label: "Add to cart", count: "12.8k", percent: 42, color: "#5a83ce" }, { label: "Checkout", count: "6.4k", percent: 27, color: "#429eaf" }, { label: "Purchase", count: "2.3k", percent: 14, color: "#4cb68c" } ]; function drawFunnel() { $("funnel").innerHTML = funnelData.map(step => ` <div class="funnel-step"> <div class="funnel-bar" style="height:${step.percent * .72 + 16}px;background:${step.color}">${step.count}</div> <strong>${step.percent}%</strong> <small>${step.label}</small> </div> `).join(""); } // Content categories const categories = [ ["Technology", 82], ["Lifestyle", 69], ["Business", 58], ["Education", 44], ["Entertainment", 31] ]; function drawCategories() { $("category-bars").innerHTML = categories.map(([name, value]) => ` <div class="category-row"> <span>${name}</span> <div class="category-track"><i style="width:${value}%"></i></div> <strong>${value}%</strong> </div> `).join(""); } // Simulated event stream const eventTypes = [ { icon: "🛒", title: "New purchase completed", detail: "Order #NX-" }, { icon: "👤", title: "New user registered", detail: "Account created" }, { icon: "📱", title: "Mobile session started", detail: "iOS · North America" }, { icon: "💳", title: "Payment processed", detail: "Transaction verified" }, { icon: "🔍", title: "Product viewed", detail: "Organic search · Desktop" }, { icon: "⭐", title: "New review submitted", detail: "Customer feedback" }, { icon: "📈", title: "Conversion event", detail: "Campaign · Direct" } ]; const eventHistory = []; function addEvent() { const type = eventTypes[Math.floor(Math.random() * eventTypes.length)]; const id = Math.floor(10000 + Math.random() * 89999); eventHistory.unshift({ ...type, detail: type.detail + " " + id, time: new Date() }); if (eventHistory.length > 5) eventHistory.pop(); $("event-list").innerHTML = eventHistory.map(event => ` <div class="event"> <div class="event-icon">${event.icon}</div> <div class="event-text"> <strong>${event.title}</strong> <span>${event.detail}</span> </div> <span class="event-time">NOW</span> </div> `).join(""); liveCount += Math.floor(Math.random() * 5) + 1; $("live-events").textContent = liveCount.toLocaleString(); } function updateClock() { const now = new Date(); const time = now.toLocaleTimeString("en-US", { hour12: false }); $("last-updated").textContent = time; $("footer-time").textContent = time; } function startLive() { clearInterval(liveTimer); clearInterval(eventTimer); liveTimer = setInterval(() => { if (livePaused) return; updateClock(); const revenue = 284590 + Math.floor(Math.random() * 800); const users = 48294 + Math.floor(Math.random() * 120); const conversion = 4.82 + (Math.random() - .5) * .08; const minutes = 6; const seconds = Math.floor(Math.random() * 60); $("revenue").textContent = "$" + revenue.toLocaleString(); $("users").textContent = users.toLocaleString(); $("conversion").textContent = conversion.toFixed(2) + "%"; $("session").textContent = `${String(minutes).padStart(2,"0")}:${String(seconds).padStart(2,"0")}`; }, 2200); eventTimer = setInterval(() => { if (!livePaused) addEvent(); }, 2400); } $("pause-live").addEventListener("click", () => { livePaused = !livePaused; $("pause-live").textContent = livePaused ? "▶" : "Ⅱ"; $("live-status").textContent = livePaused ? "PAUSED" : "LIVE DATA"; $("event-count").textContent = livePaused ? "PAUSED" : "LIVE"; }); updateSparklines(); drawChart(); setupChartInteraction(); drawDonut(); drawRegions(); drawDevices(); drawFunnel(); drawCategories(); for (let i = 0; i < 5; i++) addEvent(); updateClock(); startLive();
terminal
JavaScript Console
Preview
Clear
close
›
Run