Git Product home page Git Product logo

gopie's Introduction

gopie

Package gopie renders pie charts to SVG.

Installation

To install gopie package run:

go get -u github.com/eugenezinovyev/gopie

Dependencies

This package depends on the following packages:

  • github.com/golang/freetype/truetype
  • golang.org/x/image/font
  • github.com/satori/go.uuid

These package are used for chart label dimensions measure. Check limitations of github.com/golang/freetype package if you plan to use label font different than the default one.

Defaults

  • Font used for label size measurement: Roboto Medium
  • Default slice colors: Material Design palette 400 (see: https://material.io/color)
  • Stroke color: white
  • Label font family: Roboto Medium
  • Label font size: 12
  • Label line length: 10px
  • Label line width: 2px
  • Label text padding: 4px
  • DPI ued for label size measurement: 92
  • Chart width: 200px
  • Chart height: 200px
  • Font: Roboto Medium
  • Embed font: false
  • Inner raduis: 0px

Usage

	chart := gopie.PieChart{
		Values: []gopie.Value{
			gopie.Value{Value: 1, Label: "One"},
			gopie.Value{Value: 2, Label: "Two"},
			gopie.Value{Value: 5, Label: "Five"},
		},
	}

	svgBytes, err := chart.SVG()

Custom slice colors

Check example in ./_examples/custom_colors

	chart := gopie.PieChart{
		...
		SliceColors:    []string{"firebrick", "sandybrown", "mediumseagreen", "deepskyblue"},
		...
	}

Embed font

Check example in ./_examples/font

	robotoRegular, err := ioutil.ReadFile("Roboto-Regular.ttf")
	check(err)
	chart.SetFont(robotoRegular)

Donut

Check example in ./_examples/donut

	chart := gopie.PieChart{
		...
		InnerRadius:    90, // Forces chart to leave empty circle with 90px radius at center
		...
	}

You can also check ./_examples folder for more examples of usage.

Licence

MIT

gopie's People

Contributors

eugenezinovyev avatar

Stargazers

Tony avatar  avatar Wade Welles avatar

Watchers

 avatar

Forkers

immannino

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.