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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# oxfmt reformat
b29460dec6b016e5da18c801959f203c1bc7c639
24 changes: 12 additions & 12 deletions .github/workflows/auto-assign-reviewer.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Auto-assign reviewer
on:
pull_request:
types: [opened]
pull_request:
types: [opened]

jobs:
assign-reviewer:
if: github.event.pull_request.user.login != 'feds01'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Request review from feds01
run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer feds01
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
assign-reviewer:
if: github.event.pull_request.user.login != 'feds01'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Request review from feds01
run: gh pr edit ${{ github.event.pull_request.number }} --add-reviewer feds01
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": false,
"printWidth": 80,
"sortPackageJson": false,
"ignorePatterns": []
}
28 changes: 22 additions & 6 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export default defineConfig({
{
text: "Getting Started",
items: [
{ text: "Installation", link: "/guide/getting-started" },
{
text: "Installation",
link: "/guide/getting-started",
},
{ text: "Examples", link: "/guide/basic" },
{ text: "Playground", link: "/guide/playground" },
],
Expand All @@ -57,7 +60,10 @@ export default defineConfig({
{
text: "Getting Started",
items: [
{ text: "Installation", link: "/guide/getting-started" },
{
text: "Installation",
link: "/guide/getting-started",
},
{ text: "Examples", link: "/guide/basic" },
{ text: "Playground", link: "/guide/playground" },
],
Expand Down Expand Up @@ -94,13 +100,21 @@ export default defineConfig({
{ text: "Line", link: "/reference/core/line" },
{ text: "Axis", link: "/reference/core/axis" },
{ text: "Scale", link: "/reference/core/scale" },
{ text: "Animation", link: "/reference/core/animation" },
{ text: "Interpolation", link: "/reference/core/interpolation" },
{
text: "Animation",
link: "/reference/core/animation",
},
{
text: "Interpolation",
link: "/reference/core/interpolation",
},
],
},
{
text: "Legend",
items: [{ text: "Manager", link: "/reference/legend/manager" }],
items: [
{ text: "Manager", link: "/reference/legend/manager" },
],
},
{
text: "Utilities",
Expand All @@ -112,7 +126,9 @@ export default defineConfig({
],
},

socialLinks: [{ icon: "github", link: "https://github.com/feds01/Graphika" }],
socialLinks: [
{ icon: "github", link: "https://github.com/feds01/Graphika" },
],

footer: {
message: "Released under the ISC License.",
Expand Down
98 changes: 78 additions & 20 deletions docs/.vitepress/theme/components/GraphDemo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<script setup lang="ts">
import { ref, shallowRef, onMounted, watch, watchEffect, computed, nextTick } from "vue";
import {
ref,
shallowRef,
onMounted,
watch,
watchEffect,
computed,
nextTick,
} from "vue";
import type { PropType } from "vue";
import { useData } from "vitepress";

Expand Down Expand Up @@ -70,7 +78,9 @@ const debugMetrics = ref({
// Computed options with animation merged in
const computedOptions = computed(() => {
// Deep clone to avoid shared references between component instances
const baseOptions: Graphika.Graph.BasicGraphOptions = JSON.parse(JSON.stringify(props.options));
const baseOptions: Graphika.Graph.BasicGraphOptions = JSON.parse(
JSON.stringify(props.options)
);
if (props.animate) {
baseOptions.animation = { enabled: true, duration: 800 };
}
Expand All @@ -95,12 +105,17 @@ const computedOptions = computed(() => {
...baseOptions.tooltip,
trackingLine: {
...baseOptions.tooltip?.trackingLine,
colour: baseOptions.tooltip?.trackingLine?.colour ?? "rgba(255, 255, 255, 0.5)",
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",
backgroundColor:
baseOptions.tooltip?.content?.backgroundColor ??
"rgba(30, 30, 30, 0.95)",
textColour:
baseOptions.tooltip?.content?.textColour ?? "#dfdfd6",
},
};
}
Expand All @@ -118,7 +133,7 @@ const codeString = computed(() => {
colour: line.colour || "Graph.Colours.ELECTRIC_BLUE",
})),
null,
4,
4
)
// Replace colour string values with actual references
.replace(/"Graph\.Colours\.(\w+)"/g, "Graph.Colours.$1");
Expand Down Expand Up @@ -156,14 +171,21 @@ function renderGraph() {
}

// Calculate total data points
const totalDataPoints = props.lines.reduce((sum, line) => sum + line.data.length, 0);
const totalDataPoints = props.lines.reduce(
(sum, line) => sum + line.data.length,
0
);

// Capture render time
const startTime = performance.now();

// Create new graph instance with computed options (includes animation)
// Cast to any since the library merges partial options with defaults
graphInstance.value = new Graph(containerId.value, computedOptions.value, props.lines);
graphInstance.value = new Graph(
containerId.value,
computedOptions.value,
props.lines
);
graphInstance.value.draw();

const endTime = performance.now();
Expand Down Expand Up @@ -211,21 +233,28 @@ watch(
() => {
renderGraph();
},
{ deep: true },
{ deep: true }
);
</script>

<template>
<div class="graph-demo">
<!-- Live Preview -->
<div v-if="isClientReady" class="graph-demo-preview">
<div :id="containerId" class="graph-container" :style="{ height: `${height}px`, width: `${width}px` }">
<div
:id="containerId"
class="graph-container"
:style="{ height: `${height}px`, width: `${width}px` }"
>
<canvas :width="width" :height="height" />
</div>
</div>

<!-- Actions Bar -->
<div v-if="widgets.copy || widgets.codeView || widgets.debugPanel" class="graph-demo-actions">
<div
v-if="widgets.copy || widgets.codeView || widgets.debugPanel"
class="graph-demo-actions"
>
<button v-if="widgets.copy" :class="{ copied }" @click="copyCode">
<svg
v-if="!copied"
Expand All @@ -237,7 +266,9 @@ watch(
stroke-width="2"
>
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
<path
d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
/>
</svg>
<svg
v-else
Expand All @@ -253,14 +284,28 @@ watch(
{{ copied ? "Copied!" : "Copy" }}
</button>
<button v-if="widgets.codeView" @click="toggleCode">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<polyline points="16 18 22 12 16 6" />
<polyline points="8 6 2 12 8 18" />
</svg>
{{ showCode ? "Hide Code" : "View Code" }}
</button>
<button v-if="widgets.debugPanel" @click="toggleDebug">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<circle cx="12" cy="12" r="10" />
<line x1="12" y1="16" x2="12" y2="12" />
<line x1="12" y1="8" x2="12.01" y2="8" />
Expand All @@ -270,31 +315,44 @@ watch(
</div>

<!-- Collapsible Code Block -->
<div class="graph-demo-code" :class="showCode ? 'expanded' : 'collapsed'">
<div
class="graph-demo-code"
:class="showCode ? 'expanded' : 'collapsed'"
>
<div class="code-wrapper" v-html="highlightedCode"></div>
</div>

<!-- Collapsible Debug Panel -->
<div class="graph-demo-debug" :class="showDebug ? 'expanded' : 'collapsed'">
<div
class="graph-demo-debug"
:class="showDebug ? 'expanded' : 'collapsed'"
>
<div class="debug-wrapper">
<div class="debug-grid">
<div class="debug-item">
<span class="debug-label">Render Time</span>
<span class="debug-value">{{ debugMetrics.renderTime }} ms</span>
<span class="debug-value"
>{{ debugMetrics.renderTime }} ms</span
>
</div>
<div class="debug-item">
<span class="debug-label">Canvas Size</span>
<span class="debug-value"
>{{ debugMetrics.canvasWidth }} × {{ debugMetrics.canvasHeight }}</span
>{{ debugMetrics.canvasWidth }} ×
{{ debugMetrics.canvasHeight }}</span
>
</div>
<div class="debug-item">
<span class="debug-label">Data Points</span>
<span class="debug-value">{{ debugMetrics.dataPoints }}</span>
<span class="debug-value">{{
debugMetrics.dataPoints
}}</span>
</div>
<div class="debug-item">
<span class="debug-label">Series Count</span>
<span class="debug-value">{{ debugMetrics.seriesCount }}</span>
<span class="debug-value">{{
debugMetrics.seriesCount
}}</span>
</div>
</div>
</div>
Expand Down
Loading
Loading