Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Frontend V2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Frontend V2
Commits
6d69dbf2
Commit
6d69dbf2
authored
2 weeks ago
by
Marcos Pieras
Browse files
Options
Downloads
Patches
Plain Diff
feat: adds dropdown icons and filtering
parent
40d559ff
Branches
fix/sharelink
No related tags found
No related merge requests found
Pipeline
#147541
passed
2 weeks ago
Stage: tag-release
Stage: get-release-tag
Stage: container-image
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/vis/visualizations/vis1D/Vis1D.tsx
+55
-21
55 additions, 21 deletions
src/lib/vis/visualizations/vis1D/Vis1D.tsx
with
55 additions
and
21 deletions
src/lib/vis/visualizations/vis1D/Vis1D.tsx
+
55
−
21
View file @
6d69dbf2
import
{
DropdownContainer
,
DropdownItem
,
DropdownItemContainer
,
DropdownTrigger
,
Icon
}
from
'
@/lib/components
'
;
import
{
Button
}
from
'
@/lib/components/buttons
'
;
import
{
getDataTypeIcon
}
from
'
@/lib/components/DataTypeIcon
'
;
import
{
Input
}
from
'
@/lib/components/inputs
'
;
import
{
EntityPill
}
from
'
@/lib/components/pills/Pill
'
;
import
{
SettingsContainer
}
from
'
@/lib/vis/components/config
'
;
import
html2canvas
from
'
html2canvas
'
;
import
React
,
{
forwardRef
,
useEffect
,
useImperativeHandle
,
useMemo
,
useRef
,
useState
}
from
'
react
'
;
import
{
SchemaAttributeTypes
}
from
'
ts-common
'
;
import
{
VISComponentType
,
VisualizationPropTypes
,
VisualizationSettingsPropTypes
}
from
'
../../common
'
;
import
{
CustomChartPlotly
}
from
'
./components/CustomChartPlotly
'
;
import
{
plotTypeOptions
,
preparePlotData
}
from
'
./components/MakePlot
'
;
...
...
@@ -102,7 +105,9 @@ const Vis1D = forwardRef<Vis1DVisHandle, VisualizationPropTypes<Vis1DProps>>(({
const
Vis1DSettings
=
({
settings
,
graphMetadata
,
updateSettings
}:
VisualizationSettingsPropTypes
<
Vis1DProps
>
)
=>
{
// !TODO: include relationship
const
mutablePlotTypes
=
[...
plotTypeOptions
];
const
[
attributeOptions
,
setAttributeOptions
]
=
useState
<
string
[]
>
([]);
const
[
attributeOptions
,
setAttributeOptions
]
=
useState
<
{
name
:
string
;
type
:
string
}[]
>
([]);
const
[
openXaxisLabel
,
setOpenXaxisLabel
]
=
useState
<
boolean
>
(
false
);
const
[
filter
,
setFilter
]
=
useState
<
string
>
(
''
);
useEffect
(()
=>
{
if
(
graphMetadata
&&
graphMetadata
.
nodes
&&
graphMetadata
.
nodes
.
labels
.
length
>
0
)
{
...
...
@@ -121,22 +126,29 @@ const Vis1DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio
if
(
graphMetadata
&&
graphMetadata
.
nodes
&&
graphMetadata
.
nodes
.
labels
.
length
>
0
&&
settings
.
selectedEntity
!=
''
)
{
const
labelNodes
=
graphMetadata
.
nodes
.
labels
;
if
(
labelNodes
.
includes
(
settings
.
selectedEntity
))
{
const
newAttributeOptions
=
Object
.
keys
(
graphMetadata
.
nodes
.
types
[
settings
.
selectedEntity
].
attributes
);
const
newAttributeOptions
:
{
name
:
string
;
type
:
string
}[]
=
Object
.
entries
(
graphMetadata
.
nodes
.
types
[
settings
.
selectedEntity
].
attributes
,
)
.
filter
(([
key
])
=>
key
.
toLowerCase
().
includes
(
filter
.
toLowerCase
()))
.
map
(([
key
,
value
])
=>
({
name
:
key
,
type
:
value
.
attributeType
,
}));
if
(
settings
.
xAxisLabel
===
''
)
{
updateSettings
({
xAxisLabel
:
newAttributeOptions
[
0
]
});
updateSettings
({
xAxisLabel
:
newAttributeOptions
[
0
]
.
name
});
// !TODO: instead of contain "datum" chekc type: if it is date
if
(
newAttributeOptions
[
0
].
includes
(
'
Datum
'
))
{
if
(
newAttributeOptions
[
0
].
name
.
includes
(
'
Datum
'
))
{
updateSettings
({
groupData
:
'
yearly
'
});
}
else
{
updateSettings
({
groupData
:
undefined
});
}
}
newAttributeOptions
.
unshift
(
'
'
);
setAttributeOptions
(
newAttributeOptions
);
}
}
},
[
graphMetadata
,
settings
.
selectedEntity
]);
},
[
graphMetadata
,
settings
.
selectedEntity
,
filter
]);
return
(
<
SettingsContainer
>
...
...
@@ -179,22 +191,44 @@ const Vis1DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio
/>
</
div
>
<
div
className
=
"mb-2"
>
<
Input
type
=
"dropdown"
label
=
"X-axis:"
value
=
{
settings
.
xAxisLabel
}
options
=
{
attributeOptions
}
onChange
=
{
value
=>
{
const
valueString
=
value
as
string
;
updateSettings
({
xAxisLabel
:
valueString
});
<
DropdownContainer
open
=
{
openXaxisLabel
}
onOpenChange
=
{
setOpenXaxisLabel
}
>
<
span
>
X Axis
</
span
>
<
DropdownTrigger
title
=
{
settings
.
xAxisLabel
}
size
=
"md"
variant
=
"outline"
onClick
=
{
()
=>
setOpenXaxisLabel
(
v
=>
!
v
)
}
/>
<
DropdownItemContainer
className
=
"max-h-none"
>
<
Input
label
=
""
type
=
{
'
text
'
}
placeholder
=
"Filter"
size
=
"xs"
className
=
"mb-1 rounded-sm w-full"
value
=
{
filter
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
onChange
=
{
v
=>
setFilter
(
v
)
}
/>
{
attributeOptions
.
map
(
attr
=>
(
<
DropdownItem
key
=
{
attr
.
name
+
attr
.
type
}
value
=
{
attr
.
name
}
className
=
"w-full"
onClick
=
{
value
=>
{
const
valueString
=
value
as
string
;
updateSettings
({
xAxisLabel
:
valueString
});
if
(
!
valueString
.
includes
(
'
Datum
'
))
{
updateSettings
({
groupData
:
undefined
});
}
else
{
updateSettings
({
groupData
:
'
monthly
'
});
}
}
}
/>
if
(
!
valueString
.
includes
(
'
Datum
'
))
{
updateSettings
({
groupData
:
undefined
});
}
else
{
updateSettings
({
groupData
:
'
monthly
'
});
}
setOpenXaxisLabel
(
false
);
}
}
>
<
div
className
=
"flex items-center gap-1"
>
<
Icon
component
=
{
getDataTypeIcon
(
attr
.
type
as
SchemaAttributeTypes
)
}
size
=
{
16
}
/>
</
div
>
</
DropdownItem
>
))
}
</
DropdownItemContainer
>
</
DropdownContainer
>
</
div
>
{
(
settings
.
plotType
===
'
scatter
'
||
settings
.
plotType
===
'
line
'
)
&&
(
<
div
className
=
"mb-2"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment