d3bullet

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 5 Imported by: 0

README

D3 Bullet Chart

This Go library is based on work by Mike Bostock and inspired by work by Stephen Few.

Here is a screenshot from the green red example:

Usage

See the examples.

Here is a quick synopsis:

	timeNow := time.Now().UTC()

	bulletBuilderYTD := d3bullet.D3BulletChartBuilder{
		Title:    "Progress YTD",
		YTarget:  int64(50),
		YCurrent: int64(200),
		XStart:   tu.YearStart(timeNow).Unix(),
		XCurrent: timeNow.Unix(),
		XEnd:     tu.YearEnd(timeNow).Unix(),
	}

Documentation

Index

Constants

View Source
const (
	JSPath = "github.com/grokify/gocharts/charts/d3/d3bullet/d3bullet.js"
)

Variables

This section is empty.

Functions

func GetExampleCSS

func GetExampleCSS(includeHTML bool) string

func GetExampleCSSGreenRed

func GetExampleCSSGreenRed(includeHTML bool) string

func GetExampleJS

func GetExampleJS() string

func GetExampleJSData

func GetExampleJSData() string

func GetExampleJSVars

func GetExampleJSVars() string

func GetJS

func GetJS() []byte

Types

type Bullet

type Bullet struct {
	Title    string `json:"title,omitempty"`
	Subtitle string `json:"subtitle,omitempty"`
	Ranges   []int  `json:"ranges,omitempty"`
	Measures []int  `json:"measures,omitempty"`
	Markers  []int  `json:"markers,omitempty"`
}

func ProjectionToBullet

func ProjectionToBullet(prjData bullet.ProjectionDataInt, title string, subtitle string) Bullet

type BulletInt64

type BulletInt64 struct {
	Title    string  `json:"title,omitempty"`
	Subtitle string  `json:"subtitle,omitempty"`
	Ranges   []int64 `json:"ranges,omitempty"`
	Measures []int64 `json:"measures,omitempty"`
	Markers  []int64 `json:"markers,omitempty"`
}

func BulletChartToD3Bullet

func BulletChartToD3Bullet(bullet bullet.BulletChart) BulletInt64

func ProjectionToBulletInt64

func ProjectionToBulletInt64(prjData bullet.ProjectionDataInt64, title string, subtitle string) BulletInt64

type D3BulletChartBuilder

type D3BulletChartBuilder struct {
	Title    string
	YStart   int64 // Default to 0
	YTarget  int64 // Mandatory
	YCurrent int64 // Mandatory
	XStart   int64 // Mandatory, e.g. time
	XCurrent int64 // Mandatory, e.g. time
	XEnd     int64 // Mandatory, e.g. time
}

D3BulletChartBuilder is used to create a default D3Bullet chart based on minimal data. Instantiate D3BulletChartBuilder and then call D3Bullet(). Then add to DataInt64 and then call GetBulletDataJSON.

func (*D3BulletChartBuilder) Bullet

func (d3builder *D3BulletChartBuilder) Bullet() bullet.BulletChart

func (*D3BulletChartBuilder) D3Bullet

func (d3builder *D3BulletChartBuilder) D3Bullet() BulletInt64

type Data

type Data struct {
	Bullets []Bullet
}

func (*Data) GetBulletDataJSON

func (data *Data) GetBulletDataJSON() []byte

type DataInt64

type DataInt64 struct {
	Bullets []BulletInt64
}

func (*DataInt64) GetBulletDataJSON

func (data *DataInt64) GetBulletDataJSON() []byte

GetBulletDataJSON returns JSON structure for using in JavaScript.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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