@chapeaux/cpx-operator-graph
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -136,5 +136,5 @@ import cytoscape from "https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.19.1/cytoscape.esm.min.js"; | ||
fetch(val).then((resp) => { | ||
return resp.text(); | ||
return resp.json(); | ||
}).then((data) => { | ||
this.data = data.replaceAll("}\n{", "}|||{").split("|||").map((c) => JSON.parse(c)); | ||
this.data = data['data']; | ||
}); | ||
@@ -141,0 +141,0 @@ } |
{ | ||
"name": "@chapeaux/cpx-operator-graph", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Chapeaux Operator Graph Component", | ||
@@ -32,3 +32,3 @@ "type": "module", | ||
"homepage": "https://github.com/chapeaux/cpx-components/components/cpx-operator-graph", | ||
"gitHead": "53af1643f11de85045f1d22e55b033571be302c5" | ||
"gitHead": "ea9192ca94ec3dbc28de00fb9a1add934ffe585e" | ||
} |
@@ -1,2 +0,1 @@ | ||
import cytoscape from "https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.19.1/cytoscape.esm.min.js"; | ||
import { compareSemVer } from 'https://cdn.skypack.dev/semver-parser'; | ||
@@ -62,2 +61,3 @@ | ||
class OperatorChannel {} | ||
class OperatorGraph {} | ||
@@ -67,3 +67,4 @@ | ||
versions = new Set(); | ||
channels | ||
channels; | ||
index; | ||
getVersions() {} | ||
@@ -89,7 +90,5 @@ getChannels() {} | ||
fetch(val).then((resp) => { | ||
return resp.text() | ||
return resp.json() | ||
}).then((data) => { | ||
this.data = data.replaceAll("}\n{", "}|||{").split("|||").map((c) => | ||
JSON.parse(c) | ||
); | ||
this.data = data['data']; // data.replaceAll("}\n{", "}|||{").split("|||").map((c) => JSON.parse(c) ); | ||
}); | ||
@@ -105,2 +104,28 @@ } | ||
this._data = val; | ||
if (this._data) { | ||
// // | ||
// if (!this.versions.has(csv.version)) { | ||
// let csvVersion = this.versions.get(csv.version); | ||
// if (!csvVersion.has(csv.channelName)) { | ||
// this.versions.set(csv.version) | ||
// } | ||
// this.versions.set(csv.version, csvVersion ); | ||
// } else { | ||
// this.versions.set(csv.version, [csv.channelName]) | ||
// } | ||
// if (this.channels.has(csv.channelName)) { | ||
// let channelInfo = this.channels.get(csv.channelName); | ||
// channelInfo.push(csv); | ||
// this.channels.set(csv.channelName, channelInfo); | ||
// } else { | ||
// this.channels.set(csv.channelName, [csv]); | ||
// } | ||
// this.channels.forEach((versions,channel,d)=> { | ||
// d.set(channel,versions.sort((a, b) => { | ||
// const ord = { desc: 1, asc: -1 }; | ||
// return compareSemVer(b['version'], a['version']) * ord[this.order]; | ||
// })); | ||
// }); | ||
} | ||
this.render(); | ||
@@ -201,30 +226,3 @@ } | ||
*/ | ||
if (this.data && this.filter !== "" && this.query !== "") { | ||
const filteredData = this._data.filter((d) => d[this.filter] === this.query); | ||
filteredData.map(csv=> { | ||
// // | ||
// if (!this.versions.has(csv.version)) { | ||
// let csvVersion = this.versions.get(csv.version); | ||
// if (!csvVersion.has(csv.channelName)) { | ||
// this.versions.set(csv.version) | ||
// } | ||
// this.versions.set(csv.version, csvVersion ); | ||
// } else { | ||
// this.versions.set(csv.version, [csv.channelName]) | ||
// } | ||
if (this.channels.has(csv.channelName)) { | ||
let channelInfo = this.channels.get(csv.channelName); | ||
channelInfo.push(csv); | ||
this.channels.set(csv.channelName, channelInfo); | ||
} else { | ||
this.channels.set(csv.channelName, [csv]); | ||
} | ||
}); | ||
this.channels.forEach((versions,channel,d)=> { | ||
d.set(channel,versions.sort((a, b) => { | ||
const ord = { desc: 1, asc: -1 }; | ||
return compareSemVer(b['version'], a['version']) * ord[this.order]; | ||
})); | ||
}); | ||
} | ||
if (this.channels.size > 0) { | ||
@@ -249,4 +247,3 @@ this.template = this.querySelector("template").cloneNode(true); | ||
graphImg.id = 'graph'; | ||
graphImg.setAttribute('rowspan', [...this.channels.get(this.channel)].length.toString()); | ||
graphImg.innerHTML = '<div id="cy"></div>'; | ||
graphImg.innerHTML = '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="20" cy="50" r="10" stroke="black" fill="transparent" stroke-width="3"></circle></svg>'; | ||
// } | ||
@@ -258,56 +255,2 @@ | ||
this.shadowRoot.appendChild(this.template.content.cloneNode(true)); | ||
// https://js.cytoscape.org/ | ||
this.cy = cytoscape({ | ||
container: this.shadowRoot.querySelector("#cy"), | ||
elements: [...this.channels.get(this.channel)].reduce((a,csv)=>{ | ||
a = a.concat([{ data: { id: csv.csvName }}]); | ||
if (csv.replaces) { | ||
a = a.concat([{ data: { | ||
id: csv.csvName+'replace', | ||
source: csv.replaces, | ||
target: csv.csvName, | ||
controlPointDistances: '0 0' | ||
} | ||
}]); | ||
} | ||
return a; | ||
},[]), | ||
zoomingEnabled: false, | ||
panningEnabled: false, | ||
boxSelectionEnabled: false, | ||
autoungrabify: true, | ||
style: [ // the stylesheet for the graph | ||
{ | ||
selector: "node", | ||
style: { | ||
"width": 25, | ||
"height": 25, | ||
"background-color": "#fff", | ||
"border-width": 3, | ||
"border-color": "#00F", | ||
//"label": "data(id)", | ||
}, | ||
}, | ||
{ | ||
selector: "edge", | ||
style: { | ||
"width": 3, | ||
"line-color": "#00F", | ||
"curve-style": "unbundled-bezier", | ||
'control-point-weights': '0.1 0.2 0.5 0.8 0.9', | ||
'control-point-distances': '30 40 40 40 30' | ||
// 'control-point-distances': 'data(controlPointDistances)' | ||
} | ||
}, | ||
], | ||
layout: { | ||
name: "grid", | ||
columns: 1, | ||
}, | ||
}); | ||
// this.cy.edges().forEach(edge=>setCurve(edge)); | ||
} | ||
@@ -314,0 +257,0 @@ } |
Sorry, the diff of this file is not supported yet
310149
21
2563
4