瀏覽代碼

Added Init() method in gui.Chart

leonsal 8 年之前
父節點
當前提交
93fc004410
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      gui/chart.go

+ 8 - 1
gui/chart.go

@@ -58,6 +58,14 @@ const (
 func NewChart(width, height float32) *Chart {
 
 	ch := new(Chart)
+	ch.Init(width, height)
+	return ch
+}
+
+// Init initializes a new chart with the specified width and height
+// It is normally used to initialize a Chart embedded in a struct
+func (ch *Chart) Init(width float32, height float32) {
+
 	ch.Panel.Initialize(width, height)
 	ch.left = 40
 	ch.bottom = 20
@@ -73,7 +81,6 @@ func NewChart(width, height float32) *Chart {
 	ch.fontSizeX = 14
 	ch.fontSizeY = 14
 	ch.Subscribe(OnResize, ch.onResize)
-	return ch
 }
 
 // SetTitle sets the chart title text and font size.