Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI
This commit is contained in:
1822 files changed
+24568
-21314
No files matched your search
@@ -8,14 +8,15 @@ import (
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
mujica "mujicaui"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/chart"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/input"
|
||||
)
|
||||
|
||||
var c1Abbey = mujica.ChartNode{Name: "Abbey", Children: []mujica.ChartNode{
|
||||
{Name: "Library", Children: []mujica.ChartNode{{Name: "Psalters", Value: 30}, {Name: "Maps", Value: 10}, {Name: "Letters", Value: 8}}},
|
||||
var c1Abbey = chart.ChartNode{Name: "Abbey", Children: []chart.ChartNode{
|
||||
{Name: "Library", Children: []chart.ChartNode{{Name: "Psalters", Value: 30}, {Name: "Maps", Value: 10}, {Name: "Letters", Value: 8}}},
|
||||
{Name: "Kitchen", Value: 25},
|
||||
{Name: "Garden", Children: []mujica.ChartNode{{Name: "Herbs", Value: 12}, {Name: "Vines", Value: 8}}},
|
||||
{Name: "Chapel", Children: []mujica.ChartNode{{Name: "Nave", Value: 18}, {Name: "Crypt", Value: 6}}},
|
||||
{Name: "Garden", Children: []chart.ChartNode{{Name: "Herbs", Value: 12}, {Name: "Vines", Value: 8}}},
|
||||
{Name: "Chapel", Children: []chart.ChartNode{{Name: "Nave", Value: 18}, {Name: "Crypt", Value: 6}}},
|
||||
}}
|
||||
|
||||
func c1TreemapDemo(c *ui.Context, log func(string)) {
|
||||
@@ -28,10 +29,10 @@ func c1TreemapDemo(c *ui.Context, log func(string)) {
|
||||
frame, show := c1Frame(c, "Rooms", &s.status)
|
||||
root := c1Abbey
|
||||
if !show {
|
||||
root = mujica.ChartNode{Name: "Abbey"}
|
||||
root = chart.ChartNode{Name: "Abbey"}
|
||||
s.path = nil
|
||||
}
|
||||
r := mujica.Treemap(c, &s.path, root, mujica.TreemapOptions{Frame: frame})
|
||||
r := chart.Treemap(c, &s.path, root, chart.TreemapOptions{Frame: frame})
|
||||
c1Log(log, "Treemap", r)
|
||||
if r.ValueChanged() {
|
||||
log("Treemap: path /" + strings.Join(s.path, "/"))
|
||||
@@ -54,10 +55,10 @@ func c1SunburstDemo(c *ui.Context, log func(string)) {
|
||||
frame.Height = 300
|
||||
root := c1Abbey
|
||||
if !show {
|
||||
root = mujica.ChartNode{Name: "Abbey"}
|
||||
root = chart.ChartNode{Name: "Abbey"}
|
||||
s.path = nil
|
||||
}
|
||||
r := mujica.Sunburst(c, &s.path, root, mujica.SunburstOptions{Frame: frame, Depth: int(s.depth)})
|
||||
r := chart.Sunburst(c, &s.path, root, chart.SunburstOptions{Frame: frame, Depth: int(s.depth)})
|
||||
c1Log(log, "Sunburst", r)
|
||||
if r.ValueChanged() {
|
||||
log("Sunburst: path /" + strings.Join(s.path, "/"))
|
||||
@@ -70,12 +71,12 @@ func c1SankeyDemo(c *ui.Context, log func(string)) {
|
||||
s := ui.Local(c.Root(), "118", func() state { return state{status: "Ready"} })
|
||||
c1Section(c, "SankeyChart", func() {}, func() {
|
||||
frame, show := c1Frame(c, "Money", &s.status)
|
||||
nodes := []mujica.SankeyNode{{ID: "tithe", Label: "Tithes"}, {ID: "alms", Label: "Alms"}, {ID: "fund", Label: "Fund"}, {ID: "roof", Label: "Roof"}, {ID: "bread", Label: "Bread"}, {ID: "bells", Label: "Bells"}}
|
||||
links := []mujica.SankeyLink{{From: "tithe", To: "fund", Value: 60}, {From: "alms", To: "fund", Value: 30}, {From: "alms", To: "bread", Value: 10}, {From: "fund", To: "roof", Value: 50}, {From: "fund", To: "bells", Value: 40}}
|
||||
nodes := []chart.SankeyNode{{ID: "tithe", Label: "Tithes"}, {ID: "alms", Label: "Alms"}, {ID: "fund", Label: "Fund"}, {ID: "roof", Label: "Roof"}, {ID: "bread", Label: "Bread"}, {ID: "bells", Label: "Bells"}}
|
||||
links := []chart.SankeyLink{{From: "tithe", To: "fund", Value: 60}, {From: "alms", To: "fund", Value: 30}, {From: "alms", To: "bread", Value: 10}, {From: "fund", To: "roof", Value: 50}, {From: "fund", To: "bells", Value: 40}}
|
||||
if !show {
|
||||
links = nil
|
||||
}
|
||||
c1Log(log, "SankeyChart", mujica.SankeyChart(c, nodes, links, mujica.SankeyChartOptions{Frame: frame}))
|
||||
c1Log(log, "SankeyChart", chart.SankeyChart(c, nodes, links, chart.SankeyChartOptions{Frame: frame}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,23 +84,23 @@ func c1NetworkDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
status string
|
||||
force bool
|
||||
graph mujica.NetworkGraphState
|
||||
graph chart.NetworkGraphState
|
||||
}
|
||||
s := ui.Local(c.Root(), "119", func() state { return state{status: "Ready", force: true} })
|
||||
c1Section(c, "NetworkGraph", func() {
|
||||
ui.Checkbox(c, &s.force, "Force layout")
|
||||
if mujica.Button(c, "Reset view", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Reset view", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.graph.ResetView()
|
||||
log("NetworkGraph: reset view")
|
||||
}
|
||||
}, func() {
|
||||
frame, show := c1Frame(c, "House", &s.status)
|
||||
nodes := []mujica.GraphNode{{ID: "a", Label: "Abbot", X: 0, Y: 0}, {ID: "b", Label: "Prior", X: 10, Y: 0}, {ID: "c", Label: "Cellarer", X: 10, Y: 10}, {ID: "d", Label: "Novice", X: 0, Y: 10}, {ID: "e", Label: "Cantor", X: 5, Y: 5}}
|
||||
edges := []mujica.GraphEdge{{From: "a", To: "b"}, {From: "a", To: "c"}, {From: "c", To: "d"}, {From: "b", To: "e"}, {From: "e", To: "d"}}
|
||||
nodes := []chart.GraphNode{{ID: "a", Label: "Abbot", X: 0, Y: 0}, {ID: "b", Label: "Prior", X: 10, Y: 0}, {ID: "c", Label: "Cellarer", X: 10, Y: 10}, {ID: "d", Label: "Novice", X: 0, Y: 10}, {ID: "e", Label: "Cantor", X: 5, Y: 5}}
|
||||
edges := []chart.GraphEdge{{From: "a", To: "b"}, {From: "a", To: "c"}, {From: "c", To: "d"}, {From: "b", To: "e"}, {From: "e", To: "d"}}
|
||||
if !show {
|
||||
nodes, edges = nil, nil
|
||||
}
|
||||
c1Log(log, "NetworkGraph", mujica.NetworkGraph(c, &s.graph, nodes, edges, mujica.NetworkGraphOptions{Frame: frame, Force: s.force}))
|
||||
c1Log(log, "NetworkGraph", chart.NetworkGraph(c, &s.graph, nodes, edges, chart.NetworkGraphOptions{Frame: frame, Force: s.force}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -107,13 +108,13 @@ func c1RealtimeDemo(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
status string
|
||||
feed bool
|
||||
buf *mujica.RealtimeBuffer
|
||||
buf *chart.RealtimeBuffer
|
||||
next time.Time
|
||||
tick int
|
||||
view mujica.RealtimeChartState
|
||||
view chart.RealtimeChartState
|
||||
}
|
||||
s := ui.Local(c.Root(), "120", func() state {
|
||||
return state{status: "Ready", feed: true, buf: mujica.NewRealtimeBuffer(600, "Bell", "Organ")}
|
||||
return state{status: "Ready", feed: true, buf: chart.NewRealtimeBuffer(600, "Bell", "Organ")}
|
||||
})
|
||||
// The demo appends a sample every 500 ms while feeding.
|
||||
if s.feed && !c.Now().Before(s.next) {
|
||||
@@ -128,7 +129,7 @@ func c1RealtimeDemo(c *ui.Context, log func(string)) {
|
||||
}
|
||||
c1Section(c, "RealtimeChart", func() { ui.Checkbox(c, &s.feed, "Feed data") }, func() {
|
||||
frame, _ := c1Frame(c, "Sound", &s.status)
|
||||
r := mujica.RealtimeChart(c, &s.view, s.buf, mujica.RealtimeChartOptions{Frame: frame, Window: 20 * time.Second})
|
||||
r := chart.RealtimeChart(c, &s.view, s.buf, chart.RealtimeChartOptions{Frame: frame, Window: 20 * time.Second})
|
||||
c1Log(log, "RealtimeChart", r)
|
||||
if r.ValueChanged() {
|
||||
log(fmt.Sprintf("RealtimeChart: paused=%v", s.view.Paused))
|
||||
|
||||
Reference in new issue
Block a user