highcharts

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

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

Go to latest
Published: Feb 28, 2018 License: MIT Imports: 6 Imported by: 0

README

gohighcharts

Library to display graphics using highcharts on a local server. Supports dynamic data through channels.

Installing

Within your project run

// Download the sources
go get github.com/Narsil/gohighcharts

// Get the static files that will be used by the server
git clone https://github.com/Narsil/gohighcharts.git
cp -r gohighcharts/{tmpl,static} .
rm -rf gohighcharts

Usage

Simple Chart Example

options := map[string]interface{}{
  "series":  []interface{}{
    map[string]interface{}{
      "name": "MyData",
      "data": []int{1, 2, 3},
    },
  },
  "chart": map[string]interface{}{
    "type": "line",
  },
}                                                                          
NewChart("/chart/", options) 

Then simply visit http://localhost:8080/chart/ to see you chart.

Dynamic Chart

When using a dynamic chart

package main

import (
  highcharts "github.com/Narsil/gohighcharts"
)

func main(){
  data := make(chan interface{})                                             
  options := map[string]interface{}{
      "series":  []interface{}{
          map[string]interface{}{
              "name": "Dynamic chart",
              "data": []int{},
          },
      },
      "chart": map[string]interface{}{
          "type": "line",
      },
  }
  highcharts.NewDynamicChart("/dynamic/", options, data)
  go func(){                                                                 
      for i := 0; i < 10; i++{                                               
          data<-i                                                            
          time.Sleep(i * 1e9)                                                      
      }                                                                      
  }()
}

And visit http://localhost:8080/dyamic/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChart

func NewChart(url string, options interface{})

NewChart creates a new highchart based on options argument at url View at http://localhost:8080/url/ To change port see SetPort

func NewDynamicChart

func NewDynamicChart(url string, options interface{}, channel chan interface{})

NewDynamicChart creates a new highchart based on options argument at url Whenever you add data to your channel it will be sent to your graph via websocket. Only support one channel on one graph for now. View at http://localhost:8080/url/ To change port see SetPort

func SetPort

func SetPort(serverPort string)

SetPort sets the port for the server to see the graphs Is in the same format as ListenAndServe, ":8080"

Types

This section is empty.

Jump to

Keyboard shortcuts

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