This commit is contained in:
Will Charczuk 2019-02-13 16:09:26 -08:00
parent 3cb33d48d3
commit 26eaa1d898
76 changed files with 1076 additions and 1717 deletions

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -6,7 +6,7 @@ import (
"net/http"
"os"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -6,7 +6,7 @@ import (
"net/http"
"os"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/drawing"
)
@ -43,15 +43,15 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
Show: true,
},
Ticks: []chart.Tick{
{-4.0, "-4"},
{-2.0, "-2"},
{0, "0"},
{2.0, "2"},
{4.0, "4"},
{6.0, "6"},
{8.0, "8"},
{10.0, "10"},
{12.0, "12"},
{Value: -4.0, Label: "-4"},
{Value: -2.0, Label: "-2"},
{Value: 0, Label: "0"},
{Value: 2.0, Label: "2"},
{Value: 4.0, Label: "4"},
{Value: 6.0, Label: "6"},
{Value: 8.0, Label: "8"},
{Value: 10.0, Label: "10"},
{Value: 12.0, Label: "12"},
},
},
UseBaseValue: true,

View file

@ -4,7 +4,7 @@ import (
"log"
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func random(min, max float64) float64 {

View file

@ -2,9 +2,10 @@ package main
import (
"fmt"
"github.com/wcharczuk/go-chart"
"log"
"net/http"
chart "github.com/wcharczuk/go-chart"
)
// Note: Additional examples on how to add Stylesheets are in the custom_stylesheets example

View file

@ -4,7 +4,7 @@ import (
"fmt"
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/drawing"
"github.com/wcharczuk/go-chart/seq"
)

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/drawing"
)

View file

@ -2,9 +2,10 @@ package main
import (
"fmt"
"github.com/hashworks/go-chart"
"log"
"net/http"
chart "github.com/wcharczuk/go-chart"
)
const style = "svg .background { fill: white; }" +
@ -45,9 +46,9 @@ func svgWithCustomInlineCSSNonce(res http.ResponseWriter, _ *http.Request) {
func svgWithCustomExternalCSS(res http.ResponseWriter, _ *http.Request) {
// Add external CSS
res.Write([]byte(
`<?xml version="1.0" standalone="no"?>`+
`<?xml-stylesheet href="/main.css" type="text/css"?>`+
`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`))
`<?xml version="1.0" standalone="no"?>` +
`<?xml-stylesheet href="/main.css" type="text/css"?>` +
`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`))
res.Header().Set("Content-Type", chart.ContentTypeSVG)
err := pieChart().Render(chart.SVG, res)

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {
@ -20,12 +20,12 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
Max: 4.0,
},
Ticks: []chart.Tick{
{0.0, "0.00"},
{2.0, "2.00"},
{4.0, "4.00"},
{6.0, "6.00"},
{8.0, "Eight"},
{10.0, "Ten"},
{Value: 0.0, Label: "0.00"},
{Value: 2.0, Label: "2.00"},
{Value: 4.0, Label: "4.00"},
{Value: 6.0, Label: "6.00"},
{Value: 8.0, Label: "Eight"},
{Value: 10.0, Label: "Ten"},
},
},
Series: []chart.Series{

View file

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/seq"
)

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/seq"
)

View file

@ -5,7 +5,7 @@ import (
"log"
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {

View file

@ -3,7 +3,7 @@ package main
import (
"net/http"
"github.com/wcharczuk/go-chart"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/seq"
)

View file

@ -7,8 +7,7 @@ import (
"strings"
"time"
"github.com/wcharczuk/go-chart"
util "github.com/wcharczuk/go-chart/util"
chart "github.com/wcharczuk/go-chart"
)
func parseInt(str string) int {
@ -24,7 +23,7 @@ func parseFloat64(str string) float64 {
func readData() ([]time.Time, []float64) {
var xvalues []time.Time
var yvalues []float64
err := util.File.ReadByLines("requests.csv", func(line string) error {
err := chart.ReadLines("requests.csv", func(line string) error {
parts := strings.Split(line, ",")
year := parseInt(parts[0])
month := parseInt(parts[1])
@ -43,12 +42,12 @@ func readData() ([]time.Time, []float64) {
func releases() []chart.GridLine {
return []chart.GridLine{
{Value: util.Time.ToFloat64(time.Date(2016, 8, 1, 9, 30, 0, 0, time.UTC))},
{Value: util.Time.ToFloat64(time.Date(2016, 8, 2, 9, 30, 0, 0, time.UTC))},
{Value: util.Time.ToFloat64(time.Date(2016, 8, 2, 15, 30, 0, 0, time.UTC))},
{Value: util.Time.ToFloat64(time.Date(2016, 8, 4, 9, 30, 0, 0, time.UTC))},
{Value: util.Time.ToFloat64(time.Date(2016, 8, 5, 9, 30, 0, 0, time.UTC))},
{Value: util.Time.ToFloat64(time.Date(2016, 8, 6, 9, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 1, 9, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 2, 9, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 2, 15, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 4, 9, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 5, 9, 30, 0, 0, time.UTC))},
{Value: chart.TimeToFloat64(time.Date(2016, 8, 6, 9, 30, 0, 0, time.UTC))},
}
}

View file

@ -6,8 +6,6 @@ import (
"sync"
"time"
"github.com/wcharczuk/go-chart/util"
chart "github.com/wcharczuk/go-chart"
)
@ -18,7 +16,7 @@ var ts *chart.TimeSeries
func addData(t time.Time, e time.Duration) {
lock.Lock()
ts.XValues = append(ts.XValues, t)
ts.YValues = append(ts.YValues, util.Time.Millis(e))
ts.YValues = append(ts.YValues, chart.TimeMillis(e))
lock.Unlock()
}