unification of sample and test coding styles will improve visibility (#67)
* "Style{Show: true}" to "StyleShow()" * "Box{IsSet: true}" to "BoxZero"
This commit is contained in:
parent
0fb4aa53e9
commit
865ff54ab9
|
@ -15,14 +15,10 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true, //enables / displays the x-axis
|
||||
},
|
||||
Style: chart.StyleShow(), //enables / displays the x-axis
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true, //enables / displays the y-axis
|
||||
},
|
||||
Style: chart.StyleShow(), //enables / displays the y-axis
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.ContinuousSeries{
|
||||
|
|
|
@ -20,13 +20,9 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
},
|
||||
Height: 512,
|
||||
BarWidth: 60,
|
||||
XAxis: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
XAxis: chart.StyleShow(),
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Bars: []chart.Value{
|
||||
{Value: 5.25, Label: "Blue"},
|
||||
|
|
|
@ -16,9 +16,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
ValueFormatter: func(v interface{}) string {
|
||||
if vf, isFloat := v.(float64); isFloat {
|
||||
return fmt.Sprintf("%0.6f", vf)
|
||||
|
|
|
@ -20,14 +20,10 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
FillColor: drawing.ColorFromHex("efefef"),
|
||||
},
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.ContinuousSeries{
|
||||
|
@ -47,14 +43,10 @@ func drawChartDefault(res http.ResponseWriter, req *http.Request) {
|
|||
FillColor: drawing.ColorFromHex("efefef"),
|
||||
},
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.ContinuousSeries{
|
||||
|
|
|
@ -14,9 +14,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
Range: &chart.ContinuousRange{
|
||||
Min: 0.0,
|
||||
Max: 10.0,
|
||||
|
|
|
@ -14,9 +14,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
Range: &chart.ContinuousRange{
|
||||
Min: 0.0,
|
||||
Max: 4.0,
|
||||
|
|
|
@ -20,17 +20,13 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
Height: 500,
|
||||
Width: 500,
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
/*Range: &chart.ContinuousRange{
|
||||
Descending: true,
|
||||
},*/
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
Range: &chart.ContinuousRange{
|
||||
Descending: true,
|
||||
},
|
||||
|
|
|
@ -16,10 +16,10 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
|
|
|
@ -16,10 +16,10 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
|
|
|
@ -105,9 +105,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
},
|
||||
},
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
ValueFormatter: chart.TimeHourValueFormatter,
|
||||
GridMajorStyle: chart.Style{
|
||||
Show: true,
|
||||
|
|
|
@ -44,10 +44,10 @@ func unit(res http.ResponseWriter, req *http.Request) {
|
|||
Height: 50,
|
||||
Width: 50,
|
||||
Canvas: chart.Style{
|
||||
Padding: chart.Box{IsSet: true},
|
||||
Padding: chart.BoxZero,
|
||||
},
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{IsSet: true},
|
||||
Padding: chart.BoxZero,
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.ContinuousSeries{
|
||||
|
|
|
@ -18,12 +18,8 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
},
|
||||
},
|
||||
Height: 512,
|
||||
XAxis: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
YAxis: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
XAxis: chart.StyleShow(),
|
||||
YAxis: chart.StyleShow(),
|
||||
Bars: []chart.StackedBar{
|
||||
{
|
||||
Name: "This is a very long string to test word break wrapping.",
|
||||
|
|
|
@ -43,11 +43,11 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
TickPosition: chart.TickPositionBetweenTicks,
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{Show: true},
|
||||
Style: chart.StyleShow(),
|
||||
Range: &chart.ContinuousRange{
|
||||
Max: 220.0,
|
||||
Min: 180.0,
|
||||
|
|
|
@ -14,9 +14,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
*/
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.TimeSeries{
|
||||
|
@ -48,9 +46,7 @@ func drawCustomChart(res http.ResponseWriter, req *http.Request) {
|
|||
*/
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: chart.StyleShow(),
|
||||
ValueFormatter: chart.TimeHourValueFormatter,
|
||||
},
|
||||
Series: []chart.Series{
|
||||
|
|
|
@ -18,9 +18,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
graph := chart.Chart{
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: true, //enables / displays the x-axis
|
||||
},
|
||||
Style: chart.StyleShow(), //enables / displays the x-axis
|
||||
TickPosition: chart.TickPositionBetweenTicks,
|
||||
ValueFormatter: func(v interface{}) string {
|
||||
typed := v.(float64)
|
||||
|
@ -29,14 +27,10 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
|||
},
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true, //enables / displays the y-axis
|
||||
},
|
||||
Style: chart.StyleShow(), //enables / displays the y-axis
|
||||
},
|
||||
YAxisSecondary: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: true, //enables / displays the secondary y-axis
|
||||
},
|
||||
Style: chart.StyleShow(), //enables / displays the secondary y-axis
|
||||
},
|
||||
Series: []chart.Series{
|
||||
chart.ContinuousSeries{
|
||||
|
|
|
@ -14,10 +14,8 @@ func main() {
|
|||
b = 1000
|
||||
|
||||
ts1 := chart.ContinuousSeries{ //TimeSeries{
|
||||
Name: "Time Series",
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Name: "Time Series",
|
||||
Style: chart.StyleShow(),
|
||||
XValues: []float64{10 * b, 20 * b, 30 * b, 40 * b, 50 * b, 60 * b, 70 * b, 80 * b},
|
||||
YValues: []float64{1.0, 2.0, 30.0, 4.0, 50.0, 6.0, 7.0, 88.0},
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/blend/go-sdk/assert"
|
||||
|
||||
"github.com/wcharczuk/go-chart/drawing"
|
||||
)
|
||||
|
||||
|
@ -12,9 +13,7 @@ func TestAnnotationSeriesMeasure(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
as := AnnotationSeries{
|
||||
Style: Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: StyleShow(),
|
||||
Annotations: []Value2{
|
||||
{XValue: 1.0, YValue: 1.0, Label: "1.0"},
|
||||
{XValue: 2.0, YValue: 2.0, Label: "2.0"},
|
||||
|
|
|
@ -8,7 +8,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
|
||||
"github.com/blend/go-sdk/assert"
|
||||
|
||||
"github.com/wcharczuk/go-chart/drawing"
|
||||
"github.com/wcharczuk/go-chart/seq"
|
||||
)
|
||||
|
@ -278,27 +280,21 @@ func TestChartHasAxes(t *testing.T) {
|
|||
|
||||
x := Chart{
|
||||
XAxis: XAxis{
|
||||
Style: Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: StyleShow(),
|
||||
},
|
||||
}
|
||||
assert.True(x.hasAxes())
|
||||
|
||||
y := Chart{
|
||||
YAxis: YAxis{
|
||||
Style: Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: StyleShow(),
|
||||
},
|
||||
}
|
||||
assert.True(y.hasAxes())
|
||||
|
||||
ya := Chart{
|
||||
YAxisSecondary: YAxis{
|
||||
Style: Style{
|
||||
Show: true,
|
||||
},
|
||||
Style: StyleShow(),
|
||||
},
|
||||
}
|
||||
assert.True(ya.hasAxes())
|
||||
|
@ -312,15 +308,15 @@ func TestChartGetAxesTicks(t *testing.T) {
|
|||
|
||||
c := Chart{
|
||||
XAxis: XAxis{
|
||||
Style: Style{Show: true},
|
||||
Style: StyleShow(),
|
||||
Range: &ContinuousRange{Min: 9.8, Max: 19.8},
|
||||
},
|
||||
YAxis: YAxis{
|
||||
Style: Style{Show: true},
|
||||
Style: StyleShow(),
|
||||
Range: &ContinuousRange{Min: 9.9, Max: 19.9},
|
||||
},
|
||||
YAxisSecondary: YAxis{
|
||||
Style: Style{Show: true},
|
||||
Style: StyleShow(),
|
||||
Range: &ContinuousRange{Min: 9.7, Max: 19.7},
|
||||
},
|
||||
}
|
||||
|
@ -482,10 +478,10 @@ func TestChartE2ELine(t *testing.T) {
|
|||
Height: 50,
|
||||
Width: 50,
|
||||
Canvas: Style{
|
||||
Padding: Box{IsSet: true},
|
||||
Padding: BoxZero,
|
||||
},
|
||||
Background: Style{
|
||||
Padding: Box{IsSet: true},
|
||||
Padding: BoxZero,
|
||||
},
|
||||
Series: []Series{
|
||||
ContinuousSeries{
|
||||
|
@ -522,10 +518,10 @@ func TestChartE2ELineWithFill(t *testing.T) {
|
|||
Height: 50,
|
||||
Width: 50,
|
||||
Canvas: Style{
|
||||
Padding: Box{IsSet: true},
|
||||
Padding: BoxZero,
|
||||
},
|
||||
Background: Style{
|
||||
Padding: Box{IsSet: true},
|
||||
Padding: BoxZero,
|
||||
},
|
||||
Series: []Series{
|
||||
ContinuousSeries{
|
||||
|
|
Loading…
Reference in New Issue
Block a user