googlechart

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

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

Go to latest
Published: Nov 13, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

README

go-google-chart

Go utility for converting JSON data type to Google Chart structure so that DataTable can understand.

This utility export the types needed for creating Data Parameters needed to draw the chart

Examples

  1. Import Chart

    import (
        GoogleChart "github.com/prabdeb/go-google-chart"
    )
    
  2. Initiate the chart object with Columns

    zooData := GoogleChart.Chart{
        Cols: []GoogleChart.ColsType{
            GoogleChart.ColsType{
                Label: "Animals",
                Type:  "string",
            },
            GoogleChart.ColsType{
                Label: "Count",
                Type:  "number",
            },
        },
    }
    
  3. Insert into Rows

    for animal, count := range zooDatabase["zoo_name"].(map[string]interface{}) {
        zooData.Rows = append(zooData.Rows, GoogleChart.RowType{
            C: []GoogleChart.RowCType{
                GoogleChart.RowCType{
                    V: animal,
                },
                GoogleChart.RowCType{
                    V: count,
                },
            },
        })
    }
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart

type Chart struct {
	Cols []ColsType `json:"cols"`
	Rows []RowType  `json:"rows"`
}

Chart is Google Chart standard type

type ColsType

type ColsType struct {
	ID      string `json:"id"`
	Label   string `json:"label"`
	Pattern string `json:"pattern"`
	Type    string `json:"type"`
}

ColsType is Google Chart standard Cols type

type RowCType

type RowCType struct {
	V interface{} `json:"v"`
	F interface{} `json:"f"`
}

RowCType is Google Chart standard Rows.C type

type RowType

type RowType struct {
	C []RowCType `json:"c"`
}

RowType is Google Chart standard Rows type

Jump to

Keyboard shortcuts

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