chart

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

README

Chart package

These types allow constructing json to tweak chart options on the front'ends piechart lib

refs:

Example usage:


package foo

import (
    "github.com/doddle/lander/pkg/chart"
)


type FinalPieChart struct {
    ChartOpts chart.ChartOpts `json:"chartOptions"`
    Series    []int64   `json:"series"`
    Total     int64     `json:"total"`
}

func foo(){
    result := FinalPieChart{
        Total: someNumber,
        Series: resultSeries,
        ChartOpts: chart.ChartOpts{
            Legend: chart.Legend{Show: true},
            //Theme:  chart.Theme{Palette: "palette1"},
            //Title: chart.Title{Text: "Nodes"},
            PlotOpt: chart.PlotOpt{
                Pie: chart.PlotOptPie{
                    ExpandOnClick: false,
                    Size:          119,
                },
            },
            Colors: resultColors,
            Stroke: chart.Stroke{Width: -1},
            Chart: chart.Chart{
                ID: "pie-nodes",
                //DropShadow: chart.DropShadow{
                //	Effect: false,
                //},
            },
        Labels: resultLabels,
        },
    }
}


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart

type Chart struct {
	ID         string     `json:"id"`
	DropShadow DropShadow `json:"dropShadow"`
}

type Data

type Data struct {
	Labels   []string  `json:"labels"`
	Datasets []Dataset `json:"datasets"`
}

type Dataset

type Dataset struct {
	BorderWidth     int64    `json:"borderWidth"`
	BorderColor     []string `json:"borderColor"`
	BackgroundColor []string `json:"backgroundColor"`
	Data            []int64  `json:"data"`
}

type DropShadow

type DropShadow struct {
	Effect bool `json:"effect"`
}

type Legend

type Legend struct {
	Show bool `json:"show"`
}

type Options

type Options struct {
	Responsive          bool `json:"responsive"`
	MaintainAspectRatio bool `json:"maintainAspectRatio"`
}

type Opts

type Opts struct {
	Chart   Chart    `json:"chart"`
	Labels  []string `json:"labels"`
	PlotOpt PlotOpt  `json:"plotOptions"`
	Legend  Legend   `json:"legend"`
	Stroke  Stroke   `json:"stroke"`
	Theme   Theme    `json:"theme"`
	Title   Title    `json:"title"`
	Colors  []string `json:"colors"`
}

type PlotOpt

type PlotOpt struct {
	Pie PlotOptPie `json:"pie"`
}

type PlotOptPie

type PlotOptPie struct {
	CustomScale   float64 `json:"customScale,omitempty"`
	ExpandOnClick bool    `json:"expandOnClick"`
	Size          int64   `json:"size,omitempty"`
}

type Stroke

type Stroke struct {
	Width float64 `json:"width"`
}

type Theme

type Theme struct {
	Palette string `json:"palette"`
}

type Title

type Title struct {
	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

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