Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ export default defineConfig({
text: "Configuration",
items: [
{ text: "Graph", link: "/api/graph" },
{ text: "Linees", link: "/api/line-options" },
{ text: "Lines", link: "/api/line-options" },
{ text: "Grid", link: "/api/grid-options" },
{ text: "Scale", link: "/api/scale-options" },
{ text: "Title", link: "/api/title-options" },
{ text: "Legend", link: "/api/legend-options" },
{ text: "Tooltip", link: "/api/tooltip-options" },
],
},
],
Expand All @@ -74,6 +75,7 @@ export default defineConfig({
{ text: "Scale", link: "/api/scale-options" },
{ text: "Title", link: "/api/title-options" },
{ text: "Legend", link: "/api/legend-options" },
{ text: "Tooltip", link: "/api/tooltip-options" },
],
},
],
Expand Down
21 changes: 18 additions & 3 deletions docs/.vitepress/theme/components/GraphDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ const computedOptions = computed(() => {
if (baseOptions.title) {
baseOptions.title = { ...baseOptions.title, colour: "#dfdfd6" };
}
// Apply dark mode tooltip styling
if (baseOptions.tooltip?.enabled) {
baseOptions.tooltip = {
...baseOptions.tooltip,
trackingLine: {
...baseOptions.tooltip?.trackingLine,
colour: baseOptions.tooltip?.trackingLine?.colour ?? "rgba(255, 255, 255, 0.5)",
},
content: {
...baseOptions.tooltip?.content,
backgroundColor: baseOptions.tooltip?.content?.backgroundColor ?? "rgba(30, 30, 30, 0.95)",
textColour: baseOptions.tooltip?.content?.textColour ?? "#dfdfd6",
},
};
}
}

return baseOptions;
Expand Down Expand Up @@ -160,7 +175,7 @@ function renderGraph() {
// Update debug metrics
debugMetrics.value = {
renderTime: Math.round((endTime - startTime) * 100) / 100,
canvasWidth: 600,
canvasWidth: props.width,
canvasHeight: props.height,
dataPoints: totalDataPoints,
seriesCount: props.lines.length,
Expand Down Expand Up @@ -205,8 +220,8 @@ watch(
<div class="graph-demo">
<!-- Live Preview -->
<div class="graph-demo-preview">
<div :id="containerId" class="graph-container" :style="{ height: `${height}px` }">
<canvas :width="600" :height="height" />
<div :id="containerId" class="graph-container" :style="{ height: `${height}px`, width: `${width}px` }">
<canvas :width="width" :height="height" />
</div>
</div>

Expand Down
45 changes: 45 additions & 0 deletions docs/.vitepress/theme/components/InteractiveDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const controls = reactive({

// Animation
animate: true,

// Tooltip options
showTooltip: true,
tooltipMode: "nearest" as "nearest" | "interpolated",
});

// Sample data
Expand Down Expand Up @@ -86,6 +90,10 @@ const graphOptions = computed(() => ({
enabled: controls.animate,
duration: 800,
},
tooltip: {
enabled: controls.showTooltip,
mode: controls.tooltipMode,
},
}));

// Computed lines
Expand Down Expand Up @@ -140,6 +148,14 @@ const graph = new Graph.Graph(
draw: ${controls.showLegend},
position: "${controls.legendPosition}",
},
tooltip: {
enabled: ${controls.showTooltip},
mode: "${controls.tooltipMode}",
},
animation: {
enabled: ${controls.animate},
duration: 800,
},
},
[
{
Expand Down Expand Up @@ -303,6 +319,35 @@ async function copyCode() {
</div>
</div>

<!-- Tooltip Section -->
<div class="control-section">
<h4>Tooltip</h4>
<div class="control-group">
<label class="checkbox">
<input type="checkbox" v-model="controls.showTooltip" />
<span>Enable Tooltip</span>
</label>
<label>
<span>Mode</span>
<select v-model="controls.tooltipMode" :disabled="!controls.showTooltip">
<option value="nearest">Nearest</option>
<option value="interpolated">Interpolated</option>
</select>
</label>
</div>
</div>

<!-- Animation Section -->
<div class="control-section">
<h4>Animation</h4>
<div class="control-group">
<label class="checkbox">
<input type="checkbox" v-model="controls.animate" />
<span>Enable Animation</span>
</label>
</div>
</div>

<!-- Line 1 Section -->
<div class="control-section">
<h4>Series A</h4>
Expand Down
Loading