Skip to content
Snippets Groups Projects
Commit 176c00eb authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

color by location

parent 172d4096
No related branches found
No related tags found
No related merge requests found
package web
import (
"crypto/md5"
"fmt"
"git.sch.bme.hu/mikewashere/power-distribution/models"
)
func hashStringToColor(s string) string {
data := md5.Sum([]byte(s))
col := "#"
for i := 0; i < 3; i++ {
col += fmt.Sprintf("%02X", data[i])
}
return col
}
func LocationColor(l *models.Location) string {
return hashStringToColor(l.String())
}
...@@ -43,7 +43,7 @@ func visJSFromGraph(roots []*models.GraphNode) *visJS { ...@@ -43,7 +43,7 @@ func visJSFromGraph(roots []*models.GraphNode) *visJS {
i := 0 i := 0
for d := range devicesMap { for d := range devicesMap {
shape := "diamond" shape := "diamond"
color := "#97C2FC" color := LocationColor(d.Location)
fmt.Println(d.Type) fmt.Println(d.Type)
switch d.Type.Get() { switch d.Type.Get() {
case d.Type.Ups: case d.Type.Ups:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment