gochart

package module
v0.0.0-...-5c470e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 8 Imported by: 0

README

gochart

Simple chart implementation using fyne and gg libraries

Dependencies
Functionality

Currently only BarChart and LineChart are provided. More types can be created by embedding BaseChart and implementing the required methods:

  • Required by Chart interface
      // A "contructor" like NewAwesomeChart should be created as well
      BeginDraw(dc *gg.Context, x, y float64)
      DrawPoint(dc *gg.Context, x, y, yOffset float64, int, image.Rectangle)
      EndDraw(dc *gg.Context)
  • Required by Fyne (follow the guidelines at Extending Widgets) for more information:
      CreateRenderer() fyne.WidgetRenderer

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFont

func SetFont(path string, points float64) error

Types

type BarChart

type BarChart struct {
	BaseChart
}

func NewBarChart

func NewBarChart(w, h int) *BarChart

func (*BarChart) BeginDraw

func (c *BarChart) BeginDraw(dc *gg.Context, x, y float64)

func (*BarChart) CreateRenderer

func (l *BarChart) CreateRenderer() fyne.WidgetRenderer

func (*BarChart) DrawPoint

func (c *BarChart) DrawPoint(dc *gg.Context, x, y, yOffset float64, pointCount int, rect image.Rectangle)

func (*BarChart) EndDraw

func (c *BarChart) EndDraw(dc *gg.Context)

type BaseChart

type BaseChart struct {
	widget.BaseWidget
	Screen image.Image
	// contains filtered or unexported fields
}

func NewBaseChart

func NewBaseChart(w, h int) *BaseChart

func (*BaseChart) BeginDraw

func (c *BaseChart) BeginDraw(dc *gg.Context, x, y float64)

func (*BaseChart) CreateRenderer

func (l *BaseChart) CreateRenderer() fyne.WidgetRenderer

func (*BaseChart) DragEnd

func (c *BaseChart) DragEnd()

func (*BaseChart) Dragged

func (c *BaseChart) Dragged(event *fyne.DragEvent)

Events A minimum implementation is provided so the cursor is is tracked when it's over the chart area

func (*BaseChart) DrawCursor

func (c *BaseChart) DrawCursor(dc *gg.Context, ratioX float64)

func (*BaseChart) DrawFrame

func (c *BaseChart) DrawFrame(dc *gg.Context, ratioX, ratioY, yOffset, height, width, xSpan, ySpan float64)

func (*BaseChart) DrawPoint

func (c *BaseChart) DrawPoint(dc *gg.Context, x, y, yOffset float64, pointCount int, rect image.Rectangle)

func (*BaseChart) EndDraw

func (c *BaseChart) EndDraw(dc *gg.Context)

func (*BaseChart) GetData

func (c *BaseChart) GetData() ([]float64, []float64)

func (*BaseChart) GetGrowY

func (c *BaseChart) GetGrowY() bool

func (*BaseChart) GetMargin

func (c *BaseChart) GetMargin() float64

func (*BaseChart) GetMouse

func (c *BaseChart) GetMouse() (float32, float32)

func (*BaseChart) GetScreen

func (c *BaseChart) GetScreen() image.Image

func (*BaseChart) GetShowLabel

func (c *BaseChart) GetShowLabel() bool

func (*BaseChart) ResizeIfNeeded

func (c *BaseChart) ResizeIfNeeded(w, h int)

func (*BaseChart) SetData

func (c *BaseChart) SetData(x, y []float64)

func (*BaseChart) SetGrowY

func (c *BaseChart) SetGrowY(grow bool)

type Chart

type Chart interface {
	fyne.Widget
	SetGrowY(grow bool)
	SetData(x, y []float64)

	BeginDraw(dc *gg.Context, x, y float64)
	DrawPoint(dc *gg.Context, x, y, yOffset float64, pointCount int, rect image.Rectangle)
	EndDraw(dc *gg.Context)

	DrawCursor(dc *gg.Context, ratioX float64)
	DrawFrame(dc *gg.Context, ratioX, ratioY, yOffset, height, width, xSpan, ySpan float64)

	ResizeIfNeeded(w, h int)

	GetData() ([]float64, []float64)
	GetScreen() image.Image
	GetGrowY() bool
	GetMargin() float64
	GetMouse() (float32, float32)
	GetShowLabel() bool
}

type ChartRenderer

type ChartRenderer struct {
	// contains filtered or unexported fields
}

func (*ChartRenderer) Destroy

func (l *ChartRenderer) Destroy()

func (*ChartRenderer) Layout

func (l *ChartRenderer) Layout(size fyne.Size)

func (*ChartRenderer) MinSize

func (l *ChartRenderer) MinSize() fyne.Size

func (*ChartRenderer) Objects

func (l *ChartRenderer) Objects() []fyne.CanvasObject

func (*ChartRenderer) Refresh

func (l *ChartRenderer) Refresh()

type LineChart

type LineChart struct {
	BaseChart
}

func NewLineChart

func NewLineChart(w, h int) *LineChart

func (*LineChart) BeginDraw

func (c *LineChart) BeginDraw(dc *gg.Context, x, y float64)

func (*LineChart) CreateRenderer

func (l *LineChart) CreateRenderer() fyne.WidgetRenderer

func (*LineChart) DrawPoint

func (c *LineChart) DrawPoint(dc *gg.Context, x, y, yOffset float64, pointCount int, rect image.Rectangle)

func (*LineChart) EndDraw

func (c *LineChart) EndDraw(dc *gg.Context)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL