mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-02-04 15:38:55 +08:00
Compare commits
9 Commits
0a2af0bba3
...
5492609c3a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5492609c3a | ||
|
|
8bfd0f5944 | ||
|
|
a8006bcf52 | ||
|
|
1463f93bb0 | ||
|
|
5108495430 | ||
|
|
d28968e539 | ||
|
|
68221cba6d | ||
|
|
65c1c18fcb | ||
|
|
d7db6a0f5d |
@@ -9,7 +9,7 @@ of SQLite databases, CSV, JSON or NDJSON files.
|
|||||||
|
|
||||||
With sqliteviz you can:
|
With sqliteviz you can:
|
||||||
|
|
||||||
- run SQL queries against a SQLite database and create [Plotly][11] charts and pivot tables based on the result sets
|
- run SQL queries against a SQLite database and create [Plotly][11] charts, graphs and pivot tables based on the result sets
|
||||||
- import a CSV/JSON/NDJSON file into a SQLite database and visualize imported data
|
- import a CSV/JSON/NDJSON file into a SQLite database and visualize imported data
|
||||||
- export result set to CSV file
|
- export result set to CSV file
|
||||||
- manage inquiries and run them against different databases
|
- manage inquiries and run them against different databases
|
||||||
@@ -33,7 +33,9 @@ It's a kind of middleground between [Plotly Falcon][1] and [Redash][2].
|
|||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
It is built on top of [react-chart-editor][3], [PivotTable.js][12], [sql.js][4] and [Vue-Codemirror][8] in [Vue.js][5]. CSV parsing is performed with [Papa Parse][9].
|
It is built on top of [react-chart-editor][3], [PivotTable.js][12], [sql.js][4]
|
||||||
|
and [Vue-Codemirror][8] in [Vue.js][5]. CSV parsing is performed with [Papa Parse][9].
|
||||||
|
Graphs are visualized with [Sigma.js][13] and [Graphology][14].
|
||||||
|
|
||||||
[1]: https://github.com/plotly/falcon
|
[1]: https://github.com/plotly/falcon
|
||||||
[2]: https://github.com/getredash/redash
|
[2]: https://github.com/getredash/redash
|
||||||
@@ -47,3 +49,5 @@ It is built on top of [react-chart-editor][3], [PivotTable.js][12], [sql.js][4]
|
|||||||
[10]: https://github.com/lana-k/sqliteviz/wiki/Predefined-queries
|
[10]: https://github.com/lana-k/sqliteviz/wiki/Predefined-queries
|
||||||
[11]: https://github.com/plotly/plotly.js
|
[11]: https://github.com/plotly/plotly.js
|
||||||
[12]: https://github.com/nicolaskruchten/pivottable
|
[12]: https://github.com/nicolaskruchten/pivottable
|
||||||
|
[13]: https://www.sigmajs.org/
|
||||||
|
[14]: https://graphology.github.io/
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Scaling ratio">
|
<Field label="Scaling ratio" fieldContainerClassName="test_fa2_scaling">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.scalingRatio"
|
:value="modelValue.scalingRatio"
|
||||||
@update="update('scalingRatio', $event)"
|
@update="update('scalingRatio', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Prevent overlapping">
|
<Field
|
||||||
|
label="Prevent overlapping"
|
||||||
|
fieldContainerClassName="test_fa2_adjustSizes"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="booleanOptions"
|
:options="booleanOptions"
|
||||||
:activeOption="modelValue.adjustSizes"
|
:activeOption="modelValue.adjustSizes"
|
||||||
@@ -14,7 +17,10 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Barnes-Hut optimize">
|
<Field
|
||||||
|
label="Barnes-Hut optimize"
|
||||||
|
fieldContainerClassName="test_fa2_barnes_hut"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="booleanOptions"
|
:options="booleanOptions"
|
||||||
:activeOption="modelValue.barnesHutOptimize"
|
:activeOption="modelValue.barnesHutOptimize"
|
||||||
@@ -22,14 +28,21 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field v-show="modelValue.barnesHutOptimize" label="Barnes-Hut Theta">
|
<Field
|
||||||
|
v-show="modelValue.barnesHutOptimize"
|
||||||
|
label="Barnes-Hut Theta"
|
||||||
|
fieldContainerClassName="test_fa2_barnes_theta"
|
||||||
|
>
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.barnesHutTheta"
|
:value="modelValue.barnesHutTheta"
|
||||||
@update="update('barnesHutTheta', $event)"
|
@update="update('barnesHutTheta', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Strong gravity mode">
|
<Field
|
||||||
|
label="Strong gravity mode"
|
||||||
|
fieldContainerClassName="test_fa2_strong_gravity"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="booleanOptions"
|
:options="booleanOptions"
|
||||||
:activeOption="modelValue.strongGravityMode"
|
:activeOption="modelValue.strongGravityMode"
|
||||||
@@ -37,7 +50,10 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Noack's LinLog model">
|
<Field
|
||||||
|
label="Noack's LinLog model"
|
||||||
|
fieldContainerClassName="test_fa2_lin_log"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="booleanOptions"
|
:options="booleanOptions"
|
||||||
:activeOption="modelValue.linLogMode"
|
:activeOption="modelValue.linLogMode"
|
||||||
@@ -45,7 +61,10 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Out bound attraction distribution">
|
<Field
|
||||||
|
label="Outbound attraction distribution"
|
||||||
|
fieldContainerClassName="test_fa2_outbound_attraction"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="booleanOptions"
|
:options="booleanOptions"
|
||||||
:activeOption="modelValue.outboundAttractionDistribution"
|
:activeOption="modelValue.outboundAttractionDistribution"
|
||||||
@@ -53,7 +72,7 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Slow down">
|
<Field label="Slow down" fieldContainerClassName="test_fa2_slow_down">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.slowDown"
|
:value="modelValue.slowDown"
|
||||||
:min="0"
|
:min="0"
|
||||||
@@ -65,10 +84,15 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keyOptions"
|
:options="keyOptions"
|
||||||
:value="modelValue.weightSource"
|
:value="modelValue.weightSource"
|
||||||
|
className="test_fa2_weight_source"
|
||||||
@change="update('weightSource', $event)"
|
@change="update('weightSource', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<Field v-show="modelValue.weightSource" label="Edge weight influence">
|
<Field
|
||||||
|
v-show="modelValue.weightSource"
|
||||||
|
label="Edge weight influence"
|
||||||
|
fieldContainerClassName="test_fa2_weight_influence"
|
||||||
|
>
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.edgeWeightInfluence"
|
:value="modelValue.edgeWeightInfluence"
|
||||||
@update="update('edgeWeightInfluence', $event)"
|
@update="update('edgeWeightInfluence', $event)"
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Color">
|
<Field label="Color" fieldContainerClassName="test_edge_color">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="edgeColorTypeOptions"
|
:options="edgeColorTypeOptions"
|
||||||
:activeOption="modelValue.type"
|
:activeOption="modelValue.type"
|
||||||
@option-change="updateColorType"
|
@option-change="updateColorType"
|
||||||
/>
|
/>
|
||||||
<Field v-if="modelValue.type === 'constant'">
|
<Field
|
||||||
|
v-if="modelValue.type === 'constant'"
|
||||||
|
fieldContainerClassName="test_edge_color_value"
|
||||||
|
>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
:selectedColor="modelValue.value"
|
:selectedColor="modelValue.value"
|
||||||
@color-change="updateSettings('value', $event)"
|
@color-change="updateSettings('value', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<Field>
|
<Field fieldContainerClassName="test_edge_color_value">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
v-if="modelValue.type === 'variable'"
|
v-if="modelValue.type === 'variable'"
|
||||||
:options="keyOptions"
|
:options="keyOptions"
|
||||||
@@ -21,7 +24,7 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field>
|
<Field fieldContainerClassName="test_edge_color_mapping_mode">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="colorSourceUsageOptions"
|
:options="colorSourceUsageOptions"
|
||||||
:activeOption="modelValue.sourceUsage"
|
:activeOption="modelValue.sourceUsage"
|
||||||
@@ -42,6 +45,7 @@
|
|||||||
<Field
|
<Field
|
||||||
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
||||||
label="Color as"
|
label="Color as"
|
||||||
|
fieldContainerClassName="test_edge_color_as"
|
||||||
>
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="сolorAsOptions"
|
:options="сolorAsOptions"
|
||||||
@@ -53,6 +57,7 @@
|
|||||||
<Field
|
<Field
|
||||||
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
||||||
label="Colorscale direction"
|
label="Colorscale direction"
|
||||||
|
fieldContainerClassName="test_edge_color_colorscale_direction"
|
||||||
>
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="сolorscaleDirections"
|
:options="сolorscaleDirections"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Size">
|
<Field label="Size" fieldContainerClassName="test_edge_size">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="edgeSizeTypeOptions"
|
:options="edgeSizeTypeOptions"
|
||||||
:activeOption="modelValue.type"
|
:activeOption="modelValue.type"
|
||||||
@option-change="updateSizeType"
|
@option-change="updateSizeType"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Field>
|
<Field fieldContainerClassName="test_edge_size_value">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
v-if="modelValue.type === 'constant'"
|
v-if="modelValue.type === 'constant'"
|
||||||
:value="modelValue.value"
|
:value="modelValue.value"
|
||||||
@@ -23,14 +23,14 @@
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<template v-if="modelValue.type !== 'constant'">
|
<template v-if="modelValue.type !== 'constant'">
|
||||||
<Field label="Size scale">
|
<Field label="Size scale" fieldContainerClassName="test_edge_size_scale">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.scale"
|
:value="modelValue.scale"
|
||||||
@update="updateSettings('scale', $event)"
|
@update="updateSettings('scale', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Minimum size">
|
<Field label="Minimum size" fieldContainerClassName="test_edge_size_min">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.min"
|
:value="modelValue.min"
|
||||||
@update="updateSettings('min', $event)"
|
@update="updateSettings('min', $event)"
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Initial iterations">
|
<Field
|
||||||
|
label="Initial iterations"
|
||||||
|
fieldContainerClassName="test_fa2_iteration_amount"
|
||||||
|
>
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.initialIterationsAmount"
|
:value="modelValue.initialIterationsAmount"
|
||||||
:min="1"
|
:min="1"
|
||||||
@@ -7,7 +10,7 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Gravity">
|
<Field label="Gravity" fieldContainerClassName="test_fa2_gravity">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.gravity"
|
:value="modelValue.gravity"
|
||||||
@update="update('gravity', $event)"
|
@update="update('gravity', $event)"
|
||||||
|
|||||||
@@ -11,10 +11,11 @@
|
|||||||
documentation</a
|
documentation</a
|
||||||
>.
|
>.
|
||||||
</Field>
|
</Field>
|
||||||
<Field label="Object type">
|
<Field label="Object type" ref="objectTypeField">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.structure.objectType"
|
:value="settings.structure.objectType"
|
||||||
|
className="test_object_type_select"
|
||||||
@change="updateStructure('objectType', $event)"
|
@change="updateStructure('objectType', $event)"
|
||||||
/>
|
/>
|
||||||
<Field>
|
<Field>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.structure.nodeId"
|
:value="settings.structure.nodeId"
|
||||||
|
className="test_node_id_select"
|
||||||
@change="updateStructure('nodeId', $event)"
|
@change="updateStructure('nodeId', $event)"
|
||||||
/>
|
/>
|
||||||
<Field> A field keeping unique node identifier. </Field>
|
<Field> A field keeping unique node identifier. </Field>
|
||||||
@@ -36,6 +38,7 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.structure.edgeSource"
|
:value="settings.structure.edgeSource"
|
||||||
|
className="test_edge_source_select"
|
||||||
@change="updateStructure('edgeSource', $event)"
|
@change="updateStructure('edgeSource', $event)"
|
||||||
/>
|
/>
|
||||||
<Field>
|
<Field>
|
||||||
@@ -47,6 +50,7 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.structure.edgeTarget"
|
:value="settings.structure.edgeTarget"
|
||||||
|
className="test_edge_target_select"
|
||||||
@change="updateStructure('edgeTarget', $event)"
|
@change="updateStructure('edgeTarget', $event)"
|
||||||
/>
|
/>
|
||||||
<Field>
|
<Field>
|
||||||
@@ -71,6 +75,7 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.style.nodes.label.source"
|
:value="settings.style.nodes.label.source"
|
||||||
|
className="test_label_select"
|
||||||
@change="updateNodes('label.source', $event)"
|
@change="updateNodes('label.source', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
@@ -97,7 +102,10 @@
|
|||||||
|
|
||||||
<Panel group="Style" name="Edges">
|
<Panel group="Style" name="Edges">
|
||||||
<Fold name="Edges">
|
<Fold name="Edges">
|
||||||
<Field label="Direction">
|
<Field
|
||||||
|
label="Direction"
|
||||||
|
fieldContainerClassName="test_edge_direction"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="visibilityOptions"
|
:options="visibilityOptions"
|
||||||
:activeOption="settings.style.edges.showDirection"
|
:activeOption="settings.style.edges.showDirection"
|
||||||
@@ -109,6 +117,7 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="keysOptions"
|
:options="keysOptions"
|
||||||
:value="settings.style.edges.label.source"
|
:value="settings.style.edges.label.source"
|
||||||
|
className="test_edge_label_select"
|
||||||
@change="updateEdges('label.source', $event)"
|
@change="updateEdges('label.source', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
@@ -139,6 +148,8 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
:options="layoutOptions"
|
:options="layoutOptions"
|
||||||
:value="settings.layout.type"
|
:value="settings.layout.type"
|
||||||
|
:clearable="false"
|
||||||
|
className="test_layout_algorithm_select"
|
||||||
@change="updateLayout($event)"
|
@change="updateLayout($event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
@@ -159,10 +170,18 @@
|
|||||||
/>
|
/>
|
||||||
</Fold>
|
</Fold>
|
||||||
<div class="force-atlas-buttons">
|
<div class="force-atlas-buttons">
|
||||||
<Button variant="secondary" @click="resetFA2LayoutSettings">
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
@click="resetFA2LayoutSettings"
|
||||||
|
class="test_fa2_reset"
|
||||||
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" @click="toggleFA2Layout">
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
@click="toggleFA2Layout"
|
||||||
|
class="test_fa2_toggle"
|
||||||
|
>
|
||||||
<template #node:icon>
|
<template #node:icon>
|
||||||
<div
|
<div
|
||||||
:style="{
|
:style="{
|
||||||
@@ -183,6 +202,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
ref="graph"
|
ref="graph"
|
||||||
|
class="test_graph_output"
|
||||||
:style="{
|
:style="{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -208,7 +228,7 @@ import ForceAtlasLayoutSettings from '@/components/Graph/ForceAtlasLayoutSetting
|
|||||||
import AdvancedForceAtlasLayoutSettings from '@/components/Graph/AdvancedForceAtlasLayoutSettings.vue'
|
import AdvancedForceAtlasLayoutSettings from '@/components/Graph/AdvancedForceAtlasLayoutSettings.vue'
|
||||||
import CirclePackLayoutSettings from '@/components/Graph/CirclePackLayoutSettings.vue'
|
import CirclePackLayoutSettings from '@/components/Graph/CirclePackLayoutSettings.vue'
|
||||||
import FA2Layout from 'graphology-layout-forceatlas2/worker'
|
import FA2Layout from 'graphology-layout-forceatlas2/worker'
|
||||||
import forceAtlas2 from 'graphology-layout-forceatlas2'
|
import * as forceAtlas2 from 'graphology-layout-forceatlas2'
|
||||||
import RunIcon from '@/components/svg/run.vue'
|
import RunIcon from '@/components/svg/run.vue'
|
||||||
import StopIcon from '@/components/svg/stop.vue'
|
import StopIcon from '@/components/svg/stop.vue'
|
||||||
import { downloadAsPNG, drawOnCanvas } from '@sigma/export-image'
|
import { downloadAsPNG, drawOnCanvas } from '@sigma/export-image'
|
||||||
@@ -338,11 +358,10 @@ export default {
|
|||||||
if (!this.dataSources) {
|
if (!this.dataSources) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
const firstColumnName = Object.keys(this.dataSources)[0]
|
||||||
try {
|
try {
|
||||||
return (
|
return (
|
||||||
this.dataSources[Object.keys(this.dataSources)[0] || 'doc'].map(
|
this.dataSources[firstColumnName].map(json => JSON.parse(json)) || []
|
||||||
json => JSON.parse(json)
|
|
||||||
) || []
|
|
||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
return []
|
return []
|
||||||
@@ -417,9 +436,7 @@ export default {
|
|||||||
this.updateLayout(this.settings.layout.type)
|
this.updateLayout(this.settings.layout.type)
|
||||||
this.renderer = new Sigma(this.graph, this.$refs.graph, {
|
this.renderer = new Sigma(this.graph, this.$refs.graph, {
|
||||||
renderEdgeLabels: true,
|
renderEdgeLabels: true,
|
||||||
allowInvalidContainer: true,
|
allowInvalidContainer: true
|
||||||
labelColor: { attribute: 'labelColor', color: '#444444' },
|
|
||||||
edgeLabelColor: { attribute: 'labelColor', color: '#a2b1c6' }
|
|
||||||
})
|
})
|
||||||
if (this.settings.layout.type === 'forceAtlas2') {
|
if (this.settings.layout.type === 'forceAtlas2') {
|
||||||
this.autoRunFA2Layout()
|
this.autoRunFA2Layout()
|
||||||
@@ -491,7 +508,7 @@ export default {
|
|||||||
|
|
||||||
if (layoutType === 'random') {
|
if (layoutType === 'random') {
|
||||||
random.assign(this.graph, {
|
random.assign(this.graph, {
|
||||||
rng: seedrandom(this.settings.layout.options.seedValue || 1)
|
rng: seedrandom(this.settings.layout.options.seedValue)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -524,7 +541,7 @@ export default {
|
|||||||
this.settings.layout.options.hierarchyAttributes?.map(
|
this.settings.layout.options.hierarchyAttributes?.map(
|
||||||
(_, index) => 'hierarchyAttribute' + index
|
(_, index) => 'hierarchyAttribute' + index
|
||||||
) || [],
|
) || [],
|
||||||
rng: seedrandom(this.settings.layout.options.seedValue || 1)
|
rng: seedrandom(this.settings.layout.options.seedValue)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -574,10 +591,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
autoRunFA2Layout() {
|
autoRunFA2Layout() {
|
||||||
if (this.fa2Layout.isRunning()) {
|
|
||||||
this.stopFA2Layout()
|
|
||||||
}
|
|
||||||
|
|
||||||
let iteration = 1
|
let iteration = 1
|
||||||
this.checkIteration = () => {
|
this.checkIteration = () => {
|
||||||
if (
|
if (
|
||||||
@@ -592,7 +605,7 @@ export default {
|
|||||||
this.fa2Layout.start()
|
this.fa2Layout.start()
|
||||||
},
|
},
|
||||||
setRecommendedFA2Settings() {
|
setRecommendedFA2Settings() {
|
||||||
const sensibleSettings = forceAtlas2.inferSettings(this.graph)
|
const sensibleSettings = forceAtlas2.default.inferSettings(this.graph)
|
||||||
this.settings.layout.options = {
|
this.settings.layout.options = {
|
||||||
initialIterationsAmount: 50,
|
initialIterationsAmount: 50,
|
||||||
adjustSizes: false,
|
adjustSizes: false,
|
||||||
@@ -1,18 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Color">
|
<Field label="Color" fieldContainerClassName="test_node_color">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="nodeColorTypeOptions"
|
:options="nodeColorTypeOptions"
|
||||||
:activeOption="modelValue.type"
|
:activeOption="modelValue.type"
|
||||||
@option-change="updateColorType"
|
@option-change="updateColorType"
|
||||||
/>
|
/>
|
||||||
<Field v-if="modelValue.type === 'constant'">
|
<Field
|
||||||
|
v-if="modelValue.type === 'constant'"
|
||||||
|
fieldContainerClassName="test_node_color_value"
|
||||||
|
>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
:selectedColor="modelValue.value"
|
:selectedColor="modelValue.value"
|
||||||
@color-change="updateSettings('value', $event)"
|
@color-change="updateSettings('value', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<Field>
|
<Field fieldContainerClassName="test_node_color_value">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
v-if="modelValue.type === 'variable'"
|
v-if="modelValue.type === 'variable'"
|
||||||
:options="keyOptions"
|
:options="keyOptions"
|
||||||
@@ -23,11 +26,15 @@
|
|||||||
v-if="modelValue.type === 'calculated'"
|
v-if="modelValue.type === 'calculated'"
|
||||||
:options="nodeCalculatedColorMethodOptions"
|
:options="nodeCalculatedColorMethodOptions"
|
||||||
:value="modelValue.method"
|
:value="modelValue.method"
|
||||||
|
:clearable="false"
|
||||||
@change="updateSettings('method', $event)"
|
@change="updateSettings('method', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field v-if="modelValue.type === 'variable'">
|
<Field
|
||||||
|
v-if="modelValue.type === 'variable'"
|
||||||
|
fieldContainerClassName="test_node_color_mapping_mode"
|
||||||
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="colorSourceUsageOptions"
|
:options="colorSourceUsageOptions"
|
||||||
:activeOption="modelValue.sourceUsage"
|
:activeOption="modelValue.sourceUsage"
|
||||||
@@ -35,7 +42,12 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field v-if="modelValue.sourceUsage === 'map_to'">
|
<Field
|
||||||
|
v-if="
|
||||||
|
modelValue.sourceUsage === 'map_to' ||
|
||||||
|
modelValue.type === 'calculated'
|
||||||
|
"
|
||||||
|
>
|
||||||
<ColorscalePicker
|
<ColorscalePicker
|
||||||
:selected="modelValue.colorscale"
|
:selected="modelValue.colorscale"
|
||||||
className="colorscale-picker"
|
className="colorscale-picker"
|
||||||
@@ -46,8 +58,11 @@
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
v-if="
|
||||||
|
modelValue.sourceUsage === 'map_to' || modelValue.type === 'calculated'
|
||||||
|
"
|
||||||
label="Color as"
|
label="Color as"
|
||||||
|
fieldContainerClassName="test_node_color_as"
|
||||||
>
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="сolorAsOptions"
|
:options="сolorAsOptions"
|
||||||
@@ -57,8 +72,11 @@
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
v-if="modelValue.type !== 'constant' && modelValue.sourceUsage === 'map_to'"
|
v-if="
|
||||||
|
modelValue.sourceUsage === 'map_to' || modelValue.type === 'calculated'
|
||||||
|
"
|
||||||
label="Colorscale direction"
|
label="Colorscale direction"
|
||||||
|
fieldContainerClassName="test_node_color_colorscale_direction"
|
||||||
>
|
>
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="сolorscaleDirections"
|
:options="сolorscaleDirections"
|
||||||
@@ -126,7 +144,6 @@ export default {
|
|||||||
},
|
},
|
||||||
calculated: {
|
calculated: {
|
||||||
method: 'degree',
|
method: 'degree',
|
||||||
sourceUsage: 'map_to',
|
|
||||||
colorscale: null,
|
colorscale: null,
|
||||||
mode: 'continious',
|
mode: 'continious',
|
||||||
colorscaleDirection: 'normal'
|
colorscaleDirection: 'normal'
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<Field label="Size">
|
<Field label="Size" fieldContainerClassName="test_node_size">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="nodeSizeTypeOptions"
|
:options="nodeSizeTypeOptions"
|
||||||
:activeOption="modelValue.type"
|
:activeOption="modelValue.type"
|
||||||
@option-change="updateSizeType"
|
@option-change="updateSizeType"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Field>
|
<Field fieldContainerClassName="test_node_size_value">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
v-if="modelValue.type === 'constant'"
|
v-if="modelValue.type === 'constant'"
|
||||||
:value="modelValue.value"
|
:value="modelValue.value"
|
||||||
:min="1"
|
:min="1"
|
||||||
|
class="test_node_size_value"
|
||||||
@update="updateSettings('value', $event)"
|
@update="updateSettings('value', $event)"
|
||||||
/>
|
/>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@@ -23,20 +24,21 @@
|
|||||||
v-if="modelValue.type === 'calculated'"
|
v-if="modelValue.type === 'calculated'"
|
||||||
:options="nodeCalculatedSizeMethodOptions"
|
:options="nodeCalculatedSizeMethodOptions"
|
||||||
:value="modelValue.method"
|
:value="modelValue.method"
|
||||||
|
:clearable="false"
|
||||||
@change="updateSettings('method', $event)"
|
@change="updateSettings('method', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<template v-if="modelValue.type !== 'constant'">
|
<template v-if="modelValue.type !== 'constant'">
|
||||||
<Field label="Size scale">
|
<Field label="Size scale" fieldContainerClassName="test_node_size_scale">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.scale"
|
:value="modelValue.scale"
|
||||||
@update="updateSettings('scale', $event)"
|
@update="updateSettings('scale', $event)"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Size mode">
|
<Field label="Size mode" fieldContainerClassName="test_node_size_mode">
|
||||||
<RadioBlocks
|
<RadioBlocks
|
||||||
:options="nodeSizeModeOptions"
|
:options="nodeSizeModeOptions"
|
||||||
:activeOption="modelValue.mode"
|
:activeOption="modelValue.mode"
|
||||||
@@ -44,7 +46,7 @@
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Minimum size">
|
<Field label="Minimum size" fieldContainerClassName="test_node_size_min">
|
||||||
<NumericInput
|
<NumericInput
|
||||||
:value="modelValue.min"
|
:value="modelValue.min"
|
||||||
@update="updateSettings('min', $event)"
|
@update="updateSettings('min', $event)"
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ export function buildNodes(graph, dataSources, options) {
|
|||||||
nodes.forEach(node => {
|
nodes.forEach(node => {
|
||||||
if (node[nodeId]) {
|
if (node[nodeId]) {
|
||||||
graph.addNode(node[nodeId], {
|
graph.addNode(node[nodeId], {
|
||||||
data: node,
|
data: node
|
||||||
labelColor: options.style.nodes.label.color
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -56,7 +55,7 @@ export function buildNodes(graph, dataSources, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function buildEdges(graph, dataSources, options) {
|
export function buildEdges(graph, dataSources, options) {
|
||||||
const docColumn = Object.keys(dataSources)[0] || 'doc'
|
const docColumn = Object.keys(dataSources)[0]
|
||||||
const { objectType, edgeSource, edgeTarget } = options.structure
|
const { objectType, edgeSource, edgeTarget } = options.structure
|
||||||
|
|
||||||
if (objectType && edgeSource && edgeTarget) {
|
if (objectType && edgeSource && edgeTarget) {
|
||||||
@@ -69,8 +68,7 @@ export function buildEdges(graph, dataSources, options) {
|
|||||||
const target = edge[edgeTarget]
|
const target = edge[edgeTarget]
|
||||||
if (graph.hasNode(source) && graph.hasNode(target)) {
|
if (graph.hasNode(source) && graph.hasNode(target)) {
|
||||||
graph.addEdge(source, target, {
|
graph.addEdge(source, target, {
|
||||||
data: edge,
|
data: edge
|
||||||
labelColor: options.style.edges.label.color
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -261,7 +259,6 @@ function getColorMethod(
|
|||||||
colorscale[index % colorscale.length]
|
colorscale[index % colorscale.length]
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
return (attributes, nodeId) => {
|
return (attributes, nodeId) => {
|
||||||
const category = sourceGetter(nodeId, attributes)
|
const category = sourceGetter(nodeId, attributes)
|
||||||
attributes.color = colorMap[category]
|
attributes.color = colorMap[category]
|
||||||
@@ -277,6 +274,7 @@ function getColorMethod(
|
|||||||
const value = sourceGetter(nodeId, attributes)
|
const value = sourceGetter(nodeId, attributes)
|
||||||
const normalizedValue = (value - min) / (max - min)
|
const normalizedValue = (value - min) / (max - min)
|
||||||
if (isNaN(normalizedValue)) {
|
if (isNaN(normalizedValue)) {
|
||||||
|
attributes.color = '#000000'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const exactMatch = normalizedColorscale.find(
|
const exactMatch = normalizedColorscale.find(
|
||||||
@@ -288,9 +286,9 @@ function getColorMethod(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rightColorIndex = normalizedColorscale.findIndex(
|
const rightColorIndex = normalizedColorscale.findIndex(
|
||||||
([value]) => value >= normalizedValue
|
([value]) => value > normalizedValue
|
||||||
)
|
)
|
||||||
const leftColorIndex = (rightColorIndex || 1) - 1
|
const leftColorIndex = rightColorIndex - 1
|
||||||
const right = normalizedColorscale[rightColorIndex]
|
const right = normalizedColorscale[rightColorIndex]
|
||||||
const left = normalizedColorscale[leftColorIndex]
|
const left = normalizedColorscale[leftColorIndex]
|
||||||
const interpolationFactor =
|
const interpolationFactor =
|
||||||
@@ -327,18 +325,3 @@ function getEdgeValueScale(graph, sourceGetter) {
|
|||||||
}, new Set())
|
}, new Set())
|
||||||
return Array.from(scaleSet).sort((a, b) => a - b)
|
return Array.from(scaleSet).sort((a, b) => a - b)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOptionsFromDataSources(dataSources) {
|
|
||||||
if (!dataSources) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.keys(dataSources).map(name => ({
|
|
||||||
value: name,
|
|
||||||
label: name
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
getOptionsFromDataSources
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ export default {
|
|||||||
this.resizeObserver.observe(this.$refs.chartContainer)
|
this.resizeObserver.observe(this.$refs.chartContainer)
|
||||||
if (this.dataSources) {
|
if (this.dataSources) {
|
||||||
dereference.default(this.state.data, this.dataSources)
|
dereference.default(this.state.data, this.dataSources)
|
||||||
this.updatePlotly()
|
|
||||||
}
|
}
|
||||||
|
this.handleResize()
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.useResizeHandler = true
|
this.useResizeHandler = true
|
||||||
@@ -134,6 +134,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async handleResize() {
|
async handleResize() {
|
||||||
|
// Call updatePlotly twice because there is a small gap (for scrolling?)
|
||||||
|
// on right and bottom of the plot.
|
||||||
|
// After the second call it's good.
|
||||||
|
this.updatePlotly()
|
||||||
this.updatePlotly()
|
this.updatePlotly()
|
||||||
},
|
},
|
||||||
onRender() {
|
onRender() {
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="graphContainer" class="graph-container">
|
<div ref="graphContainer" class="graph-container">
|
||||||
<div v-show="!dataSources" class="warning data-view-warning">
|
<div v-show="!dataSources" class="warning data-view-warning no-data">
|
||||||
There is no data to build a graph. Run your SQL query and make sure the
|
There is no data to build a graph. Run your SQL query and make sure the
|
||||||
result is not empty.
|
result is not empty.
|
||||||
</div>
|
</div>
|
||||||
<div v-show="!dataSourceIsValid" class="warning data-view-warning">
|
<div
|
||||||
|
v-show="!dataSourceIsValid"
|
||||||
|
class="warning data-view-warning invalid-data"
|
||||||
|
>
|
||||||
Result set is invalid for graph visualisation. Learn more in
|
Result set is invalid for graph visualisation. Learn more in
|
||||||
<a href="https://sqliteviz.com/docs/graph/" target="_blank">
|
<a href="https://sqliteviz.com/docs/graph/" target="_blank">
|
||||||
documentation</a
|
documentation</a
|
||||||
@@ -30,7 +33,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import 'react-chart-editor/lib/react-chart-editor.css'
|
import 'react-chart-editor/lib/react-chart-editor.css'
|
||||||
import GraphEditor from './GraphEditor.vue'
|
import GraphEditor from '@/components/Graph/GraphEditor.vue'
|
||||||
import { dataSourceIsValid } from '@/lib/graphHelper'
|
import { dataSourceIsValid } from '@/lib/graphHelper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -47,6 +50,8 @@ export default {
|
|||||||
emits: [
|
emits: [
|
||||||
'update:exportToSvgEnabled',
|
'update:exportToSvgEnabled',
|
||||||
'update:exportToHtmlEnabled',
|
'update:exportToHtmlEnabled',
|
||||||
|
'update:exportToPngEnabled',
|
||||||
|
'update:exportToClipboardEnabled',
|
||||||
'update',
|
'update',
|
||||||
'loadingImageCompleted'
|
'loadingImageCompleted'
|
||||||
],
|
],
|
||||||
@@ -58,6 +63,8 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.$emit('update:exportToSvgEnabled', false)
|
this.$emit('update:exportToSvgEnabled', false)
|
||||||
this.$emit('update:exportToHtmlEnabled', false)
|
this.$emit('update:exportToHtmlEnabled', false)
|
||||||
|
this.$emit('update:exportToPngEnabled', !!this.dataSources)
|
||||||
|
this.$emit('update:exportToClipboardEnabled', !!this.dataSources)
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.resizeObserver = new ResizeObserver(this.handleResize)
|
this.resizeObserver = new ResizeObserver(this.handleResize)
|
||||||
@@ -70,6 +77,10 @@ export default {
|
|||||||
async showViewSettings() {
|
async showViewSettings() {
|
||||||
await this.$nextTick()
|
await this.$nextTick()
|
||||||
this.handleResize()
|
this.handleResize()
|
||||||
|
},
|
||||||
|
dataSources() {
|
||||||
|
this.$emit('update:exportToPngEnabled', !!this.dataSources)
|
||||||
|
this.$emit('update:exportToClipboardEnabled', !!this.dataSources)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -85,8 +96,8 @@ export default {
|
|||||||
await this.$refs.graphEditor.saveAsPng()
|
await this.$refs.graphEditor.saveAsPng()
|
||||||
this.$emit('loadingImageCompleted')
|
this.$emit('loadingImageCompleted')
|
||||||
},
|
},
|
||||||
async prepareCopy() {
|
prepareCopy() {
|
||||||
return await this.$refs.graphEditor.prepareCopy()
|
return this.$refs.graphEditor.prepareCopy()
|
||||||
},
|
},
|
||||||
async handleResize() {
|
async handleResize() {
|
||||||
const renderer = this.$refs.graphEditor.renderer
|
const renderer = this.$refs.graphEditor.renderer
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import fIo from '@/lib/utils/fileIo'
|
|||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
import 'pivottable'
|
import 'pivottable'
|
||||||
import 'pivottable/dist/pivot.css'
|
import 'pivottable/dist/pivot.css'
|
||||||
import PivotUi from './PivotUi'
|
import PivotUi from './PivotUi/index.vue'
|
||||||
import pivotHelper from './pivotHelper'
|
import pivotHelper from './pivotHelper'
|
||||||
import Chart from '@/views/MainView/Workspace/Tabs/Tab/DataView/Chart'
|
import Chart from '@/views/MainView/Workspace/Tabs/Tab/DataView/Chart'
|
||||||
import chartHelper from '@/lib/chartHelper'
|
import chartHelper from '@/lib/chartHelper'
|
||||||
@@ -227,12 +227,12 @@ export default {
|
|||||||
|
|
||||||
async prepareCopy() {
|
async prepareCopy() {
|
||||||
if (this.viewCustomChart) {
|
if (this.viewCustomChart) {
|
||||||
return await this.$refs.customChart.prepareCopy()
|
return this.$refs.customChart.prepareCopy()
|
||||||
}
|
}
|
||||||
if (this.viewStandartChart) {
|
if (this.viewStandartChart) {
|
||||||
return await chartHelper.getImageDataUrl(this.$refs.pivotOutput, 'png')
|
return chartHelper.getImageDataUrl(this.$refs.pivotOutput, 'png')
|
||||||
}
|
}
|
||||||
return await pivotHelper.getPivotCanvas(this.$refs.pivotOutput)
|
return pivotHelper.getPivotCanvas(this.$refs.pivotOutput)
|
||||||
},
|
},
|
||||||
|
|
||||||
async saveAsSvg() {
|
async saveAsSvg() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
v-model:exportToPngEnabled="exportToPngEnabled"
|
v-model:exportToPngEnabled="exportToPngEnabled"
|
||||||
v-model:exportToSvgEnabled="exportToSvgEnabled"
|
v-model:exportToSvgEnabled="exportToSvgEnabled"
|
||||||
v-model:exportToHtmlEnabled="exportToHtmlEnabled"
|
v-model:exportToHtmlEnabled="exportToHtmlEnabled"
|
||||||
|
v-model:exportToClipboardEnabled="exportToClipboardEnabled"
|
||||||
:initOptions="initOptionsByMode[mode]"
|
:initOptions="initOptionsByMode[mode]"
|
||||||
:data-sources="dataSource"
|
:data-sources="dataSource"
|
||||||
:showViewSettings="showViewSettings"
|
:showViewSettings="showViewSettings"
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<side-tool-bar panel="dataView" @switch-to="$emit('switchTo', $event)">
|
<side-tool-bar panel="dataView" @switch-to="$emit('switchTo', $event)">
|
||||||
<icon-button
|
<icon-button
|
||||||
|
ref="chartBtn"
|
||||||
:active="mode === 'chart'"
|
:active="mode === 'chart'"
|
||||||
tooltip="Switch to chart"
|
tooltip="Switch to chart"
|
||||||
tooltipPosition="top-left"
|
tooltipPosition="top-left"
|
||||||
@@ -33,6 +35,7 @@
|
|||||||
<pivot-icon />
|
<pivot-icon />
|
||||||
</icon-button>
|
</icon-button>
|
||||||
<icon-button
|
<icon-button
|
||||||
|
ref="graphBtn"
|
||||||
:active="mode === 'graph'"
|
:active="mode === 'graph'"
|
||||||
tooltip="Switch to graph"
|
tooltip="Switch to graph"
|
||||||
tooltipPosition="top-left"
|
tooltipPosition="top-left"
|
||||||
@@ -56,6 +59,7 @@
|
|||||||
<div class="side-tool-bar-divider" />
|
<div class="side-tool-bar-divider" />
|
||||||
|
|
||||||
<icon-button
|
<icon-button
|
||||||
|
ref="pngExportBtn"
|
||||||
:disabled="!exportToPngEnabled || loadingImage"
|
:disabled="!exportToPngEnabled || loadingImage"
|
||||||
:loading="loadingImage"
|
:loading="loadingImage"
|
||||||
tooltip="Save as PNG image"
|
tooltip="Save as PNG image"
|
||||||
@@ -85,6 +89,7 @@
|
|||||||
</icon-button>
|
</icon-button>
|
||||||
<icon-button
|
<icon-button
|
||||||
ref="copyToClipboardBtn"
|
ref="copyToClipboardBtn"
|
||||||
|
:disabled="!exportToClipboardEnabled"
|
||||||
:loading="copyingImage"
|
:loading="copyingImage"
|
||||||
tooltip="Copy visualisation to clipboard"
|
tooltip="Copy visualisation to clipboard"
|
||||||
tooltipPosition="top-left"
|
tooltipPosition="top-left"
|
||||||
@@ -156,6 +161,7 @@ export default {
|
|||||||
exportToPngEnabled: true,
|
exportToPngEnabled: true,
|
||||||
exportToSvgEnabled: true,
|
exportToSvgEnabled: true,
|
||||||
exportToHtmlEnabled: true,
|
exportToHtmlEnabled: true,
|
||||||
|
exportToClipboardEnabled: true,
|
||||||
loadingImage: false,
|
loadingImage: false,
|
||||||
copyingImage: false,
|
copyingImage: false,
|
||||||
preparingCopy: false,
|
preparingCopy: false,
|
||||||
@@ -178,6 +184,7 @@ export default {
|
|||||||
mode(newMode, oldMode) {
|
mode(newMode, oldMode) {
|
||||||
this.$emit('update')
|
this.$emit('update')
|
||||||
this.exportToPngEnabled = true
|
this.exportToPngEnabled = true
|
||||||
|
this.exportToClipboardEnabled = true
|
||||||
this.initOptionsByMode[oldMode] = this.getOptionsForSave()
|
this.initOptionsByMode[oldMode] = this.getOptionsForSave()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
1874
tests/components/Graph/GraphEditor.spec.js
Normal file
1874
tests/components/Graph/GraphEditor.spec.js
Normal file
File diff suppressed because it is too large
Load Diff
1206
tests/lib/graphHelper.spec.js
Normal file
1206
tests/lib/graphHelper.spec.js
Normal file
File diff suppressed because it is too large
Load Diff
20
tests/testUtils.js
Normal file
20
tests/testUtils.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export function waitCondition(condition, timeoutMs = 5000) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (condition()) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const start = new Date().getTime()
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (condition()) {
|
||||||
|
clearInterval(interval)
|
||||||
|
resolve()
|
||||||
|
} else {
|
||||||
|
if (new Date().getTime() - start > timeoutMs) {
|
||||||
|
clearInterval(interval)
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ describe('Chart.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('getOptionsForSave called with proper arguments', () => {
|
it('getOptionsForSave called with proper arguments', () => {
|
||||||
// mount the component
|
|
||||||
const wrapper = mount(Chart, {
|
const wrapper = mount(Chart, {
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store }
|
||||||
@@ -30,7 +29,6 @@ describe('Chart.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('emits update when plotly updates', async () => {
|
it('emits update when plotly updates', async () => {
|
||||||
// mount the component
|
|
||||||
const wrapper = mount(Chart, {
|
const wrapper = mount(Chart, {
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store }
|
||||||
@@ -48,7 +46,6 @@ describe('Chart.vue', () => {
|
|||||||
points: [80]
|
points: [80]
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount the component
|
|
||||||
const wrapper = mount(Chart, {
|
const wrapper = mount(Chart, {
|
||||||
props: {
|
props: {
|
||||||
dataSources,
|
dataSources,
|
||||||
@@ -187,7 +184,8 @@ describe('Chart.vue', () => {
|
|||||||
const wrapper = mount(Chart, {
|
const wrapper = mount(Chart, {
|
||||||
attachTo: document.body,
|
attachTo: document.body,
|
||||||
props: {
|
props: {
|
||||||
dataSources
|
dataSources,
|
||||||
|
showViewSettings: true
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store }
|
||||||
@@ -207,4 +205,41 @@ describe('Chart.vue', () => {
|
|||||||
expect(wrapper.find('.Select__menu').text()).to.contain('name' + 'points')
|
expect(wrapper.find('.Select__menu').text()).to.contain('name' + 'points')
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('hides and shows controls depending on showViewSettings and resizes the plot', async () => {
|
||||||
|
const wrapper = mount(Chart, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
dataSources: null,
|
||||||
|
showViewSettings: false
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// don't call flushPromises here, otherwize resize observer will be call to often
|
||||||
|
// which causes ResizeObserver loop completed with undelivered notifications.
|
||||||
|
await nextTick()
|
||||||
|
|
||||||
|
const plot = wrapper.find('.svg-container').wrapperElement
|
||||||
|
await flushPromises()
|
||||||
|
const initialPlotWidth = plot.scrollWidth
|
||||||
|
const initialPlotHeight = plot.scrollHeight
|
||||||
|
|
||||||
|
expect(wrapper.find('.plotly_editor .editor_controls').exists()).to.equal(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
await wrapper.setProps({ showViewSettings: true })
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(plot.scrollWidth).not.to.equal(initialPlotWidth)
|
||||||
|
expect(plot.scrollHeight).to.equal(initialPlotHeight)
|
||||||
|
expect(wrapper.find('.plotly_editor .editor_controls').exists()).to.equal(
|
||||||
|
true
|
||||||
|
)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import DataView from '@/views/MainView/Workspace/Tabs/Tab/DataView'
|
import DataView from '@/views/MainView/Workspace/Tabs/Tab/DataView/index.vue'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import { nextTick } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
import cIo from '@/lib/utils/clipboardIo'
|
import cIo from '@/lib/utils/clipboardIo'
|
||||||
@@ -15,7 +15,7 @@ describe('DataView.vue', () => {
|
|||||||
it('emits update on mode changing', async () => {
|
it('emits update on mode changing', async () => {
|
||||||
const wrapper = mount(DataView, {
|
const wrapper = mount(DataView, {
|
||||||
global: {
|
global: {
|
||||||
stubs: { chart: true }
|
mocks: { $store }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -29,7 +29,10 @@ describe('DataView.vue', () => {
|
|||||||
it('method getOptionsForSave calls the same method of the current view component', async () => {
|
it('method getOptionsForSave calls the same method of the current view component', async () => {
|
||||||
const wrapper = mount(DataView, {
|
const wrapper = mount(DataView, {
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -53,13 +56,28 @@ describe('DataView.vue', () => {
|
|||||||
expect(wrapper.vm.getOptionsForSave()).to.eql({
|
expect(wrapper.vm.getOptionsForSave()).to.eql({
|
||||||
here_are: 'pivot_settings'
|
here_are: 'pivot_settings'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
|
await graphBtn.trigger('click')
|
||||||
|
|
||||||
|
const graph = wrapper.findComponent({ name: 'graph' }).vm
|
||||||
|
sinon
|
||||||
|
.stub(graph, 'getOptionsForSave')
|
||||||
|
.returns({ here_are: 'graph_settings' })
|
||||||
|
|
||||||
|
expect(wrapper.vm.getOptionsForSave()).to.eql({
|
||||||
|
here_are: 'graph_settings'
|
||||||
|
})
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('method saveAsSvg calls the same method of the current view component', async () => {
|
it('method saveAsSvg calls the same method of the current view component', async () => {
|
||||||
const wrapper = mount(DataView, {
|
const wrapper = mount(DataView, {
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -87,13 +105,22 @@ describe('DataView.vue', () => {
|
|||||||
// Export to svg
|
// Export to svg
|
||||||
await svgBtn.trigger('click')
|
await svgBtn.trigger('click')
|
||||||
expect(pivot.saveAsSvg.calledOnce).to.equal(true)
|
expect(pivot.saveAsSvg.calledOnce).to.equal(true)
|
||||||
|
|
||||||
|
// Switch to graph - svg disabled
|
||||||
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
|
await graphBtn.trigger('click')
|
||||||
|
expect(svgBtn.attributes('disabled')).to.not.equal(undefined)
|
||||||
|
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('method saveAsHtml calls the same method of the current view component', async () => {
|
it('method saveAsHtml calls the same method of the current view component', async () => {
|
||||||
const wrapper = mount(DataView, {
|
const wrapper = mount(DataView, {
|
||||||
global: {
|
global: {
|
||||||
mocks: { $store }
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -114,9 +141,76 @@ describe('DataView.vue', () => {
|
|||||||
const pivot = wrapper.findComponent({ name: 'pivot' }).vm
|
const pivot = wrapper.findComponent({ name: 'pivot' }).vm
|
||||||
sinon.spy(pivot, 'saveAsHtml')
|
sinon.spy(pivot, 'saveAsHtml')
|
||||||
|
|
||||||
// Export to svg
|
// Export to html
|
||||||
await htmlBtn.trigger('click')
|
await htmlBtn.trigger('click')
|
||||||
expect(pivot.saveAsHtml.calledOnce).to.equal(true)
|
expect(pivot.saveAsHtml.calledOnce).to.equal(true)
|
||||||
|
|
||||||
|
// Switch to graph - htmlBtn disabled
|
||||||
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
|
await graphBtn.trigger('click')
|
||||||
|
expect(htmlBtn.attributes('disabled')).to.not.equal(undefined)
|
||||||
|
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('method saveAsPng calls the same method of the current view component', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
|
const wrapper = mount(DataView, {
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Find chart and stub the method
|
||||||
|
const chart = wrapper.findComponent({ name: 'Chart' }).vm
|
||||||
|
sinon.stub(chart, 'saveAsPng').callsFake(() => {
|
||||||
|
chart.$emit('loadingImageCompleted')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Export to png
|
||||||
|
const pngBtn = wrapper.findComponent({ ref: 'pngExportBtn' })
|
||||||
|
await pngBtn.trigger('click')
|
||||||
|
await clock.tick(0)
|
||||||
|
expect(chart.saveAsPng.calledOnce).to.equal(true)
|
||||||
|
|
||||||
|
// Switch to pivot
|
||||||
|
const pivotBtn = wrapper.findComponent({ ref: 'pivotBtn' })
|
||||||
|
await pivotBtn.trigger('click')
|
||||||
|
|
||||||
|
// Find pivot and stub the method
|
||||||
|
const pivot = wrapper.findComponent({ name: 'pivot' }).vm
|
||||||
|
sinon.stub(pivot, 'saveAsPng').callsFake(() => {
|
||||||
|
pivot.$emit('loadingImageCompleted')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Export to png
|
||||||
|
await pngBtn.trigger('click')
|
||||||
|
await clock.tick(0)
|
||||||
|
expect(pivot.saveAsPng.calledOnce).to.equal(true)
|
||||||
|
|
||||||
|
// Switch to graph
|
||||||
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
|
await graphBtn.trigger('click')
|
||||||
|
|
||||||
|
// Save as png is disabled because there is no data
|
||||||
|
expect(pngBtn.attributes('disabled')).to.not.equal(undefined)
|
||||||
|
|
||||||
|
await wrapper.setProps({ dataSource: { doc: [] } })
|
||||||
|
|
||||||
|
// Find graph and stub the method
|
||||||
|
const graph = wrapper.findComponent({ name: 'graph' }).vm
|
||||||
|
sinon.stub(graph, 'saveAsPng').callsFake(() => {
|
||||||
|
graph.$emit('loadingImageCompleted')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Export to png
|
||||||
|
await pngBtn.trigger('click')
|
||||||
|
await clock.tick(0)
|
||||||
|
expect(graph.saveAsPng.calledOnce).to.equal(true)
|
||||||
|
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -276,4 +370,52 @@ describe('DataView.vue', () => {
|
|||||||
expect(wrapper.vm.copyToClipboard.calledOnce).to.equal(false)
|
expect(wrapper.vm.copyToClipboard.calledOnce).to.equal(false)
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('saves visualisation options and restores them when switch between modes', async () => {
|
||||||
|
const wrapper = mount(DataView, {
|
||||||
|
props: {
|
||||||
|
initMode: 'graph',
|
||||||
|
initOptions: { test_options: 'graph_options_from_inquiery' }
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
stubs: {
|
||||||
|
chart: true,
|
||||||
|
graph: true,
|
||||||
|
pivot: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const getOptionsForSaveStub = sinon.stub(wrapper.vm, 'getOptionsForSave')
|
||||||
|
|
||||||
|
expect(
|
||||||
|
wrapper.findComponent({ name: 'graph' }).props('initOptions')
|
||||||
|
).to.eql({ test_options: 'graph_options_from_inquiery' })
|
||||||
|
|
||||||
|
getOptionsForSaveStub.returns({ test_options: 'latest_graph_options' })
|
||||||
|
const chartBtn = wrapper.findComponent({ ref: 'chartBtn' })
|
||||||
|
await chartBtn.trigger('click')
|
||||||
|
|
||||||
|
getOptionsForSaveStub.returns({ test_options: 'chart_settings' })
|
||||||
|
|
||||||
|
const pivotBtn = wrapper.findComponent({ ref: 'pivotBtn' })
|
||||||
|
await pivotBtn.trigger('click')
|
||||||
|
|
||||||
|
getOptionsForSaveStub.returns({ test_options: 'pivot_settings' })
|
||||||
|
await chartBtn.trigger('click')
|
||||||
|
expect(
|
||||||
|
wrapper.findComponent({ name: 'chart' }).props('initOptions')
|
||||||
|
).to.eql({ test_options: 'chart_settings' })
|
||||||
|
|
||||||
|
await pivotBtn.trigger('click')
|
||||||
|
expect(
|
||||||
|
wrapper.findComponent({ name: 'pivot' }).props('initOptions')
|
||||||
|
).to.eql({ test_options: 'pivot_settings' })
|
||||||
|
|
||||||
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
|
await graphBtn.trigger('click')
|
||||||
|
expect(
|
||||||
|
wrapper.findComponent({ name: 'graph' }).props('initOptions')
|
||||||
|
).to.eql({ test_options: 'latest_graph_options' })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,504 @@
|
|||||||
|
import { expect } from 'chai'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
|
import Graph from '@/views/MainView/Workspace/Tabs/Tab/DataView/Graph/index.vue'
|
||||||
|
|
||||||
|
function getPixels(canvas) {
|
||||||
|
const context = canvas.getContext('webgl2')
|
||||||
|
const width = context.canvas.width
|
||||||
|
const height = context.canvas.height
|
||||||
|
|
||||||
|
// Create arrays to hold the pixel data
|
||||||
|
const pixels = new Uint8Array(width * height * 4)
|
||||||
|
|
||||||
|
// Read pixels from canvas
|
||||||
|
context.readPixels(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
context.RGBA,
|
||||||
|
context.UNSIGNED_BYTE,
|
||||||
|
pixels
|
||||||
|
)
|
||||||
|
return pixels.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Graph.vue', () => {
|
||||||
|
const $store = { state: { isWorkspaceVisible: true } }
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shows message when no data', () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
GraphEditor: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
attachTo: document.body
|
||||||
|
})
|
||||||
|
expect(wrapper.find('.no-data').isVisible()).to.equal(true)
|
||||||
|
expect(wrapper.find('.invalid-data').isVisible()).to.equal(false)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shows message when data is invalid', () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
props: {
|
||||||
|
dataSources: {
|
||||||
|
column1: ['value1', 'value2']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
GraphEditor: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
attachTo: document.body
|
||||||
|
})
|
||||||
|
expect(wrapper.find('.no-data').isVisible()).to.equal(false)
|
||||||
|
expect(wrapper.find('.invalid-data').isVisible()).to.equal(true)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('emits update when graph editor updates', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
GraphEditor: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
wrapper.findComponent({ ref: 'graphEditor' }).vm.$emit('update')
|
||||||
|
expect(wrapper.emitted('update')).to.have.lengthOf(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('the graph resizes when the container resizes', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type":0,"node_id":"Gryffindor"}',
|
||||||
|
'{"object_type":0,"node_id":"Hufflepuff"}'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
initOptions: {
|
||||||
|
structure: {
|
||||||
|
nodeId: 'node_id',
|
||||||
|
objectType: 'object_type',
|
||||||
|
edgeSource: 'source',
|
||||||
|
edgeTarget: 'target'
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
nodes: {
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#1F77B4'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#444444'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
edges: {
|
||||||
|
showDirection: true,
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#a2b1c6'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#a2b1c6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
type: 'circular',
|
||||||
|
options: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const container =
|
||||||
|
wrapper.find('.graph-container').wrapperElement.parentElement
|
||||||
|
const canvas = wrapper.find('canvas.sigma-nodes').wrapperElement
|
||||||
|
|
||||||
|
const initialContainerWidth = container.scrollWidth
|
||||||
|
const initialContainerHeight = container.scrollHeight
|
||||||
|
|
||||||
|
const initialCanvasWidth = canvas.scrollWidth
|
||||||
|
const initialCanvasHeight = canvas.scrollHeight
|
||||||
|
|
||||||
|
const newContainerWidth = initialContainerWidth * 2 || 1000
|
||||||
|
const newContainerHeight = initialContainerHeight * 2 || 2000
|
||||||
|
|
||||||
|
container.style.width = `${newContainerWidth}px`
|
||||||
|
container.style.height = `${newContainerHeight}px`
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(canvas.scrollWidth).not.to.equal(initialCanvasWidth)
|
||||||
|
expect(canvas.scrollHeight).not.to.equal(initialCanvasHeight)
|
||||||
|
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('nodes and edges are rendered', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
showViewSettings: true,
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type": 0, "node_id": 1}',
|
||||||
|
'{"object_type": 0, "node_id": 2}',
|
||||||
|
'{"object_type": 1, "source": 1, "target": 2}'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const container =
|
||||||
|
wrapper.find('.graph-container').wrapperElement.parentElement
|
||||||
|
container.style.height = '400px'
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_object_type_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
let options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
|
||||||
|
await options[0].trigger('click')
|
||||||
|
|
||||||
|
const nodeCanvasPixelsBefore = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-nodes').wrapperElement
|
||||||
|
)
|
||||||
|
const edgeCanvasPixelsBefore = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-edges').wrapperElement
|
||||||
|
)
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_node_id_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[1].trigger('click')
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_edge_source_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[2].trigger('click')
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_edge_target_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[3].trigger('click')
|
||||||
|
|
||||||
|
const nodeCanvasPixelsAfter = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-nodes').wrapperElement
|
||||||
|
)
|
||||||
|
const edgeCanvasPixelsAfter = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-edges').wrapperElement
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(nodeCanvasPixelsBefore).not.equal(nodeCanvasPixelsAfter)
|
||||||
|
expect(edgeCanvasPixelsBefore).not.equal(edgeCanvasPixelsAfter)
|
||||||
|
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rerenders when dataSource changes but does not rerender if dataSources is empty', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
showViewSettings: true,
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type": 0, "node_id": 1}',
|
||||||
|
'{"object_type": 0, "node_id": 2}',
|
||||||
|
'{"object_type": 1, "source": 1, "target": 2}'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const container =
|
||||||
|
wrapper.find('.graph-container').wrapperElement.parentElement
|
||||||
|
container.style.height = '400px'
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_object_type_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
let options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
|
||||||
|
await options[0].trigger('click')
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_node_id_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[1].trigger('click')
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_edge_source_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[2].trigger('click')
|
||||||
|
|
||||||
|
await wrapper
|
||||||
|
.find('.test_edge_target_select.dropdown-container .Select__indicator')
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
|
||||||
|
options = wrapper.findAll('.Select__menu .Select__option')
|
||||||
|
await options[3].trigger('click')
|
||||||
|
|
||||||
|
const nodeCanvasPixelsBefore = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-nodes').wrapperElement
|
||||||
|
)
|
||||||
|
const edgeCanvasPixelsBefore = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-edges').wrapperElement
|
||||||
|
)
|
||||||
|
await wrapper.setProps({
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type": 0, "node_id": 1}',
|
||||||
|
'{"object_type": 0, "node_id": 2}',
|
||||||
|
'{"object_type": 0, "node_id": 3}',
|
||||||
|
'{"object_type": 1, "source": 1, "target": 2}',
|
||||||
|
'{"object_type": 1, "source": 1, "target": 3}'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const nodeCanvasPixelsAfter = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-nodes').wrapperElement
|
||||||
|
)
|
||||||
|
const edgeCanvasPixelsAfter = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-edges').wrapperElement
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(nodeCanvasPixelsBefore).not.equal(nodeCanvasPixelsAfter)
|
||||||
|
expect(edgeCanvasPixelsBefore).not.equal(edgeCanvasPixelsAfter)
|
||||||
|
|
||||||
|
await wrapper.setProps({
|
||||||
|
dataSources: null
|
||||||
|
})
|
||||||
|
|
||||||
|
const nodeCanvasPixelsAfterEmtyData = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-nodes').wrapperElement
|
||||||
|
)
|
||||||
|
const edgeCanvasPixelsAfterEmtyData = getPixels(
|
||||||
|
wrapper.find('.test_graph_output canvas.sigma-edges').wrapperElement
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(nodeCanvasPixelsAfterEmtyData).equal(nodeCanvasPixelsAfter)
|
||||||
|
expect(edgeCanvasPixelsAfterEmtyData).equal(edgeCanvasPixelsAfter)
|
||||||
|
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('saveAsPng', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
props: {
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type":0,"node_id":"Gryffindor"}',
|
||||||
|
'{"object_type":0,"node_id":"Hufflepuff"}'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
initOptions: {
|
||||||
|
structure: {
|
||||||
|
nodeId: 'node_id',
|
||||||
|
objectType: 'object_type',
|
||||||
|
edgeSource: 'source',
|
||||||
|
edgeTarget: 'target'
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
nodes: {
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#1F77B4'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#444444'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
edges: {
|
||||||
|
showDirection: true,
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#a2b1c6'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#a2b1c6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
type: 'circular',
|
||||||
|
options: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
sinon.stub(wrapper.vm.$refs.graphEditor, 'saveAsPng')
|
||||||
|
await wrapper.vm.saveAsPng()
|
||||||
|
expect(wrapper.emitted().loadingImageCompleted.length).to.equal(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('hides and shows controls depending on showViewSettings and resizes the graph', async () => {
|
||||||
|
const wrapper = mount(Graph, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
dataSources: {
|
||||||
|
doc: [
|
||||||
|
'{"object_type":0,"node_id":"Gryffindor"}',
|
||||||
|
'{"object_type":0,"node_id":"Hufflepuff"}'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
initOptions: {
|
||||||
|
structure: {
|
||||||
|
nodeId: 'node_id',
|
||||||
|
objectType: 'object_type',
|
||||||
|
edgeSource: 'source',
|
||||||
|
edgeTarget: 'target'
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
nodes: {
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#1F77B4'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#444444'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
edges: {
|
||||||
|
showDirection: true,
|
||||||
|
size: {
|
||||||
|
type: 'constant',
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: 'constant',
|
||||||
|
value: '#a2b1c6'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
source: null,
|
||||||
|
color: '#a2b1c6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
type: 'circular',
|
||||||
|
options: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: { $store },
|
||||||
|
provide: {
|
||||||
|
tabLayout: { dataView: 'above' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const canvas = wrapper.find('canvas.sigma-nodes').wrapperElement
|
||||||
|
|
||||||
|
const initialPlotWidth = canvas.scrollWidth
|
||||||
|
const initialPlotHeight = canvas.scrollHeight
|
||||||
|
|
||||||
|
expect(
|
||||||
|
wrapper.find('.plotly_editor .editor_controls').isVisible()
|
||||||
|
).to.equal(false)
|
||||||
|
|
||||||
|
await wrapper.setProps({ showViewSettings: true })
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(canvas.scrollWidth).not.to.equal(initialPlotWidth)
|
||||||
|
expect(canvas.scrollHeight).to.equal(initialPlotHeight)
|
||||||
|
expect(
|
||||||
|
wrapper.find('.plotly_editor .editor_controls').isVisible()
|
||||||
|
).to.equal(true)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { mount, flushPromises } from '@vue/test-utils'
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
import Pivot from '@/views/MainView/Workspace/Tabs/Tab/DataView/Pivot'
|
import Pivot from '@/views/MainView/Workspace/Tabs/Tab/DataView/Pivot/index.vue'
|
||||||
import chartHelper from '@/lib/chartHelper'
|
import chartHelper from '@/lib/chartHelper'
|
||||||
import fIo from '@/lib/utils/fileIo'
|
import fIo from '@/lib/utils/fileIo'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
@@ -586,4 +586,48 @@ describe('Pivot.vue', () => {
|
|||||||
|
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('hides or shows controlls depending on showViewSettings and resizes standart chart', async () => {
|
||||||
|
const wrapper = mount(Pivot, {
|
||||||
|
global: {
|
||||||
|
mocks: { $store: { state: { isWorkspaceVisible: true } } }
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
dataSources: {
|
||||||
|
item: ['foo', 'bar', 'bar', 'bar'],
|
||||||
|
year: [2021, 2021, 2020, 2020]
|
||||||
|
},
|
||||||
|
initOptions: {
|
||||||
|
rows: ['item'],
|
||||||
|
cols: ['year'],
|
||||||
|
colOrder: 'key_a_to_z',
|
||||||
|
rowOrder: 'key_a_to_z',
|
||||||
|
aggregatorName: 'Count',
|
||||||
|
vals: [],
|
||||||
|
renderer: $.pivotUtilities.renderers['Bar Chart'],
|
||||||
|
rendererName: 'Bar Chart'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
attachTo: container
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(wrapper.find('.pivot-ui').isVisible()).to.equal(false)
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
const plot = wrapper.find('.svg-container').wrapperElement
|
||||||
|
const initialPlotHeight = plot.scrollHeight
|
||||||
|
|
||||||
|
await wrapper.setProps({ showViewSettings: true })
|
||||||
|
expect(wrapper.find('.pivot-ui').isVisible()).to.equal(true)
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
const plotAfterResize = wrapper.find('.svg-container').wrapperElement
|
||||||
|
|
||||||
|
expect(plotAfterResize.scrollWidth.scrollHeight).not.to.equal(
|
||||||
|
initialPlotHeight
|
||||||
|
)
|
||||||
|
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user