Перейти к содержанию

Навигация

SVG-Dashboards/en: различия между версиями

Нет описания правки
(Новая страница: «For example, if the value of the MQTT topic is equal to <code>1</code> , then print the value <code>ВКЛ</code> , otherwise — <code>ОТКЛ</code> : <syntaxhighlight lang="javascript"> (val == 1) ? 'ON' : 'OFF' </syntaxhighlight>»)
 
(не показано 7 промежуточных версий этого же участника)
Строка 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
Строка 184: Строка 184:
Here you can specify under what condition to show the image element. By default, the element will be hidden and displayed only while the condition is met.
Here you can specify under what condition to show the image element. By default, the element will be hidden and displayed only while the condition is met.


<div lang="ru" dir="ltr" class="mw-content-ltr">
In the '''Channel''' field, select the MQTT topic that the element will respond to, in the '''Condition''' field, select a condition, and in the '''Value''' field, select a value.
Выберите в поле '''Канал''' MQTT-топик, на информацию из которого будет реагировать элемент, в поле '''Условие''' выберите условие, а в поле '''Значение''' — значение.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Design style ===
=== Стиль оформления ===
Allows you to change the style of image elements. Can be used to create feedback for actions, notify the user about an event, etc.
Позволяет изменять стиль элементов изображения. Можно использовать для создания обратной связи для действий, оповещения пользователя о событии т.д.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Element properties available for styling:
Доступные для стилизации свойства элемента:
* fill — fill color;
* fill — цвет заливки;
* fill-opacity — fill opacity, values from 0.0 to 1.0 or as a percentage;
* fill-opacity — непрозрачность заливки, значения от 0.0 до 1.0 или в процентах;
* stroke — stroke color;
* stroke — цвет обводки;
* stroke- width — stroke thickness;
* stroke-width — толщина обводки;
* stroke-dasharray — dashed stroke type, set in units of length or percentage.
* stroke-dasharray — вид пунктирной обводки, задается в единицах длины или процентах.
* stroke-opacity — stroke opacity, values from 0.0 to 1.0 or percentage.
* stroke-opacity — непрозрачность обводки, значения от 0.0 до 1.0 или в процентах.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Colors can be named <code>black, red, yellow и т.п.</code> or hex values <code>#ffe680ff, #4f4f4dff и т.п.</code> .
Цвета можно задавать именами <code>black, red, yellow и т.п.</code> или шестнадцатеричными значениями <code>#ffe680ff, #4f4f4dff и т.п.</code>.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Let's change the color of the element depending on the state of the relay, if the value in the topic is <code>1</code> , then paint the object yellow, otherwise - gray:
Изменим цвет элемента в зависимости от состояния реле, если в топике значение <code>1</code>, то закрашиваем объект желтым, иначе — серым:
<syntaxhighlight lang="javascript">  
<syntaxhighlight lang="javascript">
(val == 1) ? ';fill: yellow' : ';fill: gray'
(val == 1) ? ';fill: yellow' : ';fill: gray'
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Let's make it so that when the value is greater than 20, the stroke of the element becomes red, dotted and 2px thick. For values less than or equal to 20, the element style will be left by default:
Сделаем так, чтобы при значении больше 20 обводка элемента стала красного цвета, пунктиром и толщиной 2px. При значениях меньше или равно 20 стиль элемента оставим по умолчанию:
<syntaxhighlight lang="javascript">  
<syntaxhighlight lang="javascript">
(val > 20) ? 'stroke: red; stroke-width:2px; stroke-dasharray:2,1' : ''
(val > 20) ? 'stroke: red; stroke-width:2px; stroke-dasharray:2,1' : ''
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
== Editing ==
== Редактирование ==
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Panel ===
=== Панель ===
To make changes:
Чтобы внести изменения:
# Open the SVG panel.
# Откройте SVG-панель.
# Click on the '''Edit''' button.
# Нажмите кнопку '''Редактировать'''.
# Make changes and save them by clicking on the ' button ''Demonstration'''.
# Внесите изменения и сохраните их нажатием на кнопку '''Демонстрация'''.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== SVG Image ===
=== SVG-изображение ===
==== Release wb-2307 and newer ====
==== Релиз wb-2307 и новее ====
{{SupportedSinceRelease
{{SupportedSinceRelease
| release = wb-2307
| release=wb-2307
|content=
|content=
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
SVG panels use identifiers embedded in the file (the id tag), so to edit the panel, simply make changes to the drawing and upload the new version to the controller.  
В SVG-панелях используются встроенные в файл идентификаторы (тег id), поэтому для редактирования панели просто внесите изменения в рисунок и загрузите новую версию в контроллер.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Important! If you have made a binding to a group of elements, then do not ungroup this group! If you need to change it, just go to the group in Inkscape and add or remove elements.
Важно! Если вы сделали привязку к группе элементов, то не разгруппировывайте эту группу! Если вам надо её изменить, просто войдите в группу в Inkscape и добавьте или удалите элементы.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
}}
}}
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
==== Release wb-2304 and older ====
==== Релиз wb-2304 и старее ====
The SVG panel editor assigns data-svg-param-id at the time of binding actions to the element, so to edit the image, you need to load it from the controller to the computer:
Редактор SVG-панели в момент привязки действий к элементу прописывает data-svg-param-id, поэтому для редактирования изображения нужно его загрузить с контроллера на компьютер:
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
# Open the SVG panel for editing.
# Откройте SVG-панель для редактирования.
# At the top of the window, click the '''Download''' button, the svg file will be downloaded to your computer.
# В верхней части окна нажмите кнопку '''Download''', на компьютер загрузится svg-файл.
# Edit the file in Inkscape. We do not recommend editing such files in Adobe Illustrator - [https://support.wirenboard.com/t/redaktirovanie-svg-dacsboard bindings are lost], there is no information about other editors.
# Отредактируйте файл в Inkscape. В Adobe Illustrator редактировать такие файлы не рекомендуем — [https://support.wirenboard.com/t/redaktirovanie-svg-dacsboard теряются привязки], про другие редакторы информации нет.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
When editing, keep in mind that if a link was assigned to an svg element, then it contains a hidden data-svg-param-id and when it is duplicated, a new element is created with the same data-svg-param-id.
При редактировании учтите, что если на svg-элемент была назначена связь, то он содержит скрытый data-svg-param-id и при его дублировании создается новый элемент с тем же data-svg-param-id.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Edit the resulting svg file and upload it to the controller again:
Отредактируйте полученный svg-файл и вновь загрузите его на контроллер:
# In the edit window, click the '''Select File''' button.
# В окне редактирования нажмите кнопку '''Выберите файл'''.
# After the '''Change''' button becomes active, click on her.
# После того, как кнопка '''Change''' станет активной, нажмите на нее.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
== Transfer to another controller ==
== Перенос на другой контроллер ==
Sometimes you need to make a backup copy of the svg-panel, for example, to transfer to another controller. To do this, you need to save the svg file converted by the editor and the description of its links and upload them to another controller.
Иногда нужно сделать резервную копию svg-панели, например, для переноса на другой контроллер. Для этого нужно сохранить преобразованный редактором svg-файл и описание его связей и загрузить их на другой контроллер.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
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.
Учтите, что на имена MQTT-топиков на обоих контроллерах должны совпадать. Если это не так — svg-элементы нужно будет привязать к новым MQTT-топикам.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Saving ===
=== Сохранение ===
Save the svg file and link description:
Сохраните svg-файл и описание связей:
# 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.
# В редакторе svg-панели нажмите кнопку '''В виде JSON''', скопируйте и сохраните строки в файл.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
=== Loading ===
=== Загрузка ===
# Create a new SVG panel following the instructions in the [[#Creating an SVG panel| Creating an SVG panel]].
# Создайте новую SVG-панель по инструкции в разделе [[#Создание SVG-панели| Создание SVG-панели]].
# 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
# В редакторе svg-панели нажмите кнопку '''В виде JSON''', скопируйте из сохраненного файла описание связей и вставьте текст в поле
# Click the '''Save'' button '' at the bottom of the page.
# Нажмите кнопку '''Сохранить''' внизу страницы.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
==Animation of SVG panel elements==
==Анимация элементов SVG-панели==
[[File:animation-svg.gif|598x|thumb|right| SVG panel element animation example]]
[[Файл:animation-svg.gif|598x|thumb|right| Пример анимации элемента SVG-панели]]
SVG panel elements can be animated using CSS.
Элементы SVG-панели можно анимировать с помощью CSS.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
To do this:
Для этого нужно:
#Draw an SVG panel in a vector editor like Inkscape.
#Нарисовать SVG-панель в векторном редакторе, например, Inkscape.
#Open the SVG file in a text editor and add a style block wrapped in tags<style></style> .
#Открыть файл SVG в текстовом редакторе и добавить блок стилей, заключенный в теги <code><style></style></code>.
#Add the '''@keyframes''' rule in the style block.
#В блоке стилей добавить правило '''@keyframes'''.
#Save the file and load it into the controller.
#Сохранить файл и загрузить его в контроллер.
#Go to the SVG panel editor in the controller's web interface.
#Перейти в редактор SVG-панели в веб-интерфейсе контроллера.
#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.
#Активировать параметр '''Style''' и задать в поле '''Value''' свойство '''animation'''. Также нужно задать условие при котором анимация будет срабатывать.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Rendering in CSS is done using the '''animation''' property and the '''@keyframes''' rule.  
Визуализация в CSS осуществляется с помощью свойства '''animation''' и правила '''@keyframes'''.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
'''@keyframes''', or keyframes, contain information about how the element should look at each point in time.
'''@keyframes''', или ключевые кадры, содержат информацию о том как должен выглядеть элемент в каждый из моментов времени.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
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>  
Здесь '''from''' и '''to''' ключевые слова обозначающие начальную и конечную точки анимации. Вместо них можно использовать 0% и 100%, а также добавить промежуточные значения.
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.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
The keyframe name is an identifier by which the rule will be called from the style description.
Имя кейфрейма — идентификатор, по которому правило будет вызываться из описания стилей.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
In order for the animation to work, you need to set the element style to the '''animation''' property.
Чтобы анимация заработала нужно задать стилю элемента свойство '''animation'''.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
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).
Свойство '''animation''' задаёт параметры действия для анимации (длительность анимации, повторение, направление, тип движения, шаги), а в блоке '''@keyframes''' задаётся сама анимация по шагам (изменения вида и положения).
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
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.
Покажем на примере создание анимации для изменения цвета текста с красного на зеленый и обратно. Так как в SVG текст выполняется заливкой, то потребуется изменять свойство '''fill'''.
[[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| Свойство '''animation''' задается в поле '''Value''' параметра '''Style''' ]]
#Let's create a new SVG document in the Inlscape editor and add the Text element to it.  
#Создадим новый SVG-документ в редакторе Inlskape и добавим в него элемент Текст.  
#Let's save the file and open it in a text editor.
#Сохраним файл и откроем его в текстовом редакторе.
#Add a style block like this:
#Добавим блок style следующего вида:
#:<syntaxhighlight lang="html">  
#:<syntaxhighlight lang="html">
<style>
  <style>
@keyframes changecolor {
@keyframes changecolor {
   0% {fill:red}
   0% {fill:red}
Строка 358: Строка 301:
   }
   }
   </style>
   </style>
</syntaxhighlight>
</syntaxhighlight>  
#Сохраним SVG-файл и загрузим его в контроллер.
#Save the SVG file and load it into the controller.
#В редакторе дашбордов выберем созданным тестовый элемент и зададим ему свойство animation в следующем виде:
#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>  
#:Так как изменение стиля элемента может происходить только по условию, в котором участвует значение из MQTT топика, то мы выбрали топик '''CPU Temperature''' и задали условие '''>20'''. Это значит, что анимация будет работать, только когда значение топика '''CPU Temperature''' больше 20.  
#: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| Создание ссылки в Inkscape ]]
[[Image : svg-hyperlink.png |300px|thumb|right| Creating a link in Inkscape ]]
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
The transition to external links is set at the stage of creating a picture in the Inkscape editor.
Переход по внешним ссылкам задаётся на этапе создания картинки в редакторе Inkscape.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Create hyperlinks like this:
Создавать гиперссылки так:
# Select an element that will serve as a link, then in the context menu Create a link (hyperlink).
# Выбрать элемент, который будет служить ссылкой, далее в контекстном меню Создать ссылку (hyperlink).
# Insert a link into the opened field.
# Вставить в открывшееся поле ссылку.
# Save.
# Сохранить.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Now it remains to load the image into the controller and check.
Теперь остаётся загрузить рисунок в контроллер и проверить.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
== Useful Links & Materials ==
== Полезные ссылки и материалы ==
* [[Media:Examples SVG-Dashboards.zip|SVG Dashboard Example Archive]]
* [[Media:Examples SVG-Dashboards.zip|Архив с примерами SVG-панелей]]
* [https://github.com/wirenboard/wb-dashboards- demo Sample panels in the wb-dashboards-demo repository]
* [https://github.com/wirenboard/wb-dashboards-demo Примеры панелей в репозитории 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 Как добавить в SVG-панель ссылку на график или другую страницу]
* [https://wirenboard.com/en/pages/wb-software/ Wiren Board Web Interface article]
* [https://wirenboard.com/ru/pages/wb-software/ Статья о веб-интерфейсе контроллера Wiren Board]
* [[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/ru/ Свободный SVG-редактор Inkscape]
</div>