16 293
правки
(Новая страница: «=== Read === Display values from the source in a text field.») |
|||
(не показано 5 промежуточных версий этого же участника) | |||
Строка 21: | Строка 21: | ||
Full-screen mode allows you to switch between panels through the side menu, and in HMI mode, you need to implement the switch yourself: add a button (object) with a URL to the desired panel in the SVG image. | Full-screen mode allows you to switch between panels through the side menu, and in HMI mode, you need to implement the switch yourself: add a button (object) with a URL to the desired panel in the SVG image. | ||
<gallery mode="packed" heights="150px" caption=" | <gallery mode="packed" heights="150px" caption="Panel modes"> | ||
Image: WebUI SVG.png | Standard view | Image: WebUI SVG.png | Standard view | ||
Image: WebUI SVG fullscreen.png | Fullscreen | Image: WebUI SVG fullscreen.png | Fullscreen | ||
Строка 247: | Строка 247: | ||
Please note that the names of the MQTT topics on both controllers must match. If this is not the case, svg elements will need to be attached to new MQTT topics. | Please note that the names of the MQTT topics on both controllers must match. If this is not the case, svg elements will need to be attached to new MQTT topics. | ||
=== Saving === | |||
Save the svg file and link description: | |||
# Download the file from the controller to your computer. To do this, click on the button with the image of a down arrow. | |||
# | # In the editor of the svg-panel, click the button '''As JSON''', copy and save the lines to a file. | ||
# | |||
=== Loading === | |||
== | # Create a new SVG panel following the instructions in the [[#Creating an SVG panel| Creating an SVG panel]]. | ||
# | # In the svg panel editor, click the '''As JSON''' button, copy the link description from the saved file and paste the text into the field | ||
# | # Click the '''Save'' button '' at the bottom of the page. | ||
# | |||
==Animation of SVG panel elements== | |||
[[File:animation-svg.gif|598x|thumb|right| SVG panel element animation example]] | |||
[[ | SVG panel elements can be animated using CSS. | ||
To do this: | |||
#Draw an SVG panel in a vector editor like Inkscape. | |||
# | #Open the SVG file in a text editor and add a style block wrapped in tags<style></style> . | ||
# | #Add the '''@keyframes''' rule in the style block. | ||
# | #Save the file and load it into the controller. | ||
# | #Go to the SVG panel editor in the controller's web interface. | ||
# | #Activate the '''Style''' parameter and set the property '''animation''' in the '''Value''' field. You also need to set the condition under which the animation will work. | ||
# | |||
Rendering in CSS is done using the '''animation''' property and the '''@keyframes''' rule. | |||
'''@keyframes''', or keyframes, contain information about how the element should look at each point in time. | |||
'''@keyframes''', | |||
A rule containing two keyframes would look like this: | |||
<syntaxhighlight lang="css"> | |||
<syntaxhighlight lang="css"> | @keyframes <keyframe name> { | ||
@keyframes < | from: { description of the initial state of the element } | ||
from: { | to: { description of the final state of the element } | ||
to: { | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Here '''from''' and '''to''' keywords denote the start and end points of the animation. Instead, you can use 0% and 100%, as well as add intermediate values. | |||
The keyframe name is an identifier by which the rule will be called from the style description. | |||
In order for the animation to work, you need to set the element style to the '''animation''' property. | |||
The '''animation''' property sets the animation action parameters (animation duration, repetition, direction, movement type, steps), and the '''@keyframes''' block sets the animation itself in steps (changes in appearance and position). | |||
Let's use an example to create an animation to change the text color from red to green and vice versa. Since text is filled in SVG, you will need to change the '''fill''' property. | |||
[[Image: animation-style.png |350px|thumb|right| The '''animation''' property is set in the '''Value''' field of the '''Style''' parameter ]] | |||
[[Image: animation-style.png |350px|thumb|right| | #Let's create a new SVG document in the Inlscape editor and add the Text element to it. | ||
# | #Let's save the file and open it in a text editor. | ||
# | #Add a style block like this: | ||
# | #:<syntaxhighlight lang="html"> | ||
#:<syntaxhighlight lang="html"> | <style> | ||
@keyframes changecolor { | @keyframes changecolor { | ||
0% {fill:red} | 0% {fill:red} | ||
Строка 322: | Строка 301: | ||
} | } | ||
</style> | </style> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# | #Save the SVG file and load it into the controller. | ||
# | #In the dashboard editor, select the created test element and set its animation property in the following form: | ||
#:<syntaxhighlight lang="javascript"> | #:<syntaxhighlight lang="javascript"> | ||
(val > 20) ? 'animation: changecolor 3s infinite linear;' : ' ' | (val > 20) ? 'animation: changecolor 3s infinite linear;' : ' ' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
#: | #:Since the element style can only be changed by a condition involving a value from the MQTT topic, we chose the '''CPU Temperature''' topic and set the condition '''>20'''. This means that the animation will only work when the value of the '''CPU Temperature''' topic is greater than 20. | ||
# | #Save the dashboard and go to the view. | ||
== | == Add external links == | ||
[[Image: svg-hyperlink.png |300px|thumb|right| | [[Image : svg-hyperlink.png |300px|thumb|right| Creating a link in Inkscape ]] | ||
The transition to external links is set at the stage of creating a picture in the Inkscape editor. | |||
Create hyperlinks like this: | |||
# Select an element that will serve as a link, then in the context menu Create a link (hyperlink). | |||
# | # Insert a link into the opened field. | ||
# | # Save. | ||
# | |||
Now it remains to load the image into the controller and check. | |||
== Useful Links & Materials == | |||
* [[Media:Examples SVG-Dashboards.zip|SVG Dashboard Example Archive]] | |||
* [[Media:Examples SVG-Dashboards.zip| | * [https://github.com/wirenboard/wb-dashboards- demo Sample panels in the wb-dashboards-demo repository] | ||
* [https://github.com/wirenboard/wb-dashboards-demo | * [https://support.wirenboard.com/t/vyvod-dannyh-v-vide-grafika-v-realnom-vremeni/13623/5 How to add to SVG panel link to a graph or another page] | ||
* [https://support.wirenboard.com/t/vyvod-dannyh-v-vide-grafika-v-realnom-vremeni/13623/5 | * [https://wirenboard.com/en/pages/wb-software/ Wiren Board Web Interface article] | ||
* [https://wirenboard.com/ | * [[Wiren Board Web Interface | Description of the controller web interface on the wiki]] | ||
* [[Wiren Board Web Interface | | * [https://inkscape.org/en/ Free Inkscape SVG editor] | ||
* [https://inkscape.org/ | |||