Преглед на файлове

changed gui chart SetTitle() parameters

leonsal преди 8 години
родител
ревизия
6c816e707a
променени са 1 файла, в които са добавени 18 реда и са изтрити 13 реда
  1. 18 13
      gui/chart.go

+ 18 - 13
gui/chart.go

@@ -75,26 +75,31 @@ func NewChart(width, height float32) *Chart {
 	return ch
 }
 
-// SetTitle sets the chart title
-func (ch *Chart) SetTitle(title string) {
-
-	if ch.title != nil {
-		ch.Remove(ch.title)
-		ch.title = nil
+// SetTitle sets the chart title text and font size.
+// To remove the title pass an empty string
+func (ch *Chart) SetTitle(title string, size float64) {
+
+	// Remove title
+	if title == "" {
+		if ch.title != nil {
+			ch.Remove(ch.title)
+			ch.title.Dispose()
+			ch.title = nil
+			ch.recalc()
+		}
+		return
 	}
-	if title != "" {
+
+	// Sets title
+	if ch.title == nil {
 		ch.title = NewLabel(title)
 		ch.Add(ch.title)
 	}
+	ch.title.SetText(title)
+	ch.title.SetFontSize(size)
 	ch.recalc()
 }
 
-// Title returns the pointer to the title label or nil
-func (ch *Chart) Title() *Label {
-
-	return ch.title
-}
-
 // SetMarginY sets the y scale margin
 func (ch *Chart) SetMarginY(left float32) {