5911099800de — Sean E. Russell tip 7 years ago
Adds 9box
2 files changed, 157 insertions(+), 0 deletions(-)

A => cmd/9box/9box.go
A => cmd/9box/9box.svg.templ
A => cmd/9box/9box.go +86 -0
@@ 0,0 1,86 @@ 
+package main
+
+import (
+	"encoding/csv"
+	"html/template"
+	"io"
+	"io/ioutil"
+	"log"
+	"os"
+	"strconv"
+	"time"
+)
+
+type Data struct {
+	BU      string
+	Updated string
+	Owner   string
+	People  [][]Person
+}
+
+type Person struct {
+	Name  string
+	Title string
+}
+
+const (
+	NAME  = 0
+	TITLE = 2
+	BOX   = 6
+)
+
+func main() {
+	in, err := os.Open(os.Args[1])
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer in.Close()
+	r := csv.NewReader(in)
+	r.Read() // Skip header
+	d := Data{
+		BU:      "DTRM",
+		Updated: time.Now().Format("2006.01.02"),
+		Owner:   "Sean Russell",
+		People:  make([][]Person, 10),
+	}
+	for i := 0; i < 10; i++ {
+		d.People[i] = make([]Person, 0)
+	}
+	for {
+		record, err := r.Read()
+		if err == io.EOF {
+			break
+		}
+		if err != nil {
+			log.Fatal(err)
+		}
+		p := Person{
+			Name:  record[NAME],
+			Title: record[TITLE],
+		}
+		idx, err := strconv.Atoi(record[BOX])
+		if err != nil {
+			continue
+		}
+		d.People[idx] = append(d.People[idx], p)
+	}
+	fm := template.FuncMap{
+		"offset": offset,
+	}
+	t, err := ioutil.ReadFile("9box.svg.templ")
+	if err != nil {
+		log.Fatal(err)
+	}
+	svg, err := template.New("templs").Funcs(fm).Parse(string(t))
+	if err != nil {
+		log.Fatal(err)
+	}
+	err = svg.Execute(os.Stdout, d)
+	if err != nil {
+		log.Fatal(err)
+	}
+}
+
+func offset(pos float64, idx int) float64 {
+	return pos + float64(idx*22)
+}

          
A => cmd/9box/9box.svg.templ +71 -0
@@ 0,0 1,71 @@ 
+<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
+  <rect x="47.476" y="49.101" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="195.971" y="49.101" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="344.466" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;" y="49.101"/>
+  <rect x="47.476" y="168.551" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="195.971" y="168.551" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="344.466" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;" y="168.551"/>
+  <rect x="47.476" y="287.946" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="195.971" y="287.946" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;"/>
+  <rect x="344.466" width="148.495" height="119.49" style="fill: none; stroke: rgb(0, 0, 0); stroke-width: 2;" y="287.946"/>
+  <text x="48.473" y="49.52" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[3] Possible Talent</text>
+  <text x="214.012" y="49.524" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[2] Rising Talent</text>
+  <text x="380.638" y="49.517" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[1] Top Talent</text>
+  <text x="51.881" y="177.946" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[6] Must Improve</text>
+  <text x="201.381" y="177.946" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[5] Valued Contributor</text>
+  <text x="372.482" y="177.946" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[4] High Potential</text>
+  <text x="42.623" y="305.496" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[9] Resolve or Depart</text>
+  <text x="218.395" y="239.152" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.935319, 37.362461, 74.582138)">[8] Professional</text>
+  <text x="369.919" y="305.496" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;" transform="matrix(0.923516, 0, 0, 0.93532, 40.571793, 12.529038)">[7] High Performer</text>
+  <rect x="41.511" y="1.985" width="69.382" height="17.07" style="fill: rgba(169, 192, 219, 0.42);"/>
+  <rect x="187.675" y="2.029" width="60.021" height="17.07" style="fill: rgba(169, 192, 219, 0.42);"/>
+  <rect x="41.3" y="2.101" width="146.475" height="17.07" style="fill: none; stroke: rgb(0, 0, 0);"/>
+  <text x="46.463" y="13.912" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;">Business Unit: </text>
+  <text x="112.656" y="13.893" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; white-space: pre;">{{.BU}}</text>
+  <text x="191.507" y="13.893" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;">Last Update:</text>
+  <text x="248.731" y="13.898" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; white-space: pre;">{{.Updated}}</text>
+  <rect x="332.811" y="1.884" width="60.021" height="17.07" style="fill: rgba(169, 192, 219, 0.42);"/>
+  <text x="337.595" y="13.901" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; font-weight: bold; white-space: pre;">Doc. Owner:</text>
+  <text x="393.515" y="13.894" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 9px; white-space: pre;">{{.Owner}}</text>
+  <rect x="187.529" y="2.101" width="145.374" height="17.07" style="fill: none; stroke: rgb(0, 0, 0);"/>
+  <rect x="333.15" y="2.101" width="158.59" height="17.07" style="fill: none; stroke: rgb(0, 0, 0);"/>
+  <text x="80.829" y="44.648" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 6px; font-style: italic; white-space: pre;">Av. Performance Rating &lt; 80%</text>
+  <text x="377.812" y="44.646" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 6px; font-style: italic; white-space: pre;">Av. Performance Rating &gt; 90%</text>
+  <text x="223.24" y="44.655" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 6px; font-style: italic; white-space: pre;">Av. Performance Rating 80% - 90%</text>
+  <!-- {{range $idx, $p := index .People 3 }} -->
+  <text text-anchor="middle" x="120" y="{{offset 71.035 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="120" y="{{offset 79.295 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;">{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 2 }} -->
+  <text text-anchor="middle" x="270" y="{{offset 71.041 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="270" y="{{offset 79.285 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;">{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 1 }} -->
+  <text text-anchor="middle" x="422" y="{{offset 71.041 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="422" y="{{offset 79.285 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;">{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 6 }} -->
+  <text text-anchor="middle" x="126" y="{{offset 192.4 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="126" y="{{offset 200.6 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 5 }} -->
+  <text text-anchor="middle" x="274" y="{{offset 192.4 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="274" y="{{offset 200.6 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 4 }} -->
+  <text text-anchor="middle" x="422" y="{{offset 192.4 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="422" y="{{offset 200.6 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 9 }} -->
+  <text text-anchor="middle" x="127" y="{{offset 311.497 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="127" y="{{offset 319.697 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 8 }} -->
+  <text text-anchor="middle" x="274" y="{{offset 311.494 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="274" y="{{offset 319.697 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+  <!-- {{range $idx, $p := index .People 7 }} -->
+  <text text-anchor="middle" x="423" y="{{offset 311.494 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-weight: bold; white-space: pre;">{{$p.Name}}</text>
+  <text text-anchor="middle" x="423" y="{{offset 319.697 $idx}}" style="fill: rgb(51, 51, 51); font-family: sans-serif; font-size: 7px; font-style: italic; white-space: pre;" >{{$p.Title}}</text>
+  <!-- {{end}} -->
+</svg>