The reliable pattern is a relatively positioned wrapper containing the image and an absolutely positioned graph layer. Size both layers from the same wrapper, use percentage insets or a shared coordinate system for responsive layouts, and choose inline SVG when the graph must stay sharp and interactive. Use canvas when you must export one combined bitmap.
The basic HTML/CSS overlay
Start with one container that defines the displayed image area. Give it position: relative; give the graph position: absolute. The graph then occupies coordinates inside the image rather than the page.
<div class="image-chart">
<img src="photo.jpg" alt="Sales region map">
<div class="graph" aria-label="Quarterly sales graph">
<!-- inline SVG, canvas, or chart-library output -->
</div>
</div>
.image-chart {
position: relative;
width: min(100%, 900px);
aspect-ratio: 16 / 10;
}
.image-chart > img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.graph {
position: absolute;
inset: 10% 8% 12% 12%;
pointer-events: none;
}
The inset values place the graph 10% from the top, 8% from the right, 12% from the bottom and 12% from the left. Percentages keep the overlay aligned as the wrapper changes size. Use fixed pixels only when the image has a fixed, nonresponsive size.
Keep the coordinate systems identical
An overlay can drift even with correct CSS if the image is cropped differently from the graph. The wrapper’s aspect ratio, the image’s object-fit behavior and the graph’s view box must describe the same visible rectangle. If the source image is 1600×1000, for example, use a 16:10 wrapper or account for the crop introduced by another ratio. Avoid positioning against the viewport or an unrelated parent.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Make the overlay interactive only when needed
pointer-events: none lets clicks reach controls on the image or page underneath. Remove it when the graph has tooltips, links or draggable points. Give the graph a meaningful accessible name with an SVG aria-label, a canvas fallback description, or a nearby text equivalent.
Use inline SVG for a sharp graph
Inline SVG is usually the best choice for a line, bar or annotation graph that must remain crisp at different sizes. It can be styled with CSS, labelled for assistive technology and updated by JavaScript. Place the SVG in the same absolute layer and define a stable viewBox; the browser scales that coordinate system with the element.
<div class="image-chart">
<img src="photo.jpg" alt="Product photo">
<svg class="graph" viewBox="0 0 100 60" role="img" aria-label="Monthly revenue">
<polyline points="0,50 20,42 40,45 60,25 80,30 100,10"
fill="none" stroke="crimson" stroke-width="2" />
</svg>
</div>
.graph {
position: absolute;
inset: 10% 8% 12% 12%;
width: auto;
height: auto;
overflow: visible;
}
.graph polyline {
vector-effect: non-scaling-stroke;
}
The SVG’s coordinates run from 0 to 100 horizontally and 0 to 60 vertically, independent of CSS pixels. Add axes, grid lines, labels and data markers as additional SVG elements. For a data-driven graph, convert each data value to the same view-box coordinates before writing the points.
SVG as an image versus inline SVG
An SVG used as a CSS background or an external image is useful for decorative, static artwork. It is not a good place for interactive chart logic: scripts are disabled in image context and external resources may not load. Inline SVG keeps the elements in the document, where CSS, event handlers and accessible labels work normally.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Use canvas when pixels or export matter
Canvas is appropriate when JavaScript calculates many marks, when you need pixel-level drawing, or when the final result must be one raster image. A CSS background behind a canvas is visible on screen but is not part of the canvas bitmap. Consequently, exporting the canvas without first drawing the source image produces a graph on a transparent or blank background.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
<div class="image-chart">
<canvas id="graph" aria-label="Monthly revenue graph" role="img">
Monthly revenue graph: 42, 51, 48, 67, 63 and 82.
</canvas>
</div>
.image-chart {
position: relative;
width: min(100%, 900px);
aspect-ratio: 16 / 10;
}
#graph {
position: absolute;
inset: 10% 8% 12% 12%;
width: 82%;
height: 78%;
}
const canvas = document.querySelector('#graph');
const ctx = canvas.getContext('2d');
const image = new Image();
image.onload = () => {
const ratio = window.devicePixelRatio || 1;
const cssWidth = canvas.clientWidth;
const cssHeight = canvas.clientHeight;
canvas.width = Math.round(cssWidth * ratio);
canvas.height = Math.round(cssHeight * ratio);
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
ctx.drawImage(image, 0, 0, cssWidth, cssHeight);
ctx.strokeStyle = 'crimson';
ctx.lineWidth = 3;
ctx.beginPath();
[[0.00,0.83],[0.20,0.70],[0.40,0.75],[0.60,0.42],
[0.80,0.50],[1.00,0.17]].forEach(([x, y], i) => {
const px = x * cssWidth;
const py = y * cssHeight;
i ? ctx.lineTo(px, py) : ctx.moveTo(px, py);
});
ctx.stroke();
};
image.src = 'photo.jpg';
Set the bitmap dimensions separately from the CSS dimensions. Multiplying by the device-pixel ratio keeps lines sharp on high-density screens while the CSS size remains responsive. In production, redraw after a resize if the canvas dimensions change.
Export the combined image
Only pixels drawn into the canvas are exported. Draw the source image first, then axes, grid, labels and data. Once drawing finishes, call canvas.toBlob() or canvas.toDataURL().
canvas.toBlob(blob => {
const link = document.createElement('a');
link.download = 'graph-over-photo.png';
link.href = URL.createObjectURL(blob);
link.click();
URL.revokeObjectURL(link.href);
}, 'image/png');
If the image comes from another origin, the server must permit the request with suitable CORS headers and the image must be loaded with crossOrigin = 'anonymous' before drawing. Otherwise the canvas becomes tainted and export is blocked by the browser.
Choose the right implementation
| Approach | Best use | Main limitation |
|---|---|---|
| HTML/CSS overlay | Labels, annotations or a responsive graph over an image | Layout coordinates need maintenance when the image crop changes |
| Inline SVG | Scalable, stylable, accessible vector graphs | More markup; external-image SVG has script and resource restrictions |
| Canvas | Pixel drawing, many marks or one-image export | Accessibility must be supplied separately; CSS backgrounds are not export pixels |
| Chart library | Scales, tooltips, updates and complex data handling | Overlay and export behavior depends on the library’s APIs |
Overlaying a chart-library graph
A chart library can render into the same absolute layer as the image. If a label or icon must follow a data point, wait for the library’s ready or render event, obtain the plotted coordinate, and position the overlay from that coordinate rather than guessing from the page. This is essential when axes, margins or responsive resizing are computed by the library.
Export is a separate concern. Some libraries render a chart but do not automatically include an HTML image behind it in the exported bitmap. In Chart.js, for example, combining the image and chart requires a custom plugin that draws the image into the chart canvas before the chart is rendered. Test the export path independently from the on-screen overlay.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Responsive and accessible design checklist
- Give the wrapper one source of truth for width, height and aspect ratio.
- Use percentage insets or a shared SVG view box, not page coordinates.
- Verify alignment at narrow, wide and high-density viewport sizes.
- Choose
object-fit: containwhen cropping would hide graph landmarks; usecoveronly when the crop is intentional. - Provide an
altdescription for the image and a separate name or text summary for the graph. - Use sufficient contrast between graph marks and the photograph; add a translucent panel behind labels when necessary.
- Do not communicate values by color alone. Include labels, patterns or text.
- Allow pointer events and keyboard focus when the graph contains controls.
- For canvas, include fallback text inside the element and expose the same data in nearby HTML.
Common failures and fixes
The graph is behind the image
Check that the wrapper is position: relative, the graph is position: absolute, and the graph appears after the image in the DOM. Add a deliberate z-index if another positioned element creates a stacking context.
The graph moves when the window resizes
The image and graph are using different dimensions or crop rules. Put both in the same wrapper, make both fill that wrapper, and use percentages or a shared view box. If a library calculates plot margins, reposition dependent labels after its resize or render event.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Only part of the graph is visible
An ancestor may have overflow: hidden, or the graph’s inset may place marks outside its box. Inspect the wrapper in developer tools, temporarily set overflow: visible, and confirm the SVG view box or canvas CSS width and height.
The exported PNG has no background
A CSS background is display-only for canvas export. Load the image, wait for onload, draw it with drawImage, then draw the graph and export. Check CORS headers if the source is remote.
Canvas export throws a security error
The canvas is tainted by a cross-origin image. Serve the image with an appropriate Access-Control-Allow-Origin response and set image.crossOrigin = 'anonymous' before assigning src; otherwise use a same-origin copy.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Text or lines look blurry
For SVG, use a view box and avoid unnecessary rasterization. For canvas, size the bitmap at CSS dimensions multiplied by devicePixelRatio, scale the drawing context, and redraw after resizing.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesClicks do not reach the page
Set pointer-events: none on a decorative graph. For an interactive graph, remove that rule and implement keyboard-focusable controls with explicit labels.
Or skip the browser setup
If you need a rendered screenshot rather than a hand-built browser composition, ScreenshotNeo captures a URL with one request. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the complete parameter list and output details in the ScreenshotNeo documentation. The same service can capture full pages, a CSS-selected element, dark mode, device presets, retina output, PDFs, HTML/CSS, custom JavaScript, hidden selectors, network-idle waits, blocked resources, custom headers and cookies, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks and up to 100 URLs per bulk call.
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.
FAQ
Can CSS alone draw a data graph?
CSS can position and style an overlay, but it is not a practical data-plotting engine. Use SVG, canvas or a chart library for axes, scales and marks, then place that output with CSS.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Should I use an SVG or canvas for a social-media image?
Use SVG while editing or when sharp scaling and accessibility matter. Use canvas when the deliverable must be a single raster file and you control the image-loading and export steps.
How do I keep a marker attached to a moving chart point?
Calculate the point in the graph’s own coordinate system and position the marker inside the same wrapper. Recalculate after data, font or container-size changes rather than storing a page-level pixel coordinate.
Frequently Asked Questions
Can CSS alone draw a data graph?
CSS can position and style an overlay, but SVG, canvas or a chart library should render the actual data marks and scales.
Should I use SVG or canvas for a downloadable image?
Use SVG for editable, sharp and accessible graphics; use canvas when you need one raster export and can draw both the source image and graph into the bitmap.
Why does a canvas export omit my background image?
A CSS background is not canvas bitmap data. Load the image and draw it with drawImage before drawing the graph and calling toBlob or toDataURL.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

