Skip to content
Snippets Groups Projects
Commit 9680a693 authored by Benedikt's avatar Benedikt
Browse files

added first version of xml with xlt for rendering but local deplyment CDN deplyment is next step

parent 181e0701
No related branches found
No related tags found
No related merge requests found
data/
src/__tests__/
This diff is collapsed.
{
"name": "dccviewertypescript",
"name": "dccviewer-js",
"version": "0.1.0",
"description": "A JS/HTML application for displaying digital calibration certificates.",
"main": "src/app.js",
"description": "A JS application for displaying digital calibration certificates.",
"main": "dist/dccviewer-js.bundle.js",
"files": [
"dist",
"LICENSE",
"README.md"
],
"exports": {
".": {
"import": "./dist/dccviewer-js.bundle.js",
"require": "./dist/dccviewer-js.bundle.cjs.js"
}
},
"scripts": {
"dev": "vite",
"build": "vite build",
......
......@@ -18,7 +18,9 @@ export function init(xmlStr, options = {}) {
appContainer.innerHTML = '';
// Parse the XML string first
parseString(xmlStr, { explicitArray: false }, (err, result) => {
const cleanXmlStr = xmlStr.trim();
console.log("Clean XML string:", cleanXmlStr);
parseString(cleanXmlStr, { explicitArray: false }, (err, result) => {
if (err) {
console.error('Error parsing XML:', err);
return;
......
......@@ -459,7 +459,13 @@ export function renderSingleMeasurementResult(resultObj, language, tabPanel) {
};
Plotly.newPlot(graphDiv, allTraces, layout).then(() => {
// Force a resize to ensure full width
setTimeout(() => { Plotly.Plots.resize(graphDiv); }, 100);
setTimeout(() => {
if (graphDiv.offsetWidth > 0 && graphDiv.offsetHeight > 0) {
Plotly.Plots.resize(graphDiv);
} else {
console.warn('Plot div is not visible; skipping resize.');
}
}, 100);
const caption = document.createElement('div');
caption.innerHTML = '<b>' + group[0].name + '</b>';
caption.style.textAlign = 'center';
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>DCC Viewer Production Test</title>
<link rel="stylesheet" href="/dist/style.css" />
</head>
<body>
<div id="app"></div>
<script type="module">
import { init } from '/dist/dccviewer-js.es.js';
// Use your production bundle's init() to load XML.
// For testing, load the XML from a local file or hard-code a test string.
fetch('/data/sin_acceleration_example_dcc_WithExampleConformatyStatmentXLT.xml')
.then(response => response.text())
.then(xmlStr => {
init(xmlStr, { containerId: 'app', language: 'en' });
})
.catch(err => console.error('Error loading XML file:', err));
</script>
</body>
</html>
import { defineConfig } from 'vite';
export default defineConfig({
server: {
cors: true
},
resolve: {
alias: {
events: 'events'
......@@ -10,5 +13,16 @@ export default defineConfig({
esbuildOptions: {
define: { global: 'globalThis' }
}
},
build: {
lib: {
entry: 'src/app.js',
name: 'DccViewer',
fileName: (format) => `dccviewer-js.${format}.js`
},
rollupOptions: {
// Optionally mark dependencies as external if you don't want them bundled:
// external: ['xml2js', 'plotly.js-dist', 'jsoneditor', 'dsiunits-js', 'events'],
}
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment