Merge branch 'master' of github.com:wcharczuk/go-chart
This commit is contained in:
commit
9a9af15fd4
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/wcharczuk/go-chart"
|
||||
|
@ -38,5 +39,5 @@ func drawChartWide(res http.ResponseWriter, req *http.Request) {
|
|||
func main() {
|
||||
http.HandleFunc("/", drawChart)
|
||||
http.HandleFunc("/wide", drawChartWide)
|
||||
http.ListenAndServe(":8080", nil)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestAnnotationSeriesMeasure(t *testing.T) {
|
|||
assert.False(box.IsZero())
|
||||
assert.Equal(-5.0, box.Top)
|
||||
assert.Equal(5.0, box.Left)
|
||||
assert.Equal(147.0, box.Right) //the top,left annotation sticks up 5px and out ~44px.
|
||||
assert.Equal(146.0, box.Right) //the top,left annotation sticks up 5px and out ~44px.
|
||||
assert.Equal(115.0, box.Bottom)
|
||||
}
|
||||
|
||||
|
|
8
chart.go
8
chart.go
|
@ -97,6 +97,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
|
|||
|
||||
err = c.checkRanges(xr, yr, yra)
|
||||
if err != nil {
|
||||
// (try to) dump the raw background to the stream.
|
||||
r.Save(w)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -461,7 +463,7 @@ func (c Chart) styleDefaultsBackground() Style {
|
|||
return Style{
|
||||
FillColor: DefaultBackgroundColor,
|
||||
StrokeColor: DefaultBackgroundStrokeColor,
|
||||
StrokeWidth: DefaultStrokeWidth,
|
||||
StrokeWidth: DefaultBackgroundStrokeWidth,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,7 +471,7 @@ func (c Chart) styleDefaultsCanvas() Style {
|
|||
return Style{
|
||||
FillColor: DefaultCanvasColor,
|
||||
StrokeColor: DefaultCanvasStrokeColor,
|
||||
StrokeWidth: DefaultStrokeWidth,
|
||||
StrokeWidth: DefaultCanvasStrokeWidth,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,7 +479,7 @@ func (c Chart) styleDefaultsSeries(seriesIndex int) Style {
|
|||
strokeColor := GetDefaultColor(seriesIndex)
|
||||
return Style{
|
||||
StrokeColor: strokeColor,
|
||||
StrokeWidth: DefaultStrokeWidth,
|
||||
StrokeWidth: DefaultSeriesLineWidth,
|
||||
Font: c.GetFont(),
|
||||
FontSize: DefaultFontSize,
|
||||
}
|
||||
|
|
19
defaults.go
19
defaults.go
|
@ -12,8 +12,10 @@ const (
|
|||
DefaultChartHeight = 400
|
||||
// DefaultChartWidth is the default chart width.
|
||||
DefaultChartWidth = 1024
|
||||
// DefaultStrokeWidth is the default chart line/stroke width.
|
||||
DefaultStrokeWidth = 1.0
|
||||
// DefaultStrokeWidth is the default chart stroke width.
|
||||
DefaultStrokeWidth = 0.0
|
||||
// DefaultSeriesLineWidth is the default line width.
|
||||
DefaultSeriesLineWidth = 1.0
|
||||
// DefaultAxisLineWidth is the line width of the axis lines.
|
||||
DefaultAxisLineWidth = 1.0
|
||||
//DefaultDPI is the default dots per inch for the chart.
|
||||
|
@ -33,6 +35,11 @@ const (
|
|||
// DefaultTitleTop is the default distance from the top of the chart to put the title.
|
||||
DefaultTitleTop = 10
|
||||
|
||||
// DefaultBackgroundStrokeWidth is the default stroke on the chart background.
|
||||
DefaultBackgroundStrokeWidth = 0.0
|
||||
// DefaultCanvasStrokeWidth is the default stroke on the chart canvas.
|
||||
DefaultCanvasStrokeWidth = 0.0
|
||||
|
||||
// DefaultLineSpacing is the default vertical distance between lines of text.
|
||||
DefaultLineSpacing = 5
|
||||
|
||||
|
@ -103,6 +110,9 @@ var (
|
|||
ColorAlternateYellow = drawing.Color{R: 240, G: 174, B: 90, A: 255}
|
||||
// ColorAlternateLightGray is a alternate theme color.
|
||||
ColorAlternateLightGray = drawing.Color{R: 187, G: 190, B: 191, A: 255}
|
||||
|
||||
// ColorTransparent is a transparent (alpha zero) color.
|
||||
ColorTransparent = drawing.Color{R: 1, G: 1, B: 1, A: 0}
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -171,6 +181,11 @@ var (
|
|||
DashArrayDashesLarge = []int{10, 10}
|
||||
)
|
||||
|
||||
// NewColor returns a new color.
|
||||
func NewColor(r, g, b, a uint8) drawing.Color {
|
||||
return drawing.Color{R: r, G: g, B: b, A: a}
|
||||
}
|
||||
|
||||
// GetDefaultColor returns a color from the default list by index.
|
||||
// NOTE: the index will wrap around (using a modulo).
|
||||
func GetDefaultColor(index int) drawing.Color {
|
||||
|
|
|
@ -4,8 +4,6 @@ import (
|
|||
"bufio"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
exception "github.com/blendlabs/go-exception"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -26,7 +24,7 @@ func (fu fileUtil) ReadByLines(filePath string, handler func(line string)) error
|
|||
handler(line)
|
||||
}
|
||||
} else {
|
||||
return exception.Wrap(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -46,7 +44,7 @@ func (fu fileUtil) ReadByChunks(filePath string, chunkSize int, handler func(lin
|
|||
handler(readData)
|
||||
}
|
||||
} else {
|
||||
return exception.Wrap(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user