d3

package module
v0.0.0-...-c572d88 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2014 License: Apache-2.0 Imports: 2 Imported by: 2

README

d3

Thin wrapper over the data-driven documents (d3) library for use with gopherjs.

This is just enough of the d3 library to allow you to complete the Mark Bostock's excellent tutorial, but writing entirely in go.

The calls are not very regularized because they haven't been thought through with respect to statically-typed programming model.

Install

go get -u github.com/iansmith/d3

Check out the demo.

Documentation

Index

Constants

View Source
const (
	BOTTOM = iota
	TOP
	RIGHT
	LEFT
)

Variables

This section is empty.

Functions

func Max

func Max(v js.Object, fn ExtractorFunc) int64

Max is d3.max with a function that passes over each object in the array supplied as the first argument. If the second function is nil, we assume that the array contains (JS) integers.

func MaxF

func MaxF(v js.Object, fn ExtractorFuncF) float64

MaxF is d3.max with a function that passes over each object in the array supplied as the first argument. If the second function is nil, we assume that the array contains (JS) floats.

func TSV

func TSV(filename string, filter FilterFunc, callback func(js.Object, js.Object))

TSV loads a tab separated value called filename from the server. Each loaded element is passed through filter func and the final result is handed to callback.

Types

type Axis

type Axis interface {
	ScaleO(OrdinalScale) Axis
	Scale(LinearScale) Axis
	Orient(e Edge) Axis
	Ticks(int64, string) Axis
}

Axis is a VERY thin wrapper over d3.svg.axis

func NewAxis

func NewAxis() Axis

NewAxis creates a new axis object

type Edge

type Edge int

func (Edge) String

func (self Edge) String() string

type ExtractorFunc

type ExtractorFunc func(js.Object) int64

ExtractorFunc is a fun that can pull the int value from an object

type ExtractorFuncF

type ExtractorFuncF func(js.Object) float64

ExtractorFuncF is a fun that can pull the float value from an object

type ExtractorFuncO

type ExtractorFuncO func(js.Object) js.Object

ExtractorFuncO is a fun that can pull the named (usually ordinal) value from the object

type FilterFunc

type FilterFunc func(js.Object) js.Object

FilterFunc converts "raw" objects to their formatted counterparts. Raw version has only string fields, but formatted version should have the parsed values. If this func returns nil, that item is ignored.

type LinearScale

type LinearScale interface {
	Domain([]int64) LinearScale
	DomainF([]float64) LinearScale
	Range([]int64) LinearScale
	Linear(js.Object, ExtractorFunc) int64
	LinearF(js.Object, ExtractorFuncF) float64
	Invert(js.Object, ExtractorFunc) int64
	Func(ExtractorFunc) func(js.Object) int64
	FuncF(ExtractorFuncF) func(js.Object) float64
}

LinearScale is a wrapper around the d3 concept of the same name.

func ScaleLinear

func ScaleLinear() LinearScale

ScaleLinear is d3.scale.linear and returns a LinearScale

type OrdinalScale

type OrdinalScale interface {
	Domain(js.Object) OrdinalScale
	RangeBands([]int64) OrdinalScale
	RangeBand() int64
	RangeBandF() float64
	RangeBands3([]int64, float64) OrdinalScale
	Ordinal(obj js.Object, fn ExtractorFuncO) int64
}

OrdinalScale wraps d3.scale.ordinal

func ScaleOrdinal

func ScaleOrdinal() OrdinalScale

ScaleLinear is d3.scale.ordinal and returns a Ordinal

type PropertyName

type PropertyName string

PropertyName is the name of a CSS property like "width"

type Selection

Selection is the d3 concept of zero or more selected elements.

func Select

func Select(n Selector) Selection

Select is d3.select() and creates a selection from the selector.

type Selector

type Selector string

Selector is a special kind of string used for selecting elements from the dom. Roughly, it's a CSS selector.

type TagName

type TagName string

TagName is a html tag name, like "div"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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