mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
1 parent
acb95afe1b
commit
23fbd21432
4 files changed
+202
No files matched your search
@@ -110,6 +110,8 @@
|
||||
"byte-data": "^19.0.1",
|
||||
"change-case": "^5.4.4",
|
||||
"chardet": "^2.1.0",
|
||||
"chart.js": "^4.5.1",
|
||||
"chartjs-plugin-zoom": "^2.2.0",
|
||||
"chatgpt-prompt-splitter": "^1.0.5",
|
||||
"chinesegen": "^0.3.3",
|
||||
"cidr-tools": "^11.0.3",
|
||||
|
||||
Generated
+41
@@ -219,6 +219,12 @@ importers:
|
||||
chardet:
|
||||
specifier: ^2.1.0
|
||||
version: 2.1.0
|
||||
chart.js:
|
||||
specifier: ^4.5.1
|
||||
version: 4.5.1
|
||||
chartjs-plugin-zoom:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0(chart.js@4.5.1)
|
||||
chatgpt-prompt-splitter:
|
||||
specifier: ^1.0.5
|
||||
version: 1.0.5
|
||||
@@ -3052,6 +3058,9 @@ packages:
|
||||
resolution: {integrity: sha512-uhImwxvKLSxER8+ikuKpI2mnX7viL+POSnKAgDCFx+sVuRTD9/KkHFH1Gaw7EegVbCtDNKBTnECIK+GWxkpZRA==}
|
||||
engines: {node: '>= 10'}
|
||||
|
||||
'@kurkle/color@0.3.4':
|
||||
resolution: {integrity: sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==}
|
||||
|
||||
'@langfreak/convert-layout@0.11.2':
|
||||
resolution: {integrity: sha512-O0k7+cnb5uMPbaBYJ42aLilOdi/d4c8e2MVxjXb+zTBdbR/3tJpaeXN8xOu3qMNoJKyyT9979EDF6bY/gFKAmw==}
|
||||
|
||||
@@ -4066,6 +4075,9 @@ packages:
|
||||
'@types/geojson@7946.0.16':
|
||||
resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==}
|
||||
|
||||
'@types/hammerjs@2.0.46':
|
||||
resolution: {integrity: sha512-ynRvcq6wvqexJ9brDMS4BnBLzmr0e14d6ZJTEShTBWKymQiHwlAyGu0ZPEFI2Fh1U53F7tN9ufClWM5KvqkKOw==}
|
||||
|
||||
'@types/har-format@1.2.16':
|
||||
resolution: {integrity: sha512-fluxdy7ryD3MV6h8pTfTYpy/xQzCFC7m89nOH9y94cNqJ1mDIDPut7MnRHI3F6qRmh/cT2fUjG1MLdCNb4hE9A==}
|
||||
|
||||
@@ -5329,6 +5341,15 @@ packages:
|
||||
chardet@2.1.0:
|
||||
resolution: {integrity: sha512-bNFETTG/pM5ryzQ9Ad0lJOTa6HWD/YsScAR3EnCPZRPlQh77JocYktSHOUHelyhm8IARL+o4c4F1bP5KVOjiRA==}
|
||||
|
||||
chart.js@4.5.1:
|
||||
resolution: {integrity: sha512-GIjfiT9dbmHRiYi6Nl2yFCq7kkwdkp1W/lp2J99rX0yo9tgJGn3lKQATztIjb5tVtevcBtIdICNWqlq5+E8/Pw==}
|
||||
engines: {pnpm: '>=8'}
|
||||
|
||||
chartjs-plugin-zoom@2.2.0:
|
||||
resolution: {integrity: sha512-in6kcdiTlP6npIVLMd4zXZ08PDUXC52gZ4FAy5oyjk1zX3gKarXMAof7B9eFiisf9WOC3bh2saHg+J5WtLXZeA==}
|
||||
peerDependencies:
|
||||
chart.js: '>=3.2.0'
|
||||
|
||||
chatgpt-prompt-splitter@1.0.5:
|
||||
resolution: {integrity: sha512-8buXXnxZ5Y5BloPTMEhGTVld9vrVB8WVrUFrjgOpIJ4/VsT+rTnLszbaS1L1KAB0SDSCqj8GU472S2gMyhH8EA==}
|
||||
|
||||
@@ -7137,6 +7158,10 @@ packages:
|
||||
hachure-fill@0.5.2:
|
||||
resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==}
|
||||
|
||||
hammerjs@2.0.8:
|
||||
resolution: {integrity: sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
|
||||
has-bigints@1.0.2:
|
||||
resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==}
|
||||
|
||||
@@ -13995,6 +14020,8 @@ snapshots:
|
||||
'@kenjiuno/decompressrtf': 0.1.4
|
||||
iconv-lite: 0.6.3
|
||||
|
||||
'@kurkle/color@0.3.4': {}
|
||||
|
||||
'@langfreak/convert-layout@0.11.2':
|
||||
dependencies:
|
||||
fs-extra: 11.3.2
|
||||
@@ -15033,6 +15060,8 @@ snapshots:
|
||||
|
||||
'@types/geojson@7946.0.16': {}
|
||||
|
||||
'@types/hammerjs@2.0.46': {}
|
||||
|
||||
'@types/har-format@1.2.16': {}
|
||||
|
||||
'@types/hast@3.0.4':
|
||||
@@ -16572,6 +16601,16 @@ snapshots:
|
||||
|
||||
chardet@2.1.0: {}
|
||||
|
||||
chart.js@4.5.1:
|
||||
dependencies:
|
||||
'@kurkle/color': 0.3.4
|
||||
|
||||
chartjs-plugin-zoom@2.2.0(chart.js@4.5.1):
|
||||
dependencies:
|
||||
'@types/hammerjs': 2.0.46
|
||||
chart.js: 4.5.1
|
||||
hammerjs: 2.0.8
|
||||
|
||||
chatgpt-prompt-splitter@1.0.5: {}
|
||||
|
||||
check-error@1.0.3:
|
||||
@@ -18651,6 +18690,8 @@ snapshots:
|
||||
|
||||
hachure-fill@0.5.2: {}
|
||||
|
||||
hammerjs@2.0.8: {}
|
||||
|
||||
has-bigints@1.0.2: {}
|
||||
|
||||
has-flag@3.0.0: {}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MathFunction } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Trigonometric/Equation Curve Visualizer',
|
||||
path: '/trigo-viewer',
|
||||
description: 'Visualize trigonometric or equations depending on x',
|
||||
keywords: ['trigonometry', 'equation', 'curve', 'visualizer'],
|
||||
component: () => import('./trigo-viewer.vue'),
|
||||
icon: MathFunction,
|
||||
createdAt: new Date('2025-12-13'),
|
||||
category: 'Maths',
|
||||
});
|
||||
@@ -0,0 +1,146 @@
|
||||
<script setup lang="ts">
|
||||
import { Chart, registerables } from 'chart.js';
|
||||
import zoomPlugin from 'chartjs-plugin-zoom';
|
||||
import { evaluate } from 'mathjs';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
Chart.register(...registerables, zoomPlugin);
|
||||
|
||||
const canvasRef = ref<HTMLCanvasElement | null>(null);
|
||||
const chartInstance = shallowRef<Chart<'line', number[], number> | null>(null);
|
||||
|
||||
// Equation input
|
||||
const equation = ref('sin(x)');
|
||||
const xmin = useQueryParamOrStorage({ name: 'xmin', storageName: 'trigo-vw:xmin', defaultValue: -180 });
|
||||
const xmax = useQueryParamOrStorage({ name: 'xmax', storageName: 'trigo-vw:xmax', defaultValue: 180 });
|
||||
|
||||
// Generate data points
|
||||
function generateData(expr: string) {
|
||||
const xValues: number[] = [];
|
||||
const yValues: number[] = [];
|
||||
|
||||
for (let i = xmin.value; i <= xmax.value; i += 1) {
|
||||
const x = (i * Math.PI) / 180;
|
||||
xValues.push(i);
|
||||
try {
|
||||
const y = evaluate(expr, { x });
|
||||
if (typeof y === 'number' && Math.abs(y) < 1e4) {
|
||||
yValues.push(y);
|
||||
}
|
||||
else {
|
||||
yValues.push(Number.NaN);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
yValues.push(Number.NaN);
|
||||
}
|
||||
}
|
||||
|
||||
return { xValues, yValues };
|
||||
}
|
||||
|
||||
// Initialize chart
|
||||
function initChart() {
|
||||
if (!canvasRef.value) {
|
||||
return;
|
||||
}
|
||||
const { xValues, yValues } = generateData(equation.value);
|
||||
|
||||
if (chartInstance.value) {
|
||||
const chart = chartInstance.value;
|
||||
chart.data.labels = xValues;
|
||||
chart.data.datasets[0].data = yValues;
|
||||
chart.update();
|
||||
}
|
||||
else {
|
||||
chartInstance.value = new Chart(canvasRef.value, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: xValues,
|
||||
datasets: [
|
||||
{
|
||||
label: equation.value,
|
||||
data: yValues,
|
||||
borderColor: '#42b983',
|
||||
borderWidth: 2,
|
||||
pointRadius: 0,
|
||||
fill: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
x: {
|
||||
title: { display: true, text: 'Degrees (°)' },
|
||||
},
|
||||
y: {
|
||||
title: { display: true, text: 'Value' },
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
zoom: {
|
||||
zoom: {
|
||||
wheel: { enabled: true },
|
||||
pinch: { enabled: true },
|
||||
mode: 'xy',
|
||||
},
|
||||
pan: {
|
||||
enabled: true,
|
||||
mode: 'xy',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Watchers
|
||||
watch([equation, xmin, xmax], () => {
|
||||
initChart();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
initChart();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="equation"
|
||||
placeholder="Enter equation in terms of x (e.g. sin(x) + cos(2*x))"
|
||||
label="Equation in term of x:"
|
||||
label-position="left"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-form-item label="Domain:" label-placement="left">
|
||||
<NInputNumber
|
||||
v-model:value="xmin"
|
||||
:min="-720"
|
||||
:max="720"
|
||||
:step="10"
|
||||
mr-1
|
||||
/>
|
||||
<NInputNumber
|
||||
v-model:value="xmax"
|
||||
:min="-720"
|
||||
:max="720"
|
||||
:step="10"
|
||||
mr-1
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-card style="position: relative; height: 50vh;" mb-1>
|
||||
<canvas ref="canvasRef" style="width: 100%; height: 100%" />
|
||||
</n-card>
|
||||
<n-space justify="center">
|
||||
<n-button @click="chartInstance?.resetZoom()">
|
||||
Reset Zoom
|
||||
</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user