Files
Drew Slobodnjak 2502fe4d19 Canvas: Add Pan and Zoom (#76705)
* Canvas: Add Zoom

* Scale selecto components based on zoom state

* Fix pan by reverting to 3.1.0 for zoom-pan

* Update to latest library that fixes pan regression

* Add mini map to canvas pan zoom

* Fix selecto and anchors on hover

* Update naming to be more clear

* Switch back to contentComponent

* Apply transformScale to drag and resize

* Update connection source and target scaling

* Add option to display mini map

* Update yarn lock

* Revert "Update yarn lock"

This reverts commit 3d1dd65d5726fb0fd0813347451884a4034ae5d3.

* Set yarn lock to main

* Revert "Set yarn lock to main"

This reverts commit 64bc50557e75657fae14f81077d1d08b4e9e9029.

* Update to Yarn 4

* Add react-zoom-pan-pinch

* Update react-zoom-pan checksum

* Revert changes to json files

* Remove last line of api merged

* Remove last lines of all impacted jsons

* Update home json

* Update coordinate calc function to include scale

* Fix types in coordinate calc function

* Fix util calculation for transform

* Fix arrow anchor shift behavior

* Fix scale offset when adding elements during zoom

* Fix drag of selected group during zoom

* Add feature flag for canvas pan zoom

* Revert "Add feature flag for canvas pan zoom"

This reverts commit b026e31d8d9ed64b1fe307f852df10292fffadf4.

* Regenerate feature flag after merge

* Apply feature flag to enable pan zoom wrappers

* Add mini map toggle behind feature flag

* Simplify minimap behavior

* Update feature flag registry

* Set minimap to false by default

* fix gen-cue

* Set toggles gen to main

Add blank line to toggle gen csv

* Add canvas pan zoom to csv

* Remove old comment

* Change ref parameter to be more descriptive

* Rename visibleFun to be more descriptive

* Consolidate transformScale transformRef in util

* Remove non-null assertion on connection parentRect

* Consolidate parentRect null coalescing into object

* Remove minimap and change toggle

* Add controls inline help for pan and zoom

* Clean up mouse events

* Pull scale out of ref and isolate transform

* Remove transform ref from scene div

* Fix context menu visible behavior

* Fix connections and update util functions

* Move transform component instance to util

* fix backend test

* minor updates

* Clean up connections / fix minor bug where offset of arrow wasn't being calculated correctly

* missed connection code cleanup

* cleanup scene code a bit more

* actually fix backend test

* move eslint disable line closer to actual issue

---------

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
2024-01-02 11:52:21 -08:00

12 KiB

keywords labels title
grafana
schema
products
cloud
enterprise
oss
CanvasPanelCfg kind

Both documentation generation and kinds schemas are in active development and subject to change without prior notice.

CanvasPanelCfg

Maturity: experimental

Version: 0.0

Property Type Required Default Description
BackgroundConfig object Yes
BackgroundImageSize string Yes Possible values are: original, contain, cover, fill, tile.
CanvasConnection object Yes
CanvasElementOptions object Yes
ConnectionCoordinates object Yes
ConnectionPath string Yes Possible values are: straight.
Constraint object Yes
HorizontalConstraint string Yes Possible values are: left, right, leftright, center, scale.
HttpRequestMethod string Yes Possible values are: GET, POST, PUT.
LineConfig object Yes
Options object Yes
Placement object Yes
VerticalConstraint string Yes Possible values are: top, bottom, topbottom, center, scale.

BackgroundConfig

Property Type Required Default Description
color ColorDimensionConfig No
image ResourceDimensionConfig No Links to a resource (image/svg path)
size string No Possible values are: original, contain, cover, fill, tile.

ColorDimensionConfig

It extends BaseDimensionConfig.

Property Type Required Default Description
field string No (Inherited from BaseDimensionConfig)
fixed: T -- will be added by each element
fixed string No

BaseDimensionConfig

Property Type Required Default Description
field string No fixed: T -- will be added by each element

ResourceDimensionConfig

Links to a resource (image/svg path)

It extends BaseDimensionConfig.

Property Type Required Default Description
mode string Yes Possible values are: fixed, field, mapping.
field string No (Inherited from BaseDimensionConfig)
fixed: T -- will be added by each element
fixed string No

CanvasConnection

Property Type Required Default Description
path string Yes Possible values are: straight.
source ConnectionCoordinates Yes
target ConnectionCoordinates Yes
color ColorDimensionConfig No
size ScaleDimensionConfig No
targetName string No

ConnectionCoordinates

Property Type Required Default Description
x number Yes
y number Yes

ScaleDimensionConfig

It extends BaseDimensionConfig.

Property Type Required Default Description
max number Yes
min number Yes
field string No (Inherited from BaseDimensionConfig)
fixed: T -- will be added by each element
fixed number No
mode string No Possible values are: linear, quad.

CanvasElementOptions

Property Type Required Default Description
name string Yes
type string Yes
background BackgroundConfig No
border LineConfig No
config No TODO: figure out how to define this (element config(s))
connections CanvasConnection[] No
constraint Constraint No
placement Placement No

Constraint

Property Type Required Default Description
horizontal string No Possible values are: left, right, leftright, center, scale.
vertical string No Possible values are: top, bottom, topbottom, center, scale.

LineConfig

Property Type Required Default Description
color ColorDimensionConfig No
width number No

Placement

Property Type Required Default Description
bottom number No
height number No
left number No
right number No
top number No
width number No

Options

Property Type Required Default Description
inlineEditing boolean Yes true Enable inline editing
panZoom boolean Yes true Enable pan and zoom
root object Yes The root element of canvas (frame), where all canvas elements are nested
TODO: Figure out how to define a default value for this
showAdvancedTypes boolean Yes true Show all available element types

Root

The root element of canvas (frame), where all canvas elements are nested TODO: Figure out how to define a default value for this

Property Type Required Default Description
elements CanvasElementOptions[] Yes The list of canvas elements attached to the root element
name string Yes Name of the root element
type string Yes Type of root element (frame)
Possible values are: frame.