fynesimplechart

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 8 Imported by: 0

README

fyne-simple-chart

A simple chart implementation that an be used in fyne applications.

Warning

As of now, negative values are not yet implemented. Can be used in plotting to the first quadrant of the cartessian plane.

Features

  • Scatter Plot
  • Bar Chart
  • Pie Chart
  • Column Chart

Installation

go get github.com/alexiusacademia/fynesimplechart

Usage

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"github.com/alexiusacademia/fynesimplechart"
)

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	nodes := []fynesimplechart.Node{
		*fynesimplechart.NewNode(1, 1),
		*fynesimplechart.NewNode(1, 3),
		*fynesimplechart.NewNode(4, 0),
		*fynesimplechart.NewNode(5, 2),
	}

	plot := fynesimplechart.NewPlot(nodes)
	plot.ShowLine = true

	nodes2 := []fynesimplechart.Node{
		*fynesimplechart.NewNode(1.5, 5),
		*fynesimplechart.NewNode(5, 4),
		*fynesimplechart.NewNode(8, 7),
		*fynesimplechart.NewNode(10, 2),
	}
	plot2 := fynesimplechart.NewPlot(nodes2)
	plot2.ShowLine = true

	scatter := fynesimplechart.NewGraphWidget([]fynesimplechart.Plot{*plot, *plot2})
	scatter.Resize(fyne.NewSize(400, 300))

	w.SetContent(scatter)
	w.ShowAndRun()
}


  1. First Graph

  2. Second Graph for version v0.1.1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxX

func MaxX(plots []Plot) (float32, error)

func MaxY

func MaxY(plots []Plot) (float32, error)

func MinX

func MinX(plots []Plot) (float32, error)

func MinY

func MinY(plots []Plot) (float32, error)

Types

type Node

type Node struct {
	X float32
	Y float32
}

func NewNode

func NewNode(x float32, y float32) *Node

type Plot

type Plot struct {
	Nodes      []Node
	Ticks      int
	XAxisTitle string
	YAxisTitle string
	Title      string

	ShowLine bool
}

func NewPlot

func NewPlot(nodes []Node, title string) *Plot

type ScatterPlot

type ScatterPlot struct {
	widget.BaseWidget

	Plots []Plot
	// contains filtered or unexported fields
}

func NewGraphWidget

func NewGraphWidget(plots []Plot) *ScatterPlot

Constructor

func (*ScatterPlot) CreateRenderer

func (v *ScatterPlot) CreateRenderer() fyne.WidgetRenderer

Generates a new renderer for the RatingCurveView.

Jump to

Keyboard shortcuts

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