-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_histogram.go
111 lines (87 loc) · 2.26 KB
/
plot_histogram.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package gig
import (
"github.com/leonsal/gig/imgui"
)
type PlotHistogram struct {
Widget
labelId imgui.CString
values interface{}
count int
bins int
cumulative bool
density bool
prange imgui.PlotRange
outliers bool
barScale float64
renderIndex int
}
func NewPlotHistogram(label string) *PlotHistogram {
p := new(PlotHistogram)
p.Init(p)
p.labelId.SetString(label)
p.bins = imgui.PlotBin_Sturges
p.cumulative = false
p.density = false
p.outliers = true
p.barScale = 1.0
p.SetRender(func() {
switch p.renderIndex {
case indexPlotI32:
imgui.PlotHistogramInt32CS(p.labelId, p.values.(*int32), p.count, p.bins, p.cumulative, p.density, p.prange, p.outliers, p.barScale)
case indexPlotF32:
imgui.PlotHistogramFloat32CS(p.labelId, p.values.(*float32), p.count, p.bins, p.cumulative, p.density, p.prange, p.outliers, p.barScale)
case indexPlotF64:
imgui.PlotHistogramFloat64CS(p.labelId, p.values.(*float64), p.count, p.bins, p.cumulative, p.density, p.prange, p.outliers, p.barScale)
}
})
return p
}
func (p *PlotHistogram) Save(pp **PlotHistogram) *PlotHistogram {
*pp = p
return p
}
func (p *PlotHistogram) SetLabel(label string) *PlotHistogram {
p.labelId.SetString(label)
return p
}
func (p *PlotHistogram) SetValuesInt32(v *int32, count, bins int) *PlotHistogram {
p.values = v
p.count = count
p.bins = bins
p.renderIndex = indexPlotI32
return p
}
func (p *PlotHistogram) SetValuesFloat32(v *float32, count, bins int) *PlotHistogram {
p.values = v
p.count = count
p.bins = bins
p.renderIndex = indexPlotF32
return p
}
func (p *PlotHistogram) SetValuesFloat64(v *float32, count, bins int) *PlotHistogram {
p.values = v
p.count = count
p.bins = bins
p.renderIndex = indexPlotF64
return p
}
func (p *PlotHistogram) SetCumulative(c bool) *PlotHistogram {
p.cumulative = c
return p
}
func (p *PlotHistogram) SetDensity(density bool) *PlotHistogram {
p.density = density
return p
}
func (p *PlotHistogram) SetOutliers(outliers bool) *PlotHistogram {
p.outliers = outliers
return p
}
func (p *PlotHistogram) SetRange(prange imgui.PlotRange) *PlotHistogram {
p.prange = prange
return p
}
func (p *PlotHistogram) SetBarScale(barScale float64) *PlotHistogram {
p.barScale = barScale
return p
}