diff --git a/go.mod b/go.mod
index 6db0a69..6cc2c32 100644
--- a/go.mod
+++ b/go.mod
@@ -3,11 +3,11 @@ module github.com/lacazethomas/wakapi-stats
go 1.15
require (
- github.com/blend/go-sdk v1.20210731.3 // indirect
+ github.com/blend/go-sdk v1.20210819.9 // indirect
github.com/buger/jsonparser v1.1.1
github.com/caarlos0/env v3.5.0+incompatible
- github.com/gin-gonic/gin v1.7.3
- github.com/go-playground/validator/v10 v10.8.0 // indirect
+ github.com/gin-gonic/gin v1.7.4
+ github.com/go-playground/validator/v10 v10.9.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
@@ -17,13 +17,16 @@ require (
github.com/stretchr/testify v1.7.0
github.com/thinkerou/favicon v0.1.0
github.com/ugorji/go v1.2.6 // indirect
- github.com/wcharczuk/go-chart v2.0.1+incompatible
+ github.com/wcharczuk/go-chart v2.0.1+incompatible // indirect
+ github.com/wcharczuk/go-chart/v2 v2.1.0
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
- go.uber.org/zap v1.18.1
+ go.uber.org/zap v1.19.0
+ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
- golang.org/x/mod v0.4.2 // indirect
+ golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
+ golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.5 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
diff --git a/go.sum b/go.sum
index cb8ced4..442aa4d 100644
--- a/go.sum
+++ b/go.sum
@@ -32,7 +32,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/datadog-go v4.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
@@ -43,12 +42,16 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aws/aws-sdk-go v1.38.41/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
+github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/blend/go-sdk v1.20210731.3 h1:T5+n2iscZguC1DcEHpWdPiP84YAAM8xZu3MOgTTbD9A=
github.com/blend/go-sdk v1.20210731.3/go.mod h1:rGIavv+yoXOAXW8xszPlbXVNpwOunzR2Y/Ihr//mcb4=
+github.com/blend/go-sdk v1.20210819.9 h1:7+MHhZqB16eZpf45MeXFbOsgbONPFV9sV7+HSJ/aI6Q=
+github.com/blend/go-sdk v1.20210819.9/go.mod h1:rGIavv+yoXOAXW8xszPlbXVNpwOunzR2Y/Ihr//mcb4=
github.com/blend/sentry-go v1.0.0/go.mod h1:hgyX3WXen2YBiA0NitlfsXsvS+9ly2YlEBmmmYDgrWY=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
@@ -89,6 +92,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.7.3 h1:aMBzLJ/GMEYmv1UWs2FFTcPISLrQH2mRgL9Glz8xows=
github.com/gin-gonic/gin v1.7.3/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
+github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
+github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -96,14 +101,21 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
+github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
+github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k=
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
+github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A=
+github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -148,11 +160,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
-github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -252,10 +262,15 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
+github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
@@ -277,8 +292,6 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/mattn/goveralls v0.0.8/go.mod h1:h8b4ow6FxSPMQHF6o2ve3qsclnffZjYTNEKmLesRwqw=
-github.com/mattn/goveralls v0.0.9 h1:XmIwwrO9a9pqSW6IpI89BSCShzQxx0j/oKnnvELQNME=
github.com/mattn/goveralls v0.0.9/go.mod h1:FRbM1PS8oVsOe9JtdzAAXM+DsvDMMHcM1C7drGJD8HY=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mediocregopher/radix/v4 v4.0.0-beta.1/go.mod h1:Z74pilm773ghbGV4EEoPvi6XWgkAfr0VCNkfa8gI1PU=
@@ -304,6 +317,7 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -323,6 +337,9 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
+github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
+github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
@@ -349,6 +366,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -371,6 +389,8 @@ github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLVLBCWz1STcD3doU0A=
github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
+github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
+github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -390,6 +410,7 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
@@ -401,6 +422,8 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
+go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE=
+go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -415,6 +438,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
+golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -427,6 +452,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -439,6 +465,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
@@ -486,14 +513,12 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
-golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20201203001011-0b49973bad19/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
-golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -543,13 +568,15 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 h1:rw6UNGRMfarCepjI8qOepea/SXwIBVfTKjztZ5gBbq4=
+golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -559,6 +586,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -606,14 +635,11 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20201204162204-73cf035baebf/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
-golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
@@ -646,7 +672,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -707,6 +732,7 @@ gopkg.in/DataDog/dd-trace-go.v1 v1.27.1/go.mod h1:Sp1lku8WJMvNV0kjDI4Ni/T7J/U3BO
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
@@ -730,7 +756,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-honnef.co/go/tools v0.2.0/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/utils/chart.go b/utils/chart.go
index e7da099..39c4fd9 100644
--- a/utils/chart.go
+++ b/utils/chart.go
@@ -5,8 +5,8 @@ import (
"sort"
"github.com/pkg/errors"
- "github.com/wcharczuk/go-chart"
- "github.com/wcharczuk/go-chart/drawing"
+ "github.com/wcharczuk/go-chart/v2"
+ "github.com/wcharczuk/go-chart/v2/drawing"
"go.uber.org/zap"
"github.com/lacazethomas/wakapi-stats/models"
diff --git a/vendor/github.com/gin-gonic/gin/CHANGELOG.md b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
index 38d0966..308af74 100644
--- a/vendor/github.com/gin-gonic/gin/CHANGELOG.md
+++ b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
@@ -2,7 +2,10 @@
## Gin v1.7.3
+### BUGFIXES
+
* fix level 1 router match [#2767](https://github.com/gin-gonic/gin/issues/2767), [#2796](https://github.com/gin-gonic/gin/issues/2796)
+
## Gin v1.7.2
### BUGFIXES
diff --git a/vendor/github.com/go-playground/locales/README.md b/vendor/github.com/go-playground/locales/README.md
index ba1b068..5b0694f 100644
--- a/vendor/github.com/go-playground/locales/README.md
+++ b/vendor/github.com/go-playground/locales/README.md
@@ -1,5 +1,5 @@
## locales
-![Project status](https://img.shields.io/badge/version-0.13.0-green.svg)
+![Project status](https://img.shields.io/badge/version-0.14.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/locales.svg?branch=master)](https://travis-ci.org/go-playground/locales)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/locales)](https://goreportcard.com/report/github.com/go-playground/locales)
[![GoDoc](https://godoc.org/github.com/go-playground/locales?status.svg)](https://godoc.org/github.com/go-playground/locales)
@@ -11,7 +11,7 @@ an i18n package; these were built for use with, but not exclusive to, [Universal
Features
--------
-- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v31.0.1
+- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v36.0.1
- [x] Contains Cardinal, Ordinal and Range Plural Rules
- [x] Contains Month, Weekday and Timezone translations built in
- [x] Contains Date & Time formatting functions
diff --git a/vendor/github.com/go-playground/locales/currency/currency.go b/vendor/github.com/go-playground/locales/currency/currency.go
index cdaba59..b5a95fb 100644
--- a/vendor/github.com/go-playground/locales/currency/currency.go
+++ b/vendor/github.com/go-playground/locales/currency/currency.go
@@ -176,6 +176,7 @@ const (
MNT
MOP
MRO
+ MRU
MTL
MTP
MUR
@@ -262,9 +263,11 @@ const (
UYI
UYP
UYU
+ UYW
UZS
VEB
VEF
+ VES
VND
VNN
VUV
diff --git a/vendor/github.com/go-playground/locales/go.mod b/vendor/github.com/go-playground/locales/go.mod
index 34ab6f2..41b8dc1 100644
--- a/vendor/github.com/go-playground/locales/go.mod
+++ b/vendor/github.com/go-playground/locales/go.mod
@@ -2,4 +2,4 @@ module github.com/go-playground/locales
go 1.13
-require golang.org/x/text v0.3.2
+require golang.org/x/text v0.3.6
diff --git a/vendor/github.com/go-playground/locales/go.sum b/vendor/github.com/go-playground/locales/go.sum
index 63c9200..3c12b4f 100644
--- a/vendor/github.com/go-playground/locales/go.sum
+++ b/vendor/github.com/go-playground/locales/go.sum
@@ -1,3 +1,3 @@
-golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/vendor/github.com/go-playground/universal-translator/Makefile b/vendor/github.com/go-playground/universal-translator/Makefile
new file mode 100644
index 0000000..ec3455b
--- /dev/null
+++ b/vendor/github.com/go-playground/universal-translator/Makefile
@@ -0,0 +1,18 @@
+GOCMD=GO111MODULE=on go
+
+linters-install:
+ @golangci-lint --version >/dev/null 2>&1 || { \
+ echo "installing linting tools..."; \
+ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \
+ }
+
+lint: linters-install
+ golangci-lint run
+
+test:
+ $(GOCMD) test -cover -race ./...
+
+bench:
+ $(GOCMD) test -bench=. -benchmem ./...
+
+.PHONY: test lint linters-install
\ No newline at end of file
diff --git a/vendor/github.com/go-playground/universal-translator/README.md b/vendor/github.com/go-playground/universal-translator/README.md
index 071f33a..46dec6d 100644
--- a/vendor/github.com/go-playground/universal-translator/README.md
+++ b/vendor/github.com/go-playground/universal-translator/README.md
@@ -1,5 +1,5 @@
## universal-translator
-![Project status](https://img.shields.io/badge/version-0.17.0-green.svg)
+![Project status](https://img.shields.io/badge/version-0.18.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/universal-translator.svg?branch=master)](https://travis-ci.org/go-playground/universal-translator)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg)](https://coveralls.io/github/go-playground/universal-translator)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator)
@@ -18,7 +18,7 @@ use in your applications.
Features
--------
-- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v30.0.3
+- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v36.0.1
- [x] Contains Cardinal, Ordinal and Range Plural Rules
- [x] Contains Month, Weekday and Timezone translations built in
- [x] Contains Date & Time formatting functions
@@ -51,7 +51,7 @@ Please see https://godoc.org/github.com/go-playground/universal-translator for u
File formatting
--------------
-All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained withing the same file(s);
+All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained within the same file(s);
they are only separated for easy viewing.
##### Examples:
diff --git a/vendor/github.com/go-playground/universal-translator/go.mod b/vendor/github.com/go-playground/universal-translator/go.mod
index 8079590..9d08600 100644
--- a/vendor/github.com/go-playground/universal-translator/go.mod
+++ b/vendor/github.com/go-playground/universal-translator/go.mod
@@ -2,4 +2,4 @@ module github.com/go-playground/universal-translator
go 1.13
-require github.com/go-playground/locales v0.13.0
+require github.com/go-playground/locales v0.14.0
diff --git a/vendor/github.com/go-playground/universal-translator/go.sum b/vendor/github.com/go-playground/universal-translator/go.sum
index cbbf324..20667ea 100644
--- a/vendor/github.com/go-playground/universal-translator/go.sum
+++ b/vendor/github.com/go-playground/universal-translator/go.sum
@@ -1,4 +1,7 @@
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
+github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/vendor/github.com/go-playground/universal-translator/import_export.go b/vendor/github.com/go-playground/universal-translator/import_export.go
index 7bd76f2..1216f19 100644
--- a/vendor/github.com/go-playground/universal-translator/import_export.go
+++ b/vendor/github.com/go-playground/universal-translator/import_export.go
@@ -257,6 +257,8 @@ func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader i
func stringToPR(s string) locales.PluralRule {
switch s {
+ case "Zero":
+ return locales.PluralRuleZero
case "One":
return locales.PluralRuleOne
case "Two":
diff --git a/vendor/github.com/go-playground/universal-translator/translator.go b/vendor/github.com/go-playground/universal-translator/translator.go
index cfafce8..24b18db 100644
--- a/vendor/github.com/go-playground/universal-translator/translator.go
+++ b/vendor/github.com/go-playground/universal-translator/translator.go
@@ -159,13 +159,13 @@ func (t *translator) AddCardinal(key interface{}, text string, rule locales.Plur
}
} else {
- tarr = make([]*transText, 7, 7)
+ tarr = make([]*transText, 7)
t.cardinalTanslations[key] = tarr
}
trans := &transText{
text: text,
- indexes: make([]int, 2, 2),
+ indexes: make([]int, 2),
}
tarr[rule] = trans
@@ -211,13 +211,13 @@ func (t *translator) AddOrdinal(key interface{}, text string, rule locales.Plura
}
} else {
- tarr = make([]*transText, 7, 7)
+ tarr = make([]*transText, 7)
t.ordinalTanslations[key] = tarr
}
trans := &transText{
text: text,
- indexes: make([]int, 2, 2),
+ indexes: make([]int, 2),
}
tarr[rule] = trans
@@ -261,13 +261,13 @@ func (t *translator) AddRange(key interface{}, text string, rule locales.PluralR
}
} else {
- tarr = make([]*transText, 7, 7)
+ tarr = make([]*transText, 7)
t.rangeTanslations[key] = tarr
}
trans := &transText{
text: text,
- indexes: make([]int, 4, 4),
+ indexes: make([]int, 4),
}
tarr[rule] = trans
diff --git a/vendor/github.com/go-playground/validator/v10/Makefile b/vendor/github.com/go-playground/validator/v10/Makefile
index 164e8bb..ec3455b 100644
--- a/vendor/github.com/go-playground/validator/v10/Makefile
+++ b/vendor/github.com/go-playground/validator/v10/Makefile
@@ -3,7 +3,7 @@ GOCMD=GO111MODULE=on go
linters-install:
@golangci-lint --version >/dev/null 2>&1 || { \
echo "installing linting tools..."; \
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.39.0; \
+ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \
}
lint: linters-install
diff --git a/vendor/github.com/go-playground/validator/v10/README.md b/vendor/github.com/go-playground/validator/v10/README.md
index 643cb90..f56cff1 100644
--- a/vendor/github.com/go-playground/validator/v10/README.md
+++ b/vendor/github.com/go-playground/validator/v10/README.md
@@ -1,7 +1,7 @@
Package validator
=================
[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-![Project status](https://img.shields.io/badge/version-10.8.0-green.svg)
+![Project status](https://img.shields.io/badge/version-10.9.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)
@@ -126,6 +126,7 @@ Baked-in Validations
| alphanumunicode | Alphanumeric Unicode |
| alphaunicode | Alpha Unicode |
| ascii | ASCII |
+| boolean | Boolean |
| contains | Contains |
| containsany | Contains Any |
| containsrune | Contains Rune |
@@ -169,6 +170,7 @@ Baked-in Validations
| iso3166_1_alpha3 | Three-letter country code (ISO 3166-1 alpha-3) |
| iso3166_1_alpha_numeric | Numeric country code (ISO 3166-1 numeric) |
| iso3166_2 | Country subdivision code (ISO 3166-2) |
+| iso4217 | Currency code (ISO 4217) |
| json | JSON |
| jwt | JSON Web Token (JWT) |
| latitude | Latitude |
diff --git a/vendor/github.com/go-playground/validator/v10/baked_in.go b/vendor/github.com/go-playground/validator/v10/baked_in.go
index ce81457..f5fd239 100644
--- a/vendor/github.com/go-playground/validator/v10/baked_in.go
+++ b/vendor/github.com/go-playground/validator/v10/baked_in.go
@@ -107,6 +107,7 @@ var (
"alphanum": isAlphanum,
"alphaunicode": isAlphaUnicode,
"alphanumunicode": isAlphanumUnicode,
+ "boolean": isBoolean,
"numeric": isNumeric,
"number": isNumber,
"hexadecimal": isHexadecimal,
@@ -191,6 +192,8 @@ var (
"iso3166_1_alpha3": isIso3166Alpha3,
"iso3166_1_alpha_numeric": isIso3166AlphaNumeric,
"iso3166_2": isIso31662,
+ "iso4217": isIso4217,
+ "iso4217_numeric": isIso4217Numeric,
"bcp47_language_tag": isBCP47LanguageTag,
"postcode_iso3166_alpha2": isPostcodeByIso3166Alpha2,
"postcode_iso3166_alpha2_field": isPostcodeByIso3166Alpha2Field,
@@ -1438,6 +1441,12 @@ func isAlphaUnicode(fl FieldLevel) bool {
return alphaUnicodeRegex.MatchString(fl.Field().String())
}
+// isBoolean is the validation function for validating if the current field's value can be safely converted to a boolean.
+func isBoolean(fl FieldLevel) bool {
+ _, err := strconv.ParseBool(fl.Field().String())
+ return err == nil
+}
+
// isDefault is the opposite of required aka hasValue
func isDefault(fl FieldLevel) bool {
return !hasValue(fl)
@@ -2358,6 +2367,28 @@ func isIso31662(fl FieldLevel) bool {
return iso3166_2[val]
}
+// isIso4217 is the validation function for validating if the current field's value is a valid iso4217 currency code.
+func isIso4217(fl FieldLevel) bool {
+ val := fl.Field().String()
+ return iso4217[val]
+}
+
+// isIso4217Numeric is the validation function for validating if the current field's value is a valid iso4217 numeric currency code.
+func isIso4217Numeric(fl FieldLevel) bool {
+ field := fl.Field()
+
+ var code int
+ switch field.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ code = int(field.Int())
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ code = int(field.Uint())
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+ return iso4217_numeric[code]
+}
+
// isBCP47LanguageTag is the validation function for validating if the current field's value is a valid BCP 47 language tag, as parsed by language.Parse
func isBCP47LanguageTag(fl FieldLevel) bool {
field := fl.Field()
diff --git a/vendor/github.com/go-playground/validator/v10/currency_codes.go b/vendor/github.com/go-playground/validator/v10/currency_codes.go
new file mode 100644
index 0000000..a5cd9b1
--- /dev/null
+++ b/vendor/github.com/go-playground/validator/v10/currency_codes.go
@@ -0,0 +1,79 @@
+package validator
+
+var iso4217 = map[string]bool{
+ "AFN": true, "EUR": true, "ALL": true, "DZD": true, "USD": true,
+ "AOA": true, "XCD": true, "ARS": true, "AMD": true, "AWG": true,
+ "AUD": true, "AZN": true, "BSD": true, "BHD": true, "BDT": true,
+ "BBD": true, "BYN": true, "BZD": true, "XOF": true, "BMD": true,
+ "INR": true, "BTN": true, "BOB": true, "BOV": true, "BAM": true,
+ "BWP": true, "NOK": true, "BRL": true, "BND": true, "BGN": true,
+ "BIF": true, "CVE": true, "KHR": true, "XAF": true, "CAD": true,
+ "KYD": true, "CLP": true, "CLF": true, "CNY": true, "COP": true,
+ "COU": true, "KMF": true, "CDF": true, "NZD": true, "CRC": true,
+ "HRK": true, "CUP": true, "CUC": true, "ANG": true, "CZK": true,
+ "DKK": true, "DJF": true, "DOP": true, "EGP": true, "SVC": true,
+ "ERN": true, "SZL": true, "ETB": true, "FKP": true, "FJD": true,
+ "XPF": true, "GMD": true, "GEL": true, "GHS": true, "GIP": true,
+ "GTQ": true, "GBP": true, "GNF": true, "GYD": true, "HTG": true,
+ "HNL": true, "HKD": true, "HUF": true, "ISK": true, "IDR": true,
+ "XDR": true, "IRR": true, "IQD": true, "ILS": true, "JMD": true,
+ "JPY": true, "JOD": true, "KZT": true, "KES": true, "KPW": true,
+ "KRW": true, "KWD": true, "KGS": true, "LAK": true, "LBP": true,
+ "LSL": true, "ZAR": true, "LRD": true, "LYD": true, "CHF": true,
+ "MOP": true, "MKD": true, "MGA": true, "MWK": true, "MYR": true,
+ "MVR": true, "MRU": true, "MUR": true, "XUA": true, "MXN": true,
+ "MXV": true, "MDL": true, "MNT": true, "MAD": true, "MZN": true,
+ "MMK": true, "NAD": true, "NPR": true, "NIO": true, "NGN": true,
+ "OMR": true, "PKR": true, "PAB": true, "PGK": true, "PYG": true,
+ "PEN": true, "PHP": true, "PLN": true, "QAR": true, "RON": true,
+ "RUB": true, "RWF": true, "SHP": true, "WST": true, "STN": true,
+ "SAR": true, "RSD": true, "SCR": true, "SLL": true, "SGD": true,
+ "XSU": true, "SBD": true, "SOS": true, "SSP": true, "LKR": true,
+ "SDG": true, "SRD": true, "SEK": true, "CHE": true, "CHW": true,
+ "SYP": true, "TWD": true, "TJS": true, "TZS": true, "THB": true,
+ "TOP": true, "TTD": true, "TND": true, "TRY": true, "TMT": true,
+ "UGX": true, "UAH": true, "AED": true, "USN": true, "UYU": true,
+ "UYI": true, "UYW": true, "UZS": true, "VUV": true, "VES": true,
+ "VND": true, "YER": true, "ZMW": true, "ZWL": true, "XBA": true,
+ "XBB": true, "XBC": true, "XBD": true, "XTS": true, "XXX": true,
+ "XAU": true, "XPD": true, "XPT": true, "XAG": true,
+}
+
+var iso4217_numeric = map[int]bool{
+ 8: true, 12: true, 32: true, 36: true, 44: true,
+ 48: true, 50: true, 51: true, 52: true, 60: true,
+ 64: true, 68: true, 72: true, 84: true, 90: true,
+ 96: true, 104: true, 108: true, 116: true, 124: true,
+ 132: true, 136: true, 144: true, 152: true, 156: true,
+ 170: true, 174: true, 188: true, 191: true, 192: true,
+ 203: true, 208: true, 214: true, 222: true, 230: true,
+ 232: true, 238: true, 242: true, 262: true, 270: true,
+ 292: true, 320: true, 324: true, 328: true, 332: true,
+ 340: true, 344: true, 348: true, 352: true, 356: true,
+ 360: true, 364: true, 368: true, 376: true, 388: true,
+ 392: true, 398: true, 400: true, 404: true, 408: true,
+ 410: true, 414: true, 417: true, 418: true, 422: true,
+ 426: true, 430: true, 434: true, 446: true, 454: true,
+ 458: true, 462: true, 480: true, 484: true, 496: true,
+ 498: true, 504: true, 512: true, 516: true, 524: true,
+ 532: true, 533: true, 548: true, 554: true, 558: true,
+ 566: true, 578: true, 586: true, 590: true, 598: true,
+ 600: true, 604: true, 608: true, 634: true, 643: true,
+ 646: true, 654: true, 682: true, 690: true, 694: true,
+ 702: true, 704: true, 706: true, 710: true, 728: true,
+ 748: true, 752: true, 756: true, 760: true, 764: true,
+ 776: true, 780: true, 784: true, 788: true, 800: true,
+ 807: true, 818: true, 826: true, 834: true, 840: true,
+ 858: true, 860: true, 882: true, 886: true, 901: true,
+ 927: true, 928: true, 929: true, 930: true, 931: true,
+ 932: true, 933: true, 934: true, 936: true, 938: true,
+ 940: true, 941: true, 943: true, 944: true, 946: true,
+ 947: true, 948: true, 949: true, 950: true, 951: true,
+ 952: true, 953: true, 955: true, 956: true, 957: true,
+ 958: true, 959: true, 960: true, 961: true, 962: true,
+ 963: true, 964: true, 965: true, 967: true, 968: true,
+ 969: true, 970: true, 971: true, 972: true, 973: true,
+ 975: true, 976: true, 977: true, 978: true, 979: true,
+ 980: true, 981: true, 984: true, 985: true, 986: true,
+ 990: true, 994: true, 997: true, 999: true,
+}
diff --git a/vendor/github.com/go-playground/validator/v10/doc.go b/vendor/github.com/go-playground/validator/v10/doc.go
index cf1376b..8c25847 100644
--- a/vendor/github.com/go-playground/validator/v10/doc.go
+++ b/vendor/github.com/go-playground/validator/v10/doc.go
@@ -7,6 +7,14 @@ and has the ability to dive into arrays and maps of any type.
see more examples https://github.com/go-playground/validator/tree/master/_examples
+Singleton
+
+Validator is designed to be thread-safe and used as a singleton instance.
+It caches information about your struct and validations,
+in essence only parsing your validation tags once per struct type.
+Using multiple instances neglects the benefit of caching.
+The not thread-safe functions are explicitly marked as such in the documentation.
+
Validation Functions Return Type error
Doing things this way is actually the way the standard library does, see the
@@ -726,6 +734,12 @@ This validates that a string value contains unicode alphanumeric characters only
Usage: alphanumunicode
+Boolean
+
+This validates that a string value can successfully be parsed into a boolean with strconv.ParseBool
+
+ Usage: boolean
+
Number
This validates that a string value contains number values only.
diff --git a/vendor/github.com/go-playground/validator/v10/go.mod b/vendor/github.com/go-playground/validator/v10/go.mod
index 786b8ca..ddecff6 100644
--- a/vendor/github.com/go-playground/validator/v10/go.mod
+++ b/vendor/github.com/go-playground/validator/v10/go.mod
@@ -3,11 +3,17 @@ module github.com/go-playground/validator/v10
go 1.13
require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-playground/assert/v2 v2.0.1
- github.com/go-playground/locales v0.13.0
- github.com/go-playground/universal-translator v0.17.0
+ github.com/go-playground/locales v0.14.0
+ github.com/go-playground/universal-translator v0.18.0
+ github.com/kr/pretty v0.3.0 // indirect
github.com/leodido/go-urn v1.2.1
+ github.com/rogpeppe/go-internal v1.8.0 // indirect
+ github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
- golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
+ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
golang.org/x/text v0.3.6
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
+ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
diff --git a/vendor/github.com/go-playground/validator/v10/go.sum b/vendor/github.com/go-playground/validator/v10/go.sum
index e0c6781..5750093 100644
--- a/vendor/github.com/go-playground/validator/v10/go.sum
+++ b/vendor/github.com/go-playground/validator/v10/go.sum
@@ -1,32 +1,50 @@
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
-github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
-github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
-github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
-github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
+github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
+github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
+github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
+github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
+github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
+github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/vendor/github.com/go-playground/validator/v10/validator_instance.go b/vendor/github.com/go-playground/validator/v10/validator_instance.go
index 96e777f..973964f 100644
--- a/vendor/github.com/go-playground/validator/v10/validator_instance.go
+++ b/vendor/github.com/go-playground/validator/v10/validator_instance.go
@@ -89,6 +89,10 @@ type Validate struct {
}
// New returns a new instance of 'validate' with sane defaults.
+// Validate is designed to be thread-safe and used as a singleton instance.
+// It caches information about your struct and validations,
+// in essence only parsing your validation tags once per struct type.
+// Using multiple instances neglects the benefit of caching.
func New() *Validate {
tc := new(tagCache)
diff --git a/vendor/github.com/wcharczuk/go-chart/.DS_Store b/vendor/github.com/wcharczuk/go-chart/.DS_Store
deleted file mode 100644
index 4680624..0000000
Binary files a/vendor/github.com/wcharczuk/go-chart/.DS_Store and /dev/null differ
diff --git a/vendor/github.com/wcharczuk/go-chart/.gitignore b/vendor/github.com/wcharczuk/go-chart/.gitignore
deleted file mode 100644
index 722d5e7..0000000
--- a/vendor/github.com/wcharczuk/go-chart/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.vscode
diff --git a/vendor/github.com/wcharczuk/go-chart/.travis.yml b/vendor/github.com/wcharczuk/go-chart/.travis.yml
deleted file mode 100644
index d3fbf34..0000000
--- a/vendor/github.com/wcharczuk/go-chart/.travis.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-language: go
-
-go:
- - 1.6.2
-
-sudo: false
-
-before_script:
- - go get -u github.com/blend/go-sdk/assert
- - go get ./...
-
-script:
- - go test ./...
diff --git a/vendor/github.com/wcharczuk/go-chart/Makefile b/vendor/github.com/wcharczuk/go-chart/Makefile
deleted file mode 100644
index cc16258..0000000
--- a/vendor/github.com/wcharczuk/go-chart/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-all: test
-
-test:
- @go test ./...
-
-cover:
- @go test -short -covermode=set -coverprofile=profile.cov
- @go tool cover -html=profile.cov
- @rm profile.cov
\ No newline at end of file
diff --git a/vendor/github.com/wcharczuk/go-chart/market_hours_range.go b/vendor/github.com/wcharczuk/go-chart/market_hours_range.go
deleted file mode 100644
index de32e8c..0000000
--- a/vendor/github.com/wcharczuk/go-chart/market_hours_range.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package chart
-
-import (
- "fmt"
- "time"
-
- "github.com/wcharczuk/go-chart/seq"
- "github.com/wcharczuk/go-chart/util"
-)
-
-// MarketHoursRange is a special type of range that compresses a time range into just the
-// market (i.e. NYSE operating hours and days) range.
-type MarketHoursRange struct {
- Min time.Time
- Max time.Time
-
- MarketOpen time.Time
- MarketClose time.Time
-
- HolidayProvider util.HolidayProvider
-
- ValueFormatter ValueFormatter
-
- Descending bool
- Domain int
-}
-
-// IsDescending returns if the range is descending.
-func (mhr MarketHoursRange) IsDescending() bool {
- return mhr.Descending
-}
-
-// GetTimezone returns the timezone for the market hours range.
-func (mhr MarketHoursRange) GetTimezone() *time.Location {
- return mhr.GetMarketOpen().Location()
-}
-
-// IsZero returns if the range is setup or not.
-func (mhr MarketHoursRange) IsZero() bool {
- return mhr.Min.IsZero() && mhr.Max.IsZero()
-}
-
-// GetMin returns the min value.
-func (mhr MarketHoursRange) GetMin() float64 {
- return util.Time.ToFloat64(mhr.Min)
-}
-
-// GetMax returns the max value.
-func (mhr MarketHoursRange) GetMax() float64 {
- return util.Time.ToFloat64(mhr.GetEffectiveMax())
-}
-
-// GetEffectiveMax gets either the close on the max, or the max itself.
-func (mhr MarketHoursRange) GetEffectiveMax() time.Time {
- maxClose := util.Date.On(mhr.MarketClose, mhr.Max)
- if maxClose.After(mhr.Max) {
- return maxClose
- }
- return mhr.Max
-}
-
-// SetMin sets the min value.
-func (mhr *MarketHoursRange) SetMin(min float64) {
- mhr.Min = util.Time.FromFloat64(min)
- mhr.Min = mhr.Min.In(mhr.GetTimezone())
-}
-
-// SetMax sets the max value.
-func (mhr *MarketHoursRange) SetMax(max float64) {
- mhr.Max = util.Time.FromFloat64(max)
- mhr.Max = mhr.Max.In(mhr.GetTimezone())
-}
-
-// GetDelta gets the delta.
-func (mhr MarketHoursRange) GetDelta() float64 {
- min := mhr.GetMin()
- max := mhr.GetMax()
- return max - min
-}
-
-// GetDomain gets the domain.
-func (mhr MarketHoursRange) GetDomain() int {
- return mhr.Domain
-}
-
-// SetDomain sets the domain.
-func (mhr *MarketHoursRange) SetDomain(domain int) {
- mhr.Domain = domain
-}
-
-// GetHolidayProvider coalesces a userprovided holiday provider and the date.DefaultHolidayProvider.
-func (mhr MarketHoursRange) GetHolidayProvider() util.HolidayProvider {
- if mhr.HolidayProvider == nil {
- return func(_ time.Time) bool { return false }
- }
- return mhr.HolidayProvider
-}
-
-// GetMarketOpen returns the market open time.
-func (mhr MarketHoursRange) GetMarketOpen() time.Time {
- if mhr.MarketOpen.IsZero() {
- return util.NYSEOpen()
- }
- return mhr.MarketOpen
-}
-
-// GetMarketClose returns the market close time.
-func (mhr MarketHoursRange) GetMarketClose() time.Time {
- if mhr.MarketClose.IsZero() {
- return util.NYSEClose()
- }
- return mhr.MarketClose
-}
-
-// GetTicks returns the ticks for the range.
-// This is to override the default continous ticks that would be generated for the range.
-func (mhr *MarketHoursRange) GetTicks(r Renderer, defaults Style, vf ValueFormatter) []Tick {
- times := seq.Time.MarketHours(mhr.Min, mhr.Max, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.GetHolidayProvider())
- timesWidth := mhr.measureTimes(r, defaults, vf, times)
- if timesWidth <= mhr.Domain {
- return mhr.makeTicks(vf, times)
- }
-
- times = seq.Time.MarketHourQuarters(mhr.Min, mhr.Max, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.GetHolidayProvider())
- timesWidth = mhr.measureTimes(r, defaults, vf, times)
- if timesWidth <= mhr.Domain {
- return mhr.makeTicks(vf, times)
- }
-
- times = seq.Time.MarketDayCloses(mhr.Min, mhr.Max, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.GetHolidayProvider())
- timesWidth = mhr.measureTimes(r, defaults, vf, times)
- if timesWidth <= mhr.Domain {
- return mhr.makeTicks(vf, times)
- }
-
- times = seq.Time.MarketDayAlternateCloses(mhr.Min, mhr.Max, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.GetHolidayProvider())
- timesWidth = mhr.measureTimes(r, defaults, vf, times)
- if timesWidth <= mhr.Domain {
- return mhr.makeTicks(vf, times)
- }
-
- times = seq.Time.MarketDayMondayCloses(mhr.Min, mhr.Max, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.GetHolidayProvider())
- timesWidth = mhr.measureTimes(r, defaults, vf, times)
- if timesWidth <= mhr.Domain {
- return mhr.makeTicks(vf, times)
- }
-
- return GenerateContinuousTicks(r, mhr, false, defaults, vf)
-
-}
-
-func (mhr *MarketHoursRange) measureTimes(r Renderer, defaults Style, vf ValueFormatter, times []time.Time) int {
- defaults.GetTextOptions().WriteToRenderer(r)
- var total int
- for index, t := range times {
- timeLabel := vf(t)
-
- labelBox := r.MeasureText(timeLabel)
- total += labelBox.Width()
- if index > 0 {
- total += DefaultMinimumTickHorizontalSpacing
- }
- }
- return total
-}
-
-func (mhr *MarketHoursRange) makeTicks(vf ValueFormatter, times []time.Time) []Tick {
- ticks := make([]Tick, len(times))
- for index, t := range times {
- ticks[index] = Tick{
- Value: util.Time.ToFloat64(t),
- Label: vf(t),
- }
- }
- return ticks
-}
-
-func (mhr MarketHoursRange) String() string {
- return fmt.Sprintf("MarketHoursRange [%s, %s] => %d", mhr.Min.Format(time.RFC3339), mhr.Max.Format(time.RFC3339), mhr.Domain)
-}
-
-// Translate maps a given value into the ContinuousRange space.
-func (mhr MarketHoursRange) Translate(value float64) int {
- valueTime := util.Time.FromFloat64(value)
- valueTimeEastern := valueTime.In(util.Date.Eastern())
- totalSeconds := util.Date.CalculateMarketSecondsBetween(mhr.Min, mhr.GetEffectiveMax(), mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.HolidayProvider)
- valueDelta := util.Date.CalculateMarketSecondsBetween(mhr.Min, valueTimeEastern, mhr.GetMarketOpen(), mhr.GetMarketClose(), mhr.HolidayProvider)
- translated := int((float64(valueDelta) / float64(totalSeconds)) * float64(mhr.Domain))
-
- if mhr.IsDescending() {
- return mhr.Domain - translated
- }
-
- return translated
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/linear.go b/vendor/github.com/wcharczuk/go-chart/seq/linear.go
deleted file mode 100644
index 699a5ac..0000000
--- a/vendor/github.com/wcharczuk/go-chart/seq/linear.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package seq
-
-// Range returns the array values of a linear seq with a given start, end and optional step.
-func Range(start, end float64) []float64 {
- return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(1.0)}.Array()
-}
-
-// RangeWithStep returns the array values of a linear seq with a given start, end and optional step.
-func RangeWithStep(start, end, step float64) []float64 {
- return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(step)}.Array()
-}
-
-// NewLinear returns a new linear generator.
-func NewLinear() *Linear {
- return &Linear{step: 1.0}
-}
-
-// Linear is a stepwise generator.
-type Linear struct {
- start float64
- end float64
- step float64
-}
-
-// Start returns the start value.
-func (lg Linear) Start() float64 {
- return lg.start
-}
-
-// End returns the end value.
-func (lg Linear) End() float64 {
- return lg.end
-}
-
-// Step returns the step value.
-func (lg Linear) Step() float64 {
- return lg.step
-}
-
-// Len returns the number of elements in the seq.
-func (lg Linear) Len() int {
- if lg.start < lg.end {
- return int((lg.end-lg.start)/lg.step) + 1
- }
- return int((lg.start-lg.end)/lg.step) + 1
-}
-
-// GetValue returns the value at a given index.
-func (lg Linear) GetValue(index int) float64 {
- fi := float64(index)
- if lg.start < lg.end {
- return lg.start + (fi * lg.step)
- }
- return lg.start - (fi * lg.step)
-}
-
-// WithStart sets the start and returns the linear generator.
-func (lg *Linear) WithStart(start float64) *Linear {
- lg.start = start
- return lg
-}
-
-// WithEnd sets the end and returns the linear generator.
-func (lg *Linear) WithEnd(end float64) *Linear {
- lg.end = end
- return lg
-}
-
-// WithStep sets the step and returns the linear generator.
-func (lg *Linear) WithStep(step float64) *Linear {
- lg.step = step
- return lg
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/time.go b/vendor/github.com/wcharczuk/go-chart/seq/time.go
deleted file mode 100644
index 79ef02a..0000000
--- a/vendor/github.com/wcharczuk/go-chart/seq/time.go
+++ /dev/null
@@ -1,171 +0,0 @@
-package seq
-
-import (
- "time"
-
- "github.com/wcharczuk/go-chart/util"
-)
-
-// Time is a utility singleton with helper functions for time seq generation.
-var Time timeSequence
-
-type timeSequence struct{}
-
-// Days generates a seq of timestamps by day, from -days to today.
-func (ts timeSequence) Days(days int) []time.Time {
- var values []time.Time
- for day := days; day >= 0; day-- {
- values = append(values, time.Now().AddDate(0, 0, -day))
- }
- return values
-}
-
-func (ts timeSequence) MarketHours(from, to time.Time, marketOpen, marketClose time.Time, isHoliday util.HolidayProvider) []time.Time {
- var times []time.Time
- cursor := util.Date.On(marketOpen, from)
- toClose := util.Date.On(marketClose, to)
- for cursor.Before(toClose) || cursor.Equal(toClose) {
- todayOpen := util.Date.On(marketOpen, cursor)
- todayClose := util.Date.On(marketClose, cursor)
- isValidTradingDay := !isHoliday(cursor) && util.Date.IsWeekDay(cursor.Weekday())
-
- if (cursor.Equal(todayOpen) || cursor.After(todayOpen)) && (cursor.Equal(todayClose) || cursor.Before(todayClose)) && isValidTradingDay {
- times = append(times, cursor)
- }
- if cursor.After(todayClose) {
- cursor = util.Date.NextMarketOpen(cursor, marketOpen, isHoliday)
- } else {
- cursor = util.Date.NextHour(cursor)
- }
- }
- return times
-}
-
-func (ts timeSequence) MarketHourQuarters(from, to time.Time, marketOpen, marketClose time.Time, isHoliday util.HolidayProvider) []time.Time {
- var times []time.Time
- cursor := util.Date.On(marketOpen, from)
- toClose := util.Date.On(marketClose, to)
- for cursor.Before(toClose) || cursor.Equal(toClose) {
-
- isValidTradingDay := !isHoliday(cursor) && util.Date.IsWeekDay(cursor.Weekday())
-
- if isValidTradingDay {
- todayOpen := util.Date.On(marketOpen, cursor)
- todayNoon := util.Date.NoonOn(cursor)
- today2pm := util.Date.On(util.Date.Time(14, 0, 0, 0, cursor.Location()), cursor)
- todayClose := util.Date.On(marketClose, cursor)
- times = append(times, todayOpen, todayNoon, today2pm, todayClose)
- }
-
- cursor = util.Date.NextDay(cursor)
- }
- return times
-}
-
-func (ts timeSequence) MarketDayCloses(from, to time.Time, marketOpen, marketClose time.Time, isHoliday util.HolidayProvider) []time.Time {
- var times []time.Time
- cursor := util.Date.On(marketOpen, from)
- toClose := util.Date.On(marketClose, to)
- for cursor.Before(toClose) || cursor.Equal(toClose) {
- isValidTradingDay := !isHoliday(cursor) && util.Date.IsWeekDay(cursor.Weekday())
- if isValidTradingDay {
- todayClose := util.Date.On(marketClose, cursor)
- times = append(times, todayClose)
- }
-
- cursor = util.Date.NextDay(cursor)
- }
- return times
-}
-
-func (ts timeSequence) MarketDayAlternateCloses(from, to time.Time, marketOpen, marketClose time.Time, isHoliday util.HolidayProvider) []time.Time {
- var times []time.Time
- cursor := util.Date.On(marketOpen, from)
- toClose := util.Date.On(marketClose, to)
- for cursor.Before(toClose) || cursor.Equal(toClose) {
- isValidTradingDay := !isHoliday(cursor) && util.Date.IsWeekDay(cursor.Weekday())
- if isValidTradingDay {
- todayClose := util.Date.On(marketClose, cursor)
- times = append(times, todayClose)
- }
-
- cursor = cursor.AddDate(0, 0, 2)
- }
- return times
-}
-
-func (ts timeSequence) MarketDayMondayCloses(from, to time.Time, marketOpen, marketClose time.Time, isHoliday util.HolidayProvider) []time.Time {
- var times []time.Time
- cursor := util.Date.On(marketClose, from)
- toClose := util.Date.On(marketClose, to)
-
- for cursor.Equal(toClose) || cursor.Before(toClose) {
- isValidTradingDay := !isHoliday(cursor) && util.Date.IsWeekDay(cursor.Weekday())
- if isValidTradingDay {
- times = append(times, cursor)
- }
- cursor = util.Date.NextDayOfWeek(cursor, time.Monday)
- }
- return times
-}
-
-func (ts timeSequence) Hours(start time.Time, totalHours int) []time.Time {
- times := make([]time.Time, totalHours)
-
- last := start
- for i := 0; i < totalHours; i++ {
- times[i] = last
- last = last.Add(time.Hour)
- }
-
- return times
-}
-
-// HoursFilled adds zero values for the data bounded by the start and end of the xdata array.
-func (ts timeSequence) HoursFilled(xdata []time.Time, ydata []float64) ([]time.Time, []float64) {
- start := Time.Start(xdata)
- end := Time.End(xdata)
-
- totalHours := util.Math.AbsInt(util.Date.DiffHours(start, end))
-
- finalTimes := ts.Hours(start, totalHours+1)
- finalValues := make([]float64, totalHours+1)
-
- var hoursFromStart int
- for i, xd := range xdata {
- hoursFromStart = util.Date.DiffHours(start, xd)
- finalValues[hoursFromStart] = ydata[i]
- }
-
- return finalTimes, finalValues
-}
-
-// Start returns the earliest (min) time in a list of times.
-func (ts timeSequence) Start(times []time.Time) time.Time {
- if len(times) == 0 {
- return time.Time{}
- }
-
- start := times[0]
- for _, t := range times[1:] {
- if t.Before(start) {
- start = t
- }
- }
- return start
-}
-
-// Start returns the earliest (min) time in a list of times.
-func (ts timeSequence) End(times []time.Time) time.Time {
- if len(times) == 0 {
- return time.Time{}
- }
-
- end := times[0]
- for _, t := range times[1:] {
- if t.After(end) {
- end = t
- }
- }
- return end
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/util.go b/vendor/github.com/wcharczuk/go-chart/seq/util.go
deleted file mode 100644
index 685a408..0000000
--- a/vendor/github.com/wcharczuk/go-chart/seq/util.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package seq
-
-import "math"
-
-func round(input float64, places int) (rounded float64) {
- if math.IsNaN(input) {
- return 0.0
- }
-
- sign := 1.0
- if input < 0 {
- sign = -1
- input *= -1
- }
-
- precision := math.Pow(10, float64(places))
- digit := input * precision
- _, decimal := math.Modf(digit)
-
- if decimal >= 0.5 {
- rounded = math.Ceil(digit)
- } else {
- rounded = math.Floor(digit)
- }
-
- return rounded / precision * sign
-}
-
-func f64i(value float64) int {
- r := round(value, 0)
- return int(r)
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/util/date.go b/vendor/github.com/wcharczuk/go-chart/util/date.go
deleted file mode 100644
index 18b8603..0000000
--- a/vendor/github.com/wcharczuk/go-chart/util/date.go
+++ /dev/null
@@ -1,396 +0,0 @@
-package util
-
-import (
- "sync"
- "time"
-)
-
-const (
- // AllDaysMask is a bitmask of all the days of the week.
- AllDaysMask = 1<friday.
-func (d date) IsWeekDay(day time.Weekday) bool {
- return !d.IsWeekendDay(day)
-}
-
-// IsWeekendDay returns if the day is a monday->friday.
-func (d date) IsWeekendDay(day time.Weekday) bool {
- return day == time.Saturday || day == time.Sunday
-}
-
-// Before returns if a timestamp is strictly before another date (ignoring hours, minutes etc.)
-func (d date) Before(before, reference time.Time) bool {
- tzAdjustedBefore := before.In(reference.Location())
- if tzAdjustedBefore.Year() < reference.Year() {
- return true
- }
- if tzAdjustedBefore.Month() < reference.Month() {
- return true
- }
- return tzAdjustedBefore.Year() == reference.Year() && tzAdjustedBefore.Month() == reference.Month() && tzAdjustedBefore.Day() < reference.Day()
-}
-
-// NextMarketOpen returns the next market open after a given time.
-func (d date) NextMarketOpen(after, openTime time.Time, isHoliday HolidayProvider) time.Time {
- afterLocalized := after.In(openTime.Location())
- todaysOpen := d.On(openTime, afterLocalized)
-
- if isHoliday == nil {
- isHoliday = defaultHolidayProvider
- }
-
- todayIsValidTradingDay := d.IsWeekDay(todaysOpen.Weekday()) && !isHoliday(todaysOpen)
-
- if (afterLocalized.Equal(todaysOpen) || afterLocalized.Before(todaysOpen)) && todayIsValidTradingDay {
- return todaysOpen
- }
-
- for cursorDay := 1; cursorDay < 7; cursorDay++ {
- newDay := todaysOpen.AddDate(0, 0, cursorDay)
- isValidTradingDay := d.IsWeekDay(newDay.Weekday()) && !isHoliday(newDay)
- if isValidTradingDay {
- return d.On(openTime, newDay)
- }
- }
- panic("Have exhausted day window looking for next market open.")
-}
-
-// NextMarketClose returns the next market close after a given time.
-func (d date) NextMarketClose(after, closeTime time.Time, isHoliday HolidayProvider) time.Time {
- afterLocalized := after.In(closeTime.Location())
-
- if isHoliday == nil {
- isHoliday = defaultHolidayProvider
- }
-
- todaysClose := d.On(closeTime, afterLocalized)
- if afterLocalized.Before(todaysClose) && d.IsWeekDay(todaysClose.Weekday()) && !isHoliday(todaysClose) {
- return todaysClose
- }
-
- if afterLocalized.Equal(todaysClose) { //rare but it might happen.
- return todaysClose
- }
-
- for cursorDay := 1; cursorDay < 6; cursorDay++ {
- newDay := todaysClose.AddDate(0, 0, cursorDay)
- if d.IsWeekDay(newDay.Weekday()) && !isHoliday(newDay) {
- return d.On(closeTime, newDay)
- }
- }
- panic("Have exhausted day window looking for next market close.")
-}
-
-// CalculateMarketSecondsBetween calculates the number of seconds the market was open between two dates.
-func (d date) CalculateMarketSecondsBetween(start, end, marketOpen, marketClose time.Time, isHoliday HolidayProvider) (seconds int64) {
- startEastern := start.In(d.Eastern())
- endEastern := end.In(d.Eastern())
-
- startMarketOpen := d.On(marketOpen, startEastern)
- startMarketClose := d.On(marketClose, startEastern)
-
- if !d.IsWeekendDay(startMarketOpen.Weekday()) && !isHoliday(startMarketOpen) {
- if (startEastern.Equal(startMarketOpen) || startEastern.After(startMarketOpen)) && startEastern.Before(startMarketClose) {
- if endEastern.Before(startMarketClose) {
- seconds += int64(endEastern.Sub(startEastern) / time.Second)
- } else {
- seconds += int64(startMarketClose.Sub(startEastern) / time.Second)
- }
- }
- }
-
- cursor := d.NextMarketOpen(startMarketClose, marketOpen, isHoliday)
- for d.Before(cursor, endEastern) {
- if d.IsWeekDay(cursor.Weekday()) && !isHoliday(cursor) {
- close := d.NextMarketClose(cursor, marketClose, isHoliday)
- seconds += int64(close.Sub(cursor) / time.Second)
- }
- cursor = cursor.AddDate(0, 0, 1)
- }
-
- finalMarketOpen := d.NextMarketOpen(cursor, marketOpen, isHoliday)
- finalMarketClose := d.NextMarketClose(cursor, marketClose, isHoliday)
- if endEastern.After(finalMarketOpen) {
- if endEastern.Before(finalMarketClose) {
- seconds += int64(endEastern.Sub(finalMarketOpen) / time.Second)
- } else {
- seconds += int64(finalMarketClose.Sub(finalMarketOpen) / time.Second)
- }
- }
-
- return
-}
-
-const (
- _secondsPerHour = 60 * 60
- _secondsPerDay = 60 * 60 * 24
-)
-
-func (d date) DiffDays(t1, t2 time.Time) (days int) {
- t1n := t1.Unix()
- t2n := t2.Unix()
- diff := t2n - t1n //yields seconds
- return int(diff / (_secondsPerDay))
-}
-
-func (d date) DiffHours(t1, t2 time.Time) (hours int) {
- t1n := t1.Unix()
- t2n := t2.Unix()
- diff := t2n - t1n //yields seconds
- return int(diff / (_secondsPerHour))
-}
-
-// NextDay returns the timestamp advanced a day.
-func (d date) NextDay(ts time.Time) time.Time {
- return ts.AddDate(0, 0, 1)
-}
-
-// NextHour returns the next timestamp on the hour.
-func (d date) NextHour(ts time.Time) time.Time {
- //advance a full hour ...
- advanced := ts.Add(time.Hour)
- minutes := time.Duration(advanced.Minute()) * time.Minute
- final := advanced.Add(-minutes)
- return time.Date(final.Year(), final.Month(), final.Day(), final.Hour(), 0, 0, 0, final.Location())
-}
-
-// NextDayOfWeek returns the next instance of a given weekday after a given timestamp.
-func (d date) NextDayOfWeek(after time.Time, dayOfWeek time.Weekday) time.Time {
- afterWeekday := after.Weekday()
- if afterWeekday == dayOfWeek {
- return after.AddDate(0, 0, 7)
- }
-
- // 1 vs 5 ~ add 4 days
- if afterWeekday < dayOfWeek {
- dayDelta := int(dayOfWeek - afterWeekday)
- return after.AddDate(0, 0, dayDelta)
- }
-
- // 5 vs 1, add 7-(5-1) ~ 3 days
- dayDelta := 7 - int(afterWeekday-dayOfWeek)
- return after.AddDate(0, 0, dayDelta)
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/util/date_posix.go b/vendor/github.com/wcharczuk/go-chart/util/date_posix.go
deleted file mode 100644
index 1a5a80c..0000000
--- a/vendor/github.com/wcharczuk/go-chart/util/date_posix.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// +build !windows
-
-package util
-
-import "time"
-
-// Eastern returns the eastern timezone.
-func (d date) Eastern() *time.Location {
- if _eastern == nil {
- _easternLock.Lock()
- defer _easternLock.Unlock()
- if _eastern == nil {
- _eastern, _ = time.LoadLocation("America/New_York")
- }
- }
- return _eastern
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/util/date_windows.go b/vendor/github.com/wcharczuk/go-chart/util/date_windows.go
deleted file mode 100644
index c42a367..0000000
--- a/vendor/github.com/wcharczuk/go-chart/util/date_windows.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// +build windows
-
-package util
-
-import "time"
-
-// Eastern returns the eastern timezone.
-func (d date) Eastern() *time.Location {
- if _eastern == nil {
- _easternLock.Lock()
- defer _easternLock.Unlock()
- if _eastern == nil {
- _eastern, _ = time.LoadLocation("EST")
- }
- }
- return _eastern
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/util/file_util.go b/vendor/github.com/wcharczuk/go-chart/util/file_util.go
deleted file mode 100644
index d6c561d..0000000
--- a/vendor/github.com/wcharczuk/go-chart/util/file_util.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package util
-
-import (
- "bufio"
- "io"
- "os"
-)
-
-var (
- // File contains file utility functions
- File = fileUtil{}
-)
-
-type fileUtil struct{}
-
-// ReadByLines reads a file and calls the handler for each line.
-func (fu fileUtil) ReadByLines(filePath string, handler func(line string) error) error {
- var f *os.File
- var err error
- if f, err = os.Open(filePath); err == nil {
- defer f.Close()
- var line string
- scanner := bufio.NewScanner(f)
- for scanner.Scan() {
- line = scanner.Text()
- err = handler(line)
- if err != nil {
- return err
- }
- }
- }
- return err
-
-}
-
-// ReadByChunks reads a file in `chunkSize` pieces, dispatched to the handler.
-func (fu fileUtil) ReadByChunks(filePath string, chunkSize int, handler func(line []byte) error) error {
- var f *os.File
- var err error
- if f, err = os.Open(filePath); err == nil {
- defer f.Close()
-
- chunk := make([]byte, chunkSize)
- for {
- readBytes, err := f.Read(chunk)
- if err == io.EOF {
- break
- }
- readData := chunk[:readBytes]
- err = handler(readData)
- if err != nil {
- return err
- }
- }
- }
- return err
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/util/time.go b/vendor/github.com/wcharczuk/go-chart/util/time.go
deleted file mode 100644
index 88e0c8b..0000000
--- a/vendor/github.com/wcharczuk/go-chart/util/time.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package util
-
-import "time"
-
-var (
- // Time contains time utility functions.
- Time = timeUtil{}
-)
-
-type timeUtil struct{}
-
-// TimeToFloat64 returns a float64 representation of a time.
-func (tu timeUtil) ToFloat64(t time.Time) float64 {
- return float64(t.UnixNano())
-}
-
-// Float64ToTime returns a time from a float64.
-func (tu timeUtil) FromFloat64(tf float64) time.Time {
- return time.Unix(0, int64(tf))
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/.gitignore b/vendor/github.com/wcharczuk/go-chart/v2/.gitignore
new file mode 100644
index 0000000..3e4b6e1
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/.gitignore
@@ -0,0 +1,19 @@
+# Binaries for programs and plugins
+*.exe
+*.dll
+*.so
+*.dylib
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
+.glide/
+
+# Other
+.vscode
+.DS_Store
+coverage.html
\ No newline at end of file
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/COVERAGE b/vendor/github.com/wcharczuk/go-chart/v2/COVERAGE
new file mode 100644
index 0000000..7e492f8
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/COVERAGE
@@ -0,0 +1 @@
+29.02
\ No newline at end of file
diff --git a/vendor/github.com/wcharczuk/go-chart/LICENSE b/vendor/github.com/wcharczuk/go-chart/v2/LICENSE
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/LICENSE
rename to vendor/github.com/wcharczuk/go-chart/v2/LICENSE
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/Makefile b/vendor/github.com/wcharczuk/go-chart/v2/Makefile
new file mode 100644
index 0000000..e0928c3
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/Makefile
@@ -0,0 +1,10 @@
+all: new-install test
+
+new-install:
+ @go get -v -u ./...
+
+generate:
+ @go generate ./...
+
+test:
+ @go test ./...
\ No newline at end of file
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/PROFANITY_RULES.yml b/vendor/github.com/wcharczuk/go-chart/v2/PROFANITY_RULES.yml
new file mode 100644
index 0000000..1e6c803
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/PROFANITY_RULES.yml
@@ -0,0 +1,4 @@
+go-sdk:
+ excludeFiles: [ "*_test.go" ]
+ importsContain: [ github.com/blend/go-sdk/* ]
+ description: "please don't use go-sdk in this repo"
\ No newline at end of file
diff --git a/vendor/github.com/wcharczuk/go-chart/README.md b/vendor/github.com/wcharczuk/go-chart/v2/README.md
similarity index 66%
rename from vendor/github.com/wcharczuk/go-chart/README.md
rename to vendor/github.com/wcharczuk/go-chart/v2/README.md
index 0ed0a51..a0cdbc0 100644
--- a/vendor/github.com/wcharczuk/go-chart/README.md
+++ b/vendor/github.com/wcharczuk/go-chart/v2/README.md
@@ -1,13 +1,10 @@
go-chart
========
-[![Build Status](https://travis-ci.org/wcharczuk/go-chart.svg?branch=master)](https://travis-ci.org/wcharczuk/go-chart)[![Go Report Card](https://goreportcard.com/badge/github.com/wcharczuk/go-chart)](https://goreportcard.com/report/github.com/wcharczuk/go-chart)
+[![CircleCI](https://circleci.com/gh/wcharczuk/go-chart.svg?style=svg)](https://circleci.com/gh/wcharczuk/go-chart) [![Go Report Card](https://goreportcard.com/badge/github.com/wcharczuk/go-chart)](https://goreportcard.com/report/github.com/wcharczuk/go-chart)
-Package `chart` is a very simple golang native charting library that supports timeseries and continuous
-line charts.
+Package `chart` is a very simple golang native charting library that supports timeseries and continuous line charts.
-The v1.0 release has been tagged so things should be more or less stable, if something changes please log an issue.
-
-Master should now be on the v2.x codebase, which brings a couple new features and better handling of basics like axes labeling etc. Per usual, see `_examples` for more information.
+Master should now be on the v3.x codebase, which overhauls the api significantly. Per usual, see `examples` for more information.
# Installation
@@ -17,9 +14,9 @@ To install `chart` run the following:
> go get -u github.com/wcharczuk/go-chart
```
-Most of the components are interchangeable so feel free to crib whatever you want.
+Most of the components are interchangeable so feel free to crib whatever you want.
-# Output Examples
+# Output Examples
Spark Lines:
@@ -39,17 +36,17 @@ Pie Chart:
![](https://raw.githubusercontent.com/wcharczuk/go-chart/master/_images/pie_chart.png)
-The code for this chart can be found in `_examples/pie_chart/main.go`.
+The code for this chart can be found in `examples/pie_chart/main.go`.
Stacked Bar:
![](https://raw.githubusercontent.com/wcharczuk/go-chart/master/_images/stacked_bar.png)
-The code for this chart can be found in `_examples/stacked_bar/main.go`.
+The code for this chart can be found in `examples/stacked_bar/main.go`.
# Code Examples
-Actual chart configurations and examples can be found in the `./_examples/` directory. They are web servers, so start them with `go run main.go` then access `http://localhost:8080` to see the output.
+Actual chart configurations and examples can be found in the `./examples/` directory. They are simple CLI programs that write to `output.png` (they are also updated with `go generate`.
# Usage
@@ -83,8 +80,7 @@ Here, we have a single series with x range values as float64s, rendered to a PNG
# API Overview
-Everything on the `chart.Chart` object has defaults that can be overriden. Whenever a developer sets a property on the chart object, it is to be assumed that value will be used instead of the default. One complication here
-is any object's root `chart.Style` object (i.e named `Style`) and the `Show` property specifically, if any other property is set and the `Show` property is unset, it is assumed to be it's default value of `False`.
+Everything on the `chart.Chart` object has defaults that can be overriden. Whenever a developer sets a property on the chart object, it is to be assumed that value will be used instead of the default.
The best way to see the api in action is to look at the examples in the `./_examples/` directory.
@@ -96,4 +92,4 @@ The goal with the API itself is to have the "zero value be useful", and to requi
# Contributions
-This library is super early but contributions are welcome.
+Contributions are welcome though this library is in a holding pattern for the forseable future.
diff --git a/vendor/github.com/wcharczuk/go-chart/annotation_series.go b/vendor/github.com/wcharczuk/go-chart/v2/annotation_series.go
similarity index 86%
rename from vendor/github.com/wcharczuk/go-chart/annotation_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/annotation_series.go
index 9c383c9..96e78f9 100644
--- a/vendor/github.com/wcharczuk/go-chart/annotation_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/annotation_series.go
@@ -3,8 +3,11 @@ package chart
import (
"fmt"
"math"
+)
- util "github.com/wcharczuk/go-chart/util"
+// Interface Assertions.
+var (
+ _ Series = (*AnnotationSeries)(nil)
)
// AnnotationSeries is a series of labels on the chart.
@@ -50,17 +53,17 @@ func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Ran
Right: 0,
Bottom: 0,
}
- if as.Style.IsZero() || as.Style.Show {
+ if !as.Style.Hidden {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for _, a := range as.Annotations {
style := a.Style.InheritFrom(seriesStyle)
lx := canvasBox.Left + xrange.Translate(a.XValue)
ly := canvasBox.Bottom - yrange.Translate(a.YValue)
ab := Draw.MeasureAnnotation(r, canvasBox, style, lx, ly, a.Label)
- box.Top = util.Math.MinInt(box.Top, ab.Top)
- box.Left = util.Math.MinInt(box.Left, ab.Left)
- box.Right = util.Math.MaxInt(box.Right, ab.Right)
- box.Bottom = util.Math.MaxInt(box.Bottom, ab.Bottom)
+ box.Top = MinInt(box.Top, ab.Top)
+ box.Left = MinInt(box.Left, ab.Left)
+ box.Right = MaxInt(box.Right, ab.Right)
+ box.Bottom = MaxInt(box.Bottom, ab.Bottom)
}
}
return box
@@ -68,7 +71,7 @@ func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Ran
// Render draws the series.
func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
- if as.Style.IsZero() || as.Style.Show {
+ if !as.Style.Hidden {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for _, a := range as.Annotations {
style := a.Style.InheritFrom(seriesStyle)
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/array.go b/vendor/github.com/wcharczuk/go-chart/v2/array.go
similarity index 65%
rename from vendor/github.com/wcharczuk/go-chart/seq/array.go
rename to vendor/github.com/wcharczuk/go-chart/v2/array.go
index 08479c2..71b3ee7 100644
--- a/vendor/github.com/wcharczuk/go-chart/seq/array.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/array.go
@@ -1,6 +1,11 @@
-package seq
+package chart
-// NewArray creates a new array.
+var (
+ _ Sequence = (*Array)(nil)
+)
+
+// NewArray returns a new array from a given set of values.
+// Array implements Sequence, which allows it to be used with the sequence helpers.
func NewArray(values ...float64) Array {
return Array(values)
}
diff --git a/vendor/github.com/wcharczuk/go-chart/axis.go b/vendor/github.com/wcharczuk/go-chart/v2/axis.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/axis.go
rename to vendor/github.com/wcharczuk/go-chart/v2/axis.go
diff --git a/vendor/github.com/wcharczuk/go-chart/bar_chart.go b/vendor/github.com/wcharczuk/go-chart/v2/bar_chart.go
similarity index 94%
rename from vendor/github.com/wcharczuk/go-chart/bar_chart.go
rename to vendor/github.com/wcharczuk/go-chart/v2/bar_chart.go
index 0c24d92..d61f3db 100644
--- a/vendor/github.com/wcharczuk/go-chart/bar_chart.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/bar_chart.go
@@ -7,7 +7,6 @@ import (
"math"
"github.com/golang/freetype/truetype"
- util "github.com/wcharczuk/go-chart/util"
)
// BarChart is a chart that draws bars on a range.
@@ -31,6 +30,9 @@ type BarChart struct {
BarSpacing int
+ UseBaseValue bool
+ BaseValue float64
+
Font *truetype.Font
defaultFont *truetype.Font
@@ -199,11 +201,20 @@ func (bc BarChart) drawBars(r Renderer, canvasBox Box, yr Range) {
by = canvasBox.Bottom - yr.Translate(bar.Value)
- barBox = Box{
- Top: by,
- Left: bxl,
- Right: bxr,
- Bottom: canvasBox.Bottom,
+ if bc.UseBaseValue {
+ barBox = Box{
+ Top: by,
+ Left: bxl,
+ Right: bxr,
+ Bottom: canvasBox.Bottom - yr.Translate(bc.BaseValue),
+ }
+ } else {
+ barBox = Box{
+ Top: by,
+ Left: bxl,
+ Right: bxr,
+ Bottom: canvasBox.Bottom,
+ }
}
Draw.Box(r, barBox, bar.Style.InheritFrom(bc.styleDefaultsBar(index)))
@@ -213,7 +224,7 @@ func (bc BarChart) drawBars(r Renderer, canvasBox Box, yr Range) {
}
func (bc BarChart) drawXAxis(r Renderer, canvasBox Box) {
- if bc.XAxis.Show {
+ if !bc.XAxis.Hidden {
axisStyle := bc.XAxis.InheritFrom(bc.styleDefaultsAxes())
axisStyle.WriteToRenderer(r)
@@ -252,7 +263,7 @@ func (bc BarChart) drawXAxis(r Renderer, canvasBox Box) {
}
func (bc BarChart) drawYAxis(r Renderer, canvasBox Box, yr Range, ticks []Tick) {
- if bc.YAxis.Style.Show {
+ if !bc.YAxis.Style.Hidden {
axisStyle := bc.YAxis.Style.InheritFrom(bc.styleDefaultsAxes())
axisStyle.WriteToRenderer(r)
@@ -283,7 +294,7 @@ func (bc BarChart) drawYAxis(r Renderer, canvasBox Box, yr Range, ticks []Tick)
}
func (bc BarChart) drawTitle(r Renderer) {
- if len(bc.Title) > 0 && bc.TitleStyle.Show {
+ if len(bc.Title) > 0 && !bc.TitleStyle.Hidden {
r.SetFont(bc.TitleStyle.GetFont(bc.GetFont()))
r.SetFontColor(bc.TitleStyle.GetFontColor(bc.GetColorPalette().TextColor()))
titleFontSize := bc.TitleStyle.GetFontSize(bc.getTitleFontSize())
@@ -314,7 +325,7 @@ func (bc BarChart) styleDefaultsCanvas() Style {
}
func (bc BarChart) hasAxes() bool {
- return bc.YAxis.Style.Show
+ return !bc.YAxis.Style.Hidden
}
func (bc BarChart) setRangeDomains(canvasBox Box, yr Range) Range {
@@ -334,7 +345,7 @@ func (bc BarChart) getValueFormatters() ValueFormatter {
}
func (bc BarChart) getAxesTicks(r Renderer, yr Range, yf ValueFormatter) (yticks []Tick) {
- if bc.YAxis.Style.Show {
+ if !bc.YAxis.Style.Hidden {
yticks = bc.YAxis.GetTicks(r, yr, bc.styleDefaultsAxes(), yf)
}
return
@@ -380,7 +391,7 @@ func (bc BarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box, yrange Range,
_, _, totalWidth := bc.calculateScaledTotalWidth(canvasBox)
- if bc.XAxis.Show {
+ if !bc.XAxis.Hidden {
xaxisHeight := DefaultVerticalTickHeight
axisStyle := bc.XAxis.InheritFrom(bc.styleDefaultsAxes())
@@ -398,7 +409,7 @@ func (bc BarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box, yrange Range,
lines := Text.WrapFit(r, bar.Label, barLabelBox.Width(), axisStyle)
linesBox := Text.MeasureLines(r, lines, axisStyle)
- xaxisHeight = util.Math.MinInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
+ xaxisHeight = MinInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
}
}
@@ -412,7 +423,7 @@ func (bc BarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box, yrange Range,
axesOuterBox = axesOuterBox.Grow(xbox)
}
- if bc.YAxis.Style.Show {
+ if !bc.YAxis.Style.Hidden {
axesBounds := bc.YAxis.Measure(r, canvasBox, yrange, bc.styleDefaultsAxes(), yticks)
axesOuterBox = axesOuterBox.Grow(axesBounds)
}
@@ -465,7 +476,7 @@ func (bc BarChart) styleDefaultsTitle() Style {
}
func (bc BarChart) getTitleFontSize() float64 {
- effectiveDimension := util.Math.MinInt(bc.GetWidth(), bc.GetHeight())
+ effectiveDimension := MinInt(bc.GetWidth(), bc.GetHeight())
if effectiveDimension >= 2048 {
return 48
} else if effectiveDimension >= 1024 {
diff --git a/vendor/github.com/wcharczuk/go-chart/bollinger_band_series.go b/vendor/github.com/wcharczuk/go-chart/v2/bollinger_band_series.go
similarity index 89%
rename from vendor/github.com/wcharczuk/go-chart/bollinger_band_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/bollinger_band_series.go
index 9dbd3b8..728b232 100644
--- a/vendor/github.com/wcharczuk/go-chart/bollinger_band_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/bollinger_band_series.go
@@ -2,8 +2,11 @@ package chart
import (
"fmt"
+)
- "github.com/wcharczuk/go-chart/seq"
+// Interface Assertions.
+var (
+ _ Series = (*BollingerBandsSeries)(nil)
)
// BollingerBandsSeries draws bollinger bands for an inner series.
@@ -17,7 +20,7 @@ type BollingerBandsSeries struct {
K float64
InnerSeries ValuesProvider
- valueBuffer *seq.Buffer
+ valueBuffer *ValueBuffer
}
// GetName returns the name of the time series.
@@ -67,7 +70,7 @@ func (bbs *BollingerBandsSeries) GetBoundedValues(index int) (x, y1, y2 float64)
return
}
if bbs.valueBuffer == nil || index == 0 {
- bbs.valueBuffer = seq.NewBufferWithCapacity(bbs.GetPeriod())
+ bbs.valueBuffer = NewValueBufferWithCapacity(bbs.GetPeriod())
}
if bbs.valueBuffer.Len() >= bbs.GetPeriod() {
bbs.valueBuffer.Dequeue()
@@ -76,8 +79,8 @@ func (bbs *BollingerBandsSeries) GetBoundedValues(index int) (x, y1, y2 float64)
bbs.valueBuffer.Enqueue(py)
x = px
- ay := seq.New(bbs.valueBuffer).Average()
- std := seq.New(bbs.valueBuffer).StdDev()
+ ay := Seq{bbs.valueBuffer}.Average()
+ std := Seq{bbs.valueBuffer}.StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
@@ -96,15 +99,15 @@ func (bbs *BollingerBandsSeries) GetBoundedLastValues() (x, y1, y2 float64) {
startAt = 0
}
- vb := seq.NewBufferWithCapacity(period)
+ vb := NewValueBufferWithCapacity(period)
for index := startAt; index < seriesLength; index++ {
xn, yn := bbs.InnerSeries.GetValues(index)
vb.Enqueue(yn)
x = xn
}
- ay := seq.Seq{Provider: vb}.Average()
- std := seq.Seq{Provider: vb}.StdDev()
+ ay := Seq{vb}.Average()
+ std := Seq{vb}.StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/bounded_last_values_annotation_series.go b/vendor/github.com/wcharczuk/go-chart/v2/bounded_last_values_annotation_series.go
new file mode 100644
index 0000000..670ddf7
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/bounded_last_values_annotation_series.go
@@ -0,0 +1,36 @@
+package chart
+
+import "fmt"
+
+// BoundedLastValuesAnnotationSeries returns a last value annotation series for a bounded values provider.
+func BoundedLastValuesAnnotationSeries(innerSeries FullBoundedValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
+ lvx, lvy1, lvy2 := innerSeries.GetBoundedLastValues()
+
+ var vf ValueFormatter
+ if len(vfs) > 0 {
+ vf = vfs[0]
+ } else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
+ _, vf = typed.GetValueFormatters()
+ } else {
+ vf = FloatValueFormatter
+ }
+
+ label1 := vf(lvy1)
+ label2 := vf(lvy2)
+
+ var seriesName string
+ var seriesStyle Style
+ if typed, isTyped := innerSeries.(Series); isTyped {
+ seriesName = fmt.Sprintf("%s - Last Values", typed.GetName())
+ seriesStyle = typed.GetStyle()
+ }
+
+ return AnnotationSeries{
+ Name: seriesName,
+ Style: seriesStyle,
+ Annotations: []Value2{
+ {XValue: lvx, YValue: lvy1, Label: label1},
+ {XValue: lvx, YValue: lvy2, Label: label2},
+ },
+ }
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/box.go b/vendor/github.com/wcharczuk/go-chart/v2/box.go
similarity index 79%
rename from vendor/github.com/wcharczuk/go-chart/box.go
rename to vendor/github.com/wcharczuk/go-chart/v2/box.go
index c59ab69..9611ff9 100644
--- a/vendor/github.com/wcharczuk/go-chart/box.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/box.go
@@ -3,8 +3,6 @@ package chart
import (
"fmt"
"math"
-
- util "github.com/wcharczuk/go-chart/util"
)
var (
@@ -91,12 +89,12 @@ func (b Box) GetBottom(defaults ...int) int {
// Width returns the width
func (b Box) Width() int {
- return util.Math.AbsInt(b.Right - b.Left)
+ return AbsInt(b.Right - b.Left)
}
// Height returns the height
func (b Box) Height() int {
- return util.Math.AbsInt(b.Bottom - b.Top)
+ return AbsInt(b.Bottom - b.Top)
}
// Center returns the center of the box
@@ -148,10 +146,10 @@ func (b Box) Equals(other Box) bool {
// Grow grows a box based on another box.
func (b Box) Grow(other Box) Box {
return Box{
- Top: util.Math.MinInt(b.Top, other.Top),
- Left: util.Math.MinInt(b.Left, other.Left),
- Right: util.Math.MaxInt(b.Right, other.Right),
- Bottom: util.Math.MaxInt(b.Bottom, other.Bottom),
+ Top: MinInt(b.Top, other.Top),
+ Left: MinInt(b.Left, other.Left),
+ Right: MaxInt(b.Right, other.Right),
+ Bottom: MaxInt(b.Bottom, other.Bottom),
}
}
@@ -222,10 +220,10 @@ func (b Box) Fit(other Box) Box {
func (b Box) Constrain(other Box) Box {
newBox := b.Clone()
- newBox.Top = util.Math.MaxInt(newBox.Top, other.Top)
- newBox.Left = util.Math.MaxInt(newBox.Left, other.Left)
- newBox.Right = util.Math.MinInt(newBox.Right, other.Right)
- newBox.Bottom = util.Math.MinInt(newBox.Bottom, other.Bottom)
+ newBox.Top = MaxInt(newBox.Top, other.Top)
+ newBox.Left = MaxInt(newBox.Left, other.Left)
+ newBox.Right = MinInt(newBox.Right, other.Right)
+ newBox.Bottom = MinInt(newBox.Bottom, other.Bottom)
return newBox
}
@@ -264,36 +262,36 @@ type BoxCorners struct {
// Box return the BoxCorners as a regular box.
func (bc BoxCorners) Box() Box {
return Box{
- Top: util.Math.MinInt(bc.TopLeft.Y, bc.TopRight.Y),
- Left: util.Math.MinInt(bc.TopLeft.X, bc.BottomLeft.X),
- Right: util.Math.MaxInt(bc.TopRight.X, bc.BottomRight.X),
- Bottom: util.Math.MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y),
+ Top: MinInt(bc.TopLeft.Y, bc.TopRight.Y),
+ Left: MinInt(bc.TopLeft.X, bc.BottomLeft.X),
+ Right: MaxInt(bc.TopRight.X, bc.BottomRight.X),
+ Bottom: MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y),
}
}
// Width returns the width
func (bc BoxCorners) Width() int {
- minLeft := util.Math.MinInt(bc.TopLeft.X, bc.BottomLeft.X)
- maxRight := util.Math.MaxInt(bc.TopRight.X, bc.BottomRight.X)
+ minLeft := MinInt(bc.TopLeft.X, bc.BottomLeft.X)
+ maxRight := MaxInt(bc.TopRight.X, bc.BottomRight.X)
return maxRight - minLeft
}
// Height returns the height
func (bc BoxCorners) Height() int {
- minTop := util.Math.MinInt(bc.TopLeft.Y, bc.TopRight.Y)
- maxBottom := util.Math.MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y)
+ minTop := MinInt(bc.TopLeft.Y, bc.TopRight.Y)
+ maxBottom := MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y)
return maxBottom - minTop
}
// Center returns the center of the box
func (bc BoxCorners) Center() (x, y int) {
- left := util.Math.MeanInt(bc.TopLeft.X, bc.BottomLeft.X)
- right := util.Math.MeanInt(bc.TopRight.X, bc.BottomRight.X)
+ left := MeanInt(bc.TopLeft.X, bc.BottomLeft.X)
+ right := MeanInt(bc.TopRight.X, bc.BottomRight.X)
x = ((right - left) >> 1) + left
- top := util.Math.MeanInt(bc.TopLeft.Y, bc.TopRight.Y)
- bottom := util.Math.MeanInt(bc.BottomLeft.Y, bc.BottomRight.Y)
+ top := MeanInt(bc.TopLeft.Y, bc.TopRight.Y)
+ bottom := MeanInt(bc.BottomLeft.Y, bc.BottomRight.Y)
y = ((bottom - top) >> 1) + top
return
@@ -303,12 +301,12 @@ func (bc BoxCorners) Center() (x, y int) {
func (bc BoxCorners) Rotate(thetaDegrees float64) BoxCorners {
cx, cy := bc.Center()
- thetaRadians := util.Math.DegreesToRadians(thetaDegrees)
+ thetaRadians := DegreesToRadians(thetaDegrees)
- tlx, tly := util.Math.RotateCoordinate(cx, cy, bc.TopLeft.X, bc.TopLeft.Y, thetaRadians)
- trx, try := util.Math.RotateCoordinate(cx, cy, bc.TopRight.X, bc.TopRight.Y, thetaRadians)
- brx, bry := util.Math.RotateCoordinate(cx, cy, bc.BottomRight.X, bc.BottomRight.Y, thetaRadians)
- blx, bly := util.Math.RotateCoordinate(cx, cy, bc.BottomLeft.X, bc.BottomLeft.Y, thetaRadians)
+ tlx, tly := RotateCoordinate(cx, cy, bc.TopLeft.X, bc.TopLeft.Y, thetaRadians)
+ trx, try := RotateCoordinate(cx, cy, bc.TopRight.X, bc.TopRight.Y, thetaRadians)
+ brx, bry := RotateCoordinate(cx, cy, bc.BottomRight.X, bc.BottomRight.Y, thetaRadians)
+ blx, bly := RotateCoordinate(cx, cy, bc.BottomLeft.X, bc.BottomLeft.Y, thetaRadians)
return BoxCorners{
TopLeft: Point{tlx, tly},
diff --git a/vendor/github.com/wcharczuk/go-chart/chart.go b/vendor/github.com/wcharczuk/go-chart/v2/chart.go
similarity index 89%
rename from vendor/github.com/wcharczuk/go-chart/chart.go
rename to vendor/github.com/wcharczuk/go-chart/v2/chart.go
index 83b70ec..5212a43 100644
--- a/vendor/github.com/wcharczuk/go-chart/chart.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/chart.go
@@ -7,7 +7,6 @@ import (
"math"
"github.com/golang/freetype/truetype"
- util "github.com/wcharczuk/go-chart/util"
)
// Chart is what we're drawing.
@@ -33,6 +32,8 @@ type Chart struct {
Series []Series
Elements []Renderable
+
+ Log Logger
}
// GetDPI returns the dpi for the chart.
@@ -75,8 +76,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
if len(c.Series) == 0 {
return errors.New("please provide at least one series")
}
- if visibleSeriesErr := c.checkHasVisibleSeries(); visibleSeriesErr != nil {
- return visibleSeriesErr
+ if err := c.checkHasVisibleSeries(); err != nil {
+ return err
}
c.YAxisSecondary.AxisType = YAxisSecondary
@@ -102,6 +103,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
canvasBox := c.getDefaultCanvasBox()
xf, yf, yfa := c.getValueFormatters()
+ Debugf(c.Log, "chart; canvas box: %v", canvasBox)
+
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
err = c.checkRanges(xr, yr, yra)
@@ -115,6 +118,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
canvasBox = c.getAxesAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xt, yt, yta)
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
+ Debugf(c.Log, "chart; axes adjusted canvas box: %v", canvasBox)
+
// do a second pass in case things haven't settled yet.
xt, yt, yta = c.getAxesTicks(r, xr, yr, yra, xf, yf, yfa)
canvasBox = c.getAxesAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xt, yt, yta)
@@ -125,6 +130,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
canvasBox = c.getAnnotationAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xf, yf, yfa)
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
xt, yt, yta = c.getAxesTicks(r, xr, yr, yra, xf, yf, yfa)
+
+ Debugf(c.Log, "chart; annotation adjusted canvas box: %v", canvasBox)
}
c.drawCanvas(r, canvasBox)
@@ -143,16 +150,14 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
}
func (c Chart) checkHasVisibleSeries() error {
- hasVisibleSeries := false
var style Style
for _, s := range c.Series {
style = s.GetStyle()
- hasVisibleSeries = hasVisibleSeries || (style.IsZero() || style.Show)
- }
- if !hasVisibleSeries {
- return fmt.Errorf("must have (1) visible series; make sure if you set a style, you set .Show = true")
+ if !style.Hidden {
+ return nil
+ }
}
- return nil
+ return fmt.Errorf("chart render; must have (1) visible series")
}
func (c Chart) validateSeries() error {
@@ -176,7 +181,7 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
// note: a possible future optimization is to not scan the series values if
// all axis are represented by either custom ticks or custom ranges.
for _, s := range c.Series {
- if s.GetStyle().IsZero() || s.GetStyle().Show {
+ if !s.GetStyle().Hidden {
seriesAxis := s.GetYAxis()
if bvp, isBoundedValuesProvider := s.(BoundedValuesProvider); isBoundedValuesProvider {
seriesLength := bvp.Len()
@@ -263,11 +268,10 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
yrange.SetMin(miny)
yrange.SetMax(maxy)
- // only round if we're showing the axis
- if c.YAxis.Style.Show {
+ if !c.YAxis.Style.Hidden {
delta := yrange.GetDelta()
- roundTo := util.Math.GetRoundToForDelta(delta)
- rmin, rmax := util.Math.RoundDown(yrange.GetMin(), roundTo), util.Math.RoundUp(yrange.GetMax(), roundTo)
+ roundTo := GetRoundToForDelta(delta)
+ rmin, rmax := RoundDown(yrange.GetMin(), roundTo), RoundUp(yrange.GetMax(), roundTo)
yrange.SetMin(rmin)
yrange.SetMax(rmax)
@@ -286,10 +290,10 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
yrangeAlt.SetMin(minya)
yrangeAlt.SetMax(maxya)
- if c.YAxisSecondary.Style.Show {
+ if !c.YAxisSecondary.Style.Hidden {
delta := yrangeAlt.GetDelta()
- roundTo := util.Math.GetRoundToForDelta(delta)
- rmin, rmax := util.Math.RoundDown(yrangeAlt.GetMin(), roundTo), util.Math.RoundUp(yrangeAlt.GetMax(), roundTo)
+ roundTo := GetRoundToForDelta(delta)
+ rmin, rmax := RoundDown(yrangeAlt.GetMin(), roundTo), RoundUp(yrangeAlt.GetMax(), roundTo)
yrangeAlt.SetMin(rmin)
yrangeAlt.SetMax(rmax)
}
@@ -299,6 +303,7 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
}
func (c Chart) checkRanges(xr, yr, yra Range) error {
+ Debugf(c.Log, "checking xrange: %v", xr)
xDelta := xr.GetDelta()
if math.IsInf(xDelta, 0) {
return errors.New("infinite x-range delta")
@@ -310,6 +315,7 @@ func (c Chart) checkRanges(xr, yr, yra Range) error {
return errors.New("zero x-range delta; there needs to be at least (2) values")
}
+ Debugf(c.Log, "checking yrange: %v", yr)
yDelta := yr.GetDelta()
if math.IsInf(yDelta, 0) {
return errors.New("infinite y-range delta")
@@ -317,11 +323,9 @@ func (c Chart) checkRanges(xr, yr, yra Range) error {
if math.IsNaN(yDelta) {
return errors.New("nan y-range delta")
}
- if yDelta == 0 {
- return errors.New("zero y-range delta")
- }
if c.hasSecondarySeries() {
+ Debugf(c.Log, "checking secondary yrange: %v", yra)
yraDelta := yra.GetDelta()
if math.IsInf(yraDelta, 0) {
return errors.New("infinite secondary y-range delta")
@@ -329,9 +333,6 @@ func (c Chart) checkRanges(xr, yr, yra Range) error {
if math.IsNaN(yraDelta) {
return errors.New("nan secondary y-range delta")
}
- if yraDelta == 0 {
- return errors.New("zero secondary y-range delta")
- }
}
return nil
@@ -367,17 +368,17 @@ func (c Chart) getValueFormatters() (x, y, ya ValueFormatter) {
}
func (c Chart) hasAxes() bool {
- return c.XAxis.Style.Show || c.YAxis.Style.Show || c.YAxisSecondary.Style.Show
+ return !c.XAxis.Style.Hidden || !c.YAxis.Style.Hidden || !c.YAxisSecondary.Style.Hidden
}
func (c Chart) getAxesTicks(r Renderer, xr, yr, yar Range, xf, yf, yfa ValueFormatter) (xticks, yticks, yticksAlt []Tick) {
- if c.XAxis.Style.Show {
+ if !c.XAxis.Style.Hidden {
xticks = c.XAxis.GetTicks(r, xr, c.styleDefaultsAxes(), xf)
}
- if c.YAxis.Style.Show {
+ if !c.YAxis.Style.Hidden {
yticks = c.YAxis.GetTicks(r, yr, c.styleDefaultsAxes(), yf)
}
- if c.YAxisSecondary.Style.Show {
+ if !c.YAxisSecondary.Style.Hidden {
yticksAlt = c.YAxisSecondary.GetTicks(r, yar, c.styleDefaultsAxes(), yfa)
}
return
@@ -385,16 +386,19 @@ func (c Chart) getAxesTicks(r Renderer, xr, yr, yar Range, xf, yf, yfa ValueForm
func (c Chart) getAxesAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr, yra Range, xticks, yticks, yticksAlt []Tick) Box {
axesOuterBox := canvasBox.Clone()
- if c.XAxis.Style.Show {
+ if !c.XAxis.Style.Hidden {
axesBounds := c.XAxis.Measure(r, canvasBox, xr, c.styleDefaultsAxes(), xticks)
+ Debugf(c.Log, "chart; x-axis measured %v", axesBounds)
axesOuterBox = axesOuterBox.Grow(axesBounds)
}
- if c.YAxis.Style.Show {
+ if !c.YAxis.Style.Hidden {
axesBounds := c.YAxis.Measure(r, canvasBox, yr, c.styleDefaultsAxes(), yticks)
+ Debugf(c.Log, "chart; y-axis measured %v", axesBounds)
axesOuterBox = axesOuterBox.Grow(axesBounds)
}
- if c.YAxisSecondary.Style.Show {
+ if !c.YAxisSecondary.Style.Hidden && c.hasSecondarySeries() {
axesBounds := c.YAxisSecondary.Measure(r, canvasBox, yra, c.styleDefaultsAxes(), yticksAlt)
+ Debugf(c.Log, "chart; y-axis secondary measured %v", axesBounds)
axesOuterBox = axesOuterBox.Grow(axesBounds)
}
@@ -411,7 +415,7 @@ func (c Chart) setRangeDomains(canvasBox Box, xr, yr, yra Range) (Range, Range,
func (c Chart) hasAnnotationSeries() bool {
for _, s := range c.Series {
if as, isAnnotationSeries := s.(AnnotationSeries); isAnnotationSeries {
- if as.Style.IsZero() || as.Style.Show {
+ if !as.GetStyle().Hidden {
return true
}
}
@@ -432,7 +436,7 @@ func (c Chart) getAnnotationAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr,
annotationSeriesBox := canvasBox.Clone()
for seriesIndex, s := range c.Series {
if as, isAnnotationSeries := s.(AnnotationSeries); isAnnotationSeries {
- if as.Style.IsZero() || as.Style.Show {
+ if !as.GetStyle().Hidden {
style := c.styleDefaultsSeries(seriesIndex)
var annotationBounds Box
if as.YAxis == YAxisPrimary {
@@ -469,19 +473,19 @@ func (c Chart) drawCanvas(r Renderer, canvasBox Box) {
}
func (c Chart) drawAxes(r Renderer, canvasBox Box, xrange, yrange, yrangeAlt Range, xticks, yticks, yticksAlt []Tick) {
- if c.XAxis.Style.Show {
+ if !c.XAxis.Style.Hidden {
c.XAxis.Render(r, canvasBox, xrange, c.styleDefaultsAxes(), xticks)
}
- if c.YAxis.Style.Show {
+ if !c.YAxis.Style.Hidden {
c.YAxis.Render(r, canvasBox, yrange, c.styleDefaultsAxes(), yticks)
}
- if c.YAxisSecondary.Style.Show {
+ if !c.YAxisSecondary.Style.Hidden {
c.YAxisSecondary.Render(r, canvasBox, yrangeAlt, c.styleDefaultsAxes(), yticksAlt)
}
}
func (c Chart) drawSeries(r Renderer, canvasBox Box, xrange, yrange, yrangeAlt Range, s Series, seriesIndex int) {
- if s.GetStyle().IsZero() || s.GetStyle().Show {
+ if !s.GetStyle().Hidden {
if s.GetYAxis() == YAxisPrimary {
s.Render(r, canvasBox, xrange, yrange, c.styleDefaultsSeries(seriesIndex))
} else if s.GetYAxis() == YAxisSecondary {
@@ -491,7 +495,7 @@ func (c Chart) drawSeries(r Renderer, canvasBox Box, xrange, yrange, yrangeAlt R
}
func (c Chart) drawTitle(r Renderer) {
- if len(c.Title) > 0 && c.TitleStyle.Show {
+ if len(c.Title) > 0 && !c.TitleStyle.Hidden {
r.SetFont(c.TitleStyle.GetFont(c.GetFont()))
r.SetFontColor(c.TitleStyle.GetFontColor(c.GetColorPalette().TextColor()))
titleFontSize := c.TitleStyle.GetFontSize(DefaultTitleFontSize)
diff --git a/vendor/github.com/wcharczuk/go-chart/colors.go b/vendor/github.com/wcharczuk/go-chart/v2/colors.go
similarity index 99%
rename from vendor/github.com/wcharczuk/go-chart/colors.go
rename to vendor/github.com/wcharczuk/go-chart/v2/colors.go
index 87dd4f0..b51f9ea 100644
--- a/vendor/github.com/wcharczuk/go-chart/colors.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/colors.go
@@ -1,6 +1,6 @@
package chart
-import "github.com/wcharczuk/go-chart/drawing"
+import "github.com/wcharczuk/go-chart/v2/drawing"
var (
// ColorWhite is white.
diff --git a/vendor/github.com/wcharczuk/go-chart/concat_series.go b/vendor/github.com/wcharczuk/go-chart/v2/concat_series.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/concat_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/concat_series.go
diff --git a/vendor/github.com/wcharczuk/go-chart/continuous_range.go b/vendor/github.com/wcharczuk/go-chart/v2/continuous_range.go
similarity index 96%
rename from vendor/github.com/wcharczuk/go-chart/continuous_range.go
rename to vendor/github.com/wcharczuk/go-chart/v2/continuous_range.go
index 99fa939..517b727 100644
--- a/vendor/github.com/wcharczuk/go-chart/continuous_range.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/continuous_range.go
@@ -62,6 +62,9 @@ func (r *ContinuousRange) SetDomain(domain int) {
// String returns a simple string for the ContinuousRange.
func (r ContinuousRange) String() string {
+ if r.GetDelta() == 0 {
+ return "ContinuousRange [empty]"
+ }
return fmt.Sprintf("ContinuousRange [%.2f,%.2f] => %d", r.Min, r.Max, r.Domain)
}
diff --git a/vendor/github.com/wcharczuk/go-chart/continuous_series.go b/vendor/github.com/wcharczuk/go-chart/v2/continuous_series.go
similarity index 75%
rename from vendor/github.com/wcharczuk/go-chart/continuous_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/continuous_series.go
index bca80de..73c7ab7 100644
--- a/vendor/github.com/wcharczuk/go-chart/continuous_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/continuous_series.go
@@ -2,6 +2,13 @@ package chart
import "fmt"
+// Interface Assertions.
+var (
+ _ Series = (*ContinuousSeries)(nil)
+ _ FirstValuesProvider = (*ContinuousSeries)(nil)
+ _ LastValuesProvider = (*ContinuousSeries)(nil)
+)
+
// ContinuousSeries represents a line on a chart.
type ContinuousSeries struct {
Name string
@@ -36,6 +43,11 @@ func (cs ContinuousSeries) GetValues(index int) (float64, float64) {
return cs.XValues[index], cs.YValues[index]
}
+// GetFirstValues gets the first x,y values.
+func (cs ContinuousSeries) GetFirstValues() (float64, float64) {
+ return cs.XValues[0], cs.YValues[0]
+}
+
// GetLastValues gets the last x,y values.
func (cs ContinuousSeries) GetLastValues() (float64, float64) {
return cs.XValues[len(cs.XValues)-1], cs.YValues[len(cs.YValues)-1]
@@ -70,11 +82,15 @@ func (cs ContinuousSeries) Render(r Renderer, canvasBox Box, xrange, yrange Rang
// Validate validates the series.
func (cs ContinuousSeries) Validate() error {
if len(cs.XValues) == 0 {
- return fmt.Errorf("continuous series must have xvalues set")
+ return fmt.Errorf("continuous series; must have xvalues set")
}
if len(cs.YValues) == 0 {
- return fmt.Errorf("continuous series must have yvalues set")
+ return fmt.Errorf("continuous series; must have yvalues set")
+ }
+
+ if len(cs.XValues) != len(cs.YValues) {
+ return fmt.Errorf("continuous series; must have same length xvalues as yvalues")
}
return nil
}
diff --git a/vendor/github.com/wcharczuk/go-chart/defaults.go b/vendor/github.com/wcharczuk/go-chart/v2/defaults.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/defaults.go
rename to vendor/github.com/wcharczuk/go-chart/v2/defaults.go
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/donut_chart.go b/vendor/github.com/wcharczuk/go-chart/v2/donut_chart.go
new file mode 100644
index 0000000..f5a7854
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/donut_chart.go
@@ -0,0 +1,315 @@
+package chart
+
+import (
+ "errors"
+ "fmt"
+ "io"
+
+ "github.com/golang/freetype/truetype"
+)
+
+// DonutChart is a chart that draws sections of a circle based on percentages with an hole.
+type DonutChart struct {
+ Title string
+ TitleStyle Style
+
+ ColorPalette ColorPalette
+
+ Width int
+ Height int
+ DPI float64
+
+ Background Style
+ Canvas Style
+ SliceStyle Style
+
+ Font *truetype.Font
+ defaultFont *truetype.Font
+
+ Values []Value
+ Elements []Renderable
+}
+
+// GetDPI returns the dpi for the chart.
+func (pc DonutChart) GetDPI(defaults ...float64) float64 {
+ if pc.DPI == 0 {
+ if len(defaults) > 0 {
+ return defaults[0]
+ }
+ return DefaultDPI
+ }
+ return pc.DPI
+}
+
+// GetFont returns the text font.
+func (pc DonutChart) GetFont() *truetype.Font {
+ if pc.Font == nil {
+ return pc.defaultFont
+ }
+ return pc.Font
+}
+
+// GetWidth returns the chart width or the default value.
+func (pc DonutChart) GetWidth() int {
+ if pc.Width == 0 {
+ return DefaultChartWidth
+ }
+ return pc.Width
+}
+
+// GetHeight returns the chart height or the default value.
+func (pc DonutChart) GetHeight() int {
+ if pc.Height == 0 {
+ return DefaultChartWidth
+ }
+ return pc.Height
+}
+
+// Render renders the chart with the given renderer to the given io.Writer.
+func (pc DonutChart) Render(rp RendererProvider, w io.Writer) error {
+ if len(pc.Values) == 0 {
+ return errors.New("please provide at least one value")
+ }
+
+ r, err := rp(pc.GetWidth(), pc.GetHeight())
+ if err != nil {
+ return err
+ }
+
+ if pc.Font == nil {
+ defaultFont, err := GetDefaultFont()
+ if err != nil {
+ return err
+ }
+ pc.defaultFont = defaultFont
+ }
+ r.SetDPI(pc.GetDPI(DefaultDPI))
+
+ canvasBox := pc.getDefaultCanvasBox()
+ canvasBox = pc.getCircleAdjustedCanvasBox(canvasBox)
+
+ pc.drawBackground(r)
+ pc.drawCanvas(r, canvasBox)
+
+ finalValues, err := pc.finalizeValues(pc.Values)
+ if err != nil {
+ return err
+ }
+ pc.drawSlices(r, canvasBox, finalValues)
+ pc.drawTitle(r)
+ for _, a := range pc.Elements {
+ a(r, canvasBox, pc.styleDefaultsElements())
+ }
+
+ return r.Save(w)
+}
+
+func (pc DonutChart) drawBackground(r Renderer) {
+ Draw.Box(r, Box{
+ Right: pc.GetWidth(),
+ Bottom: pc.GetHeight(),
+ }, pc.getBackgroundStyle())
+}
+
+func (pc DonutChart) drawCanvas(r Renderer, canvasBox Box) {
+ Draw.Box(r, canvasBox, pc.getCanvasStyle())
+}
+
+func (pc DonutChart) drawTitle(r Renderer) {
+ if len(pc.Title) > 0 && !pc.TitleStyle.Hidden {
+ Draw.TextWithin(r, pc.Title, pc.Box(), pc.styleDefaultsTitle())
+ }
+}
+
+func (pc DonutChart) drawSlices(r Renderer, canvasBox Box, values []Value) {
+ cx, cy := canvasBox.Center()
+ diameter := MinInt(canvasBox.Width(), canvasBox.Height())
+ radius := float64(diameter>>1) / 1.1
+ labelRadius := (radius * 2.83) / 3.0
+
+ // draw the donut slices
+ var rads, delta, delta2, total float64
+ var lx, ly int
+
+ if len(values) == 1 {
+ pc.styleDonutChartValue(0).WriteToRenderer(r)
+ r.MoveTo(cx, cy)
+ r.Circle(radius, cx, cy)
+ } else {
+ for index, v := range values {
+ v.Style.InheritFrom(pc.styleDonutChartValue(index)).WriteToRenderer(r)
+ r.MoveTo(cx, cy)
+ rads = PercentToRadians(total)
+ delta = PercentToRadians(v.Value)
+
+ r.ArcTo(cx, cy, (radius / 1.25), (radius / 1.25), rads, delta)
+
+ r.LineTo(cx, cy)
+ r.Close()
+ r.FillStroke()
+ total = total + v.Value
+ }
+ }
+
+ //making the donut hole
+ v := Value{Value: 100, Label: "center"}
+ styletemp := pc.SliceStyle.InheritFrom(Style{
+ StrokeColor: ColorWhite, StrokeWidth: 4.0, FillColor: ColorWhite, FontColor: ColorWhite, //Font: pc.GetFont(),//FontSize: pc.getScaledFontSize(),
+ })
+ v.Style.InheritFrom(styletemp).WriteToRenderer(r)
+ r.MoveTo(cx, cy)
+ r.ArcTo(cx, cy, (radius / 3.5), (radius / 3.5), DegreesToRadians(0), DegreesToRadians(359))
+ r.LineTo(cx, cy)
+ r.Close()
+ r.FillStroke()
+
+ // draw the labels
+ total = 0
+ for index, v := range values {
+ v.Style.InheritFrom(pc.styleDonutChartValue(index)).WriteToRenderer(r)
+ if len(v.Label) > 0 {
+ delta2 = PercentToRadians(total + (v.Value / 2.0))
+ delta2 = RadianAdd(delta2, _pi2)
+ lx, ly = CirclePoint(cx, cy, labelRadius, delta2)
+
+ tb := r.MeasureText(v.Label)
+ lx = lx - (tb.Width() >> 1)
+ ly = ly + (tb.Height() >> 1)
+
+ r.Text(v.Label, lx, ly)
+ }
+ total = total + v.Value
+ }
+}
+
+func (pc DonutChart) finalizeValues(values []Value) ([]Value, error) {
+ finalValues := Values(values).Normalize()
+ if len(finalValues) == 0 {
+ return nil, fmt.Errorf("donut chart must contain at least (1) non-zero value")
+ }
+ return finalValues, nil
+}
+
+func (pc DonutChart) getDefaultCanvasBox() Box {
+ return pc.Box()
+}
+
+func (pc DonutChart) getCircleAdjustedCanvasBox(canvasBox Box) Box {
+ circleDiameter := MinInt(canvasBox.Width(), canvasBox.Height())
+
+ square := Box{
+ Right: circleDiameter,
+ Bottom: circleDiameter,
+ }
+
+ return canvasBox.Fit(square)
+}
+
+func (pc DonutChart) getBackgroundStyle() Style {
+ return pc.Background.InheritFrom(pc.styleDefaultsBackground())
+}
+
+func (pc DonutChart) getCanvasStyle() Style {
+ return pc.Canvas.InheritFrom(pc.styleDefaultsCanvas())
+}
+
+func (pc DonutChart) styleDefaultsCanvas() Style {
+ return Style{
+ FillColor: pc.GetColorPalette().CanvasColor(),
+ StrokeColor: pc.GetColorPalette().CanvasStrokeColor(),
+ StrokeWidth: DefaultStrokeWidth,
+ }
+}
+
+func (pc DonutChart) styleDefaultsDonutChartValue() Style {
+ return Style{
+ StrokeColor: pc.GetColorPalette().TextColor(),
+ StrokeWidth: 4.0,
+ FillColor: pc.GetColorPalette().TextColor(),
+ }
+}
+
+func (pc DonutChart) styleDonutChartValue(index int) Style {
+ return pc.SliceStyle.InheritFrom(Style{
+ StrokeColor: ColorWhite,
+ StrokeWidth: 4.0,
+ FillColor: pc.GetColorPalette().GetSeriesColor(index),
+ FontSize: pc.getScaledFontSize(),
+ FontColor: pc.GetColorPalette().TextColor(),
+ Font: pc.GetFont(),
+ })
+}
+
+func (pc DonutChart) getScaledFontSize() float64 {
+ effectiveDimension := MinInt(pc.GetWidth(), pc.GetHeight())
+ if effectiveDimension >= 2048 {
+ return 48.0
+ } else if effectiveDimension >= 1024 {
+ return 24.0
+ } else if effectiveDimension > 512 {
+ return 18.0
+ } else if effectiveDimension > 256 {
+ return 12.0
+ }
+ return 10.0
+}
+
+func (pc DonutChart) styleDefaultsBackground() Style {
+ return Style{
+ FillColor: pc.GetColorPalette().BackgroundColor(),
+ StrokeColor: pc.GetColorPalette().BackgroundStrokeColor(),
+ StrokeWidth: DefaultStrokeWidth,
+ }
+}
+
+func (pc DonutChart) styleDefaultsElements() Style {
+ return Style{
+ Font: pc.GetFont(),
+ }
+}
+
+func (pc DonutChart) styleDefaultsTitle() Style {
+ return pc.TitleStyle.InheritFrom(Style{
+ FontColor: pc.GetColorPalette().TextColor(),
+ Font: pc.GetFont(),
+ FontSize: pc.getTitleFontSize(),
+ TextHorizontalAlign: TextHorizontalAlignCenter,
+ TextVerticalAlign: TextVerticalAlignTop,
+ TextWrap: TextWrapWord,
+ })
+}
+
+func (pc DonutChart) getTitleFontSize() float64 {
+ effectiveDimension := MinInt(pc.GetWidth(), pc.GetHeight())
+ if effectiveDimension >= 2048 {
+ return 48
+ } else if effectiveDimension >= 1024 {
+ return 24
+ } else if effectiveDimension >= 512 {
+ return 18
+ } else if effectiveDimension >= 256 {
+ return 12
+ }
+ return 10
+}
+
+// GetColorPalette returns the color palette for the chart.
+func (pc DonutChart) GetColorPalette() ColorPalette {
+ if pc.ColorPalette != nil {
+ return pc.ColorPalette
+ }
+ return AlternateColorPalette
+}
+
+// Box returns the chart bounds as a box.
+func (pc DonutChart) Box() Box {
+ dpr := pc.Background.Padding.GetRight(DefaultBackgroundPadding.Right)
+ dpb := pc.Background.Padding.GetBottom(DefaultBackgroundPadding.Bottom)
+
+ return Box{
+ Top: pc.Background.Padding.GetTop(DefaultBackgroundPadding.Top),
+ Left: pc.Background.Padding.GetLeft(DefaultBackgroundPadding.Left),
+ Right: pc.GetWidth() - dpr,
+ Bottom: pc.GetHeight() - dpb,
+ }
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/draw.go b/vendor/github.com/wcharczuk/go-chart/v2/draw.go
similarity index 97%
rename from vendor/github.com/wcharczuk/go-chart/draw.go
rename to vendor/github.com/wcharczuk/go-chart/v2/draw.go
index ef79dc6..e188079 100644
--- a/vendor/github.com/wcharczuk/go-chart/draw.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/draw.go
@@ -2,8 +2,6 @@ package chart
import (
"math"
-
- util "github.com/wcharczuk/go-chart/util"
)
var (
@@ -40,8 +38,8 @@ func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style
y = cb - yrange.Translate(vy)
r.LineTo(x, y)
}
- r.LineTo(x, util.Math.MinInt(cb, cb-yv0))
- r.LineTo(x0, util.Math.MinInt(cb, cb-yv0))
+ r.LineTo(x, MinInt(cb, cb-yv0))
+ r.LineTo(x0, MinInt(cb, cb-yv0))
r.LineTo(x0, y0)
r.Fill()
}
@@ -298,8 +296,10 @@ func (d draw) TextWithin(r Renderer, text string, box Box, style Style) {
switch style.GetTextVerticalAlign() {
case TextVerticalAlignBottom, TextVerticalAlignBaseline: // i have to build better baseline handling into measure text
y = y - linesBox.Height()
- case TextVerticalAlignMiddle, TextVerticalAlignMiddleBaseline:
- y = (y - linesBox.Height()) >> 1
+ case TextVerticalAlignMiddle:
+ y = y + (box.Height() >> 1) - (linesBox.Height() >> 1)
+ case TextVerticalAlignMiddleBaseline:
+ y = y + (box.Height() >> 1) - linesBox.Height()
}
var tx, ty int
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/README.md b/vendor/github.com/wcharczuk/go-chart/v2/drawing/README.md
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/README.md
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/README.md
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/color.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/color.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/color.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/color.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/constants.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/constants.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/constants.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/constants.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/curve.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/curve.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/curve.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/curve.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/dasher.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/dasher.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/dasher.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/dasher.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/demux_flattener.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/demux_flattener.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/demux_flattener.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/demux_flattener.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/drawing.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/drawing.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/drawing.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/drawing.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/flattener.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/flattener.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/flattener.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/flattener.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/free_type_path.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/free_type_path.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/free_type_path.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/free_type_path.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/graphic_context.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/graphic_context.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/graphic_context.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/graphic_context.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/image_filter.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/image_filter.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/image_filter.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/image_filter.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/line.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/line.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/line.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/line.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/matrix.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/matrix.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/matrix.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/matrix.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/painter.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/painter.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/painter.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/painter.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/path.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/path.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/path.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/path.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/raster_graphic_context.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/raster_graphic_context.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/raster_graphic_context.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/raster_graphic_context.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/stack_graphic_context.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/stack_graphic_context.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/stack_graphic_context.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/stack_graphic_context.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/stroker.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/stroker.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/stroker.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/stroker.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/text.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/text.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/text.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/text.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/transformer.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/transformer.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/transformer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/transformer.go
diff --git a/vendor/github.com/wcharczuk/go-chart/drawing/util.go b/vendor/github.com/wcharczuk/go-chart/v2/drawing/util.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/drawing/util.go
rename to vendor/github.com/wcharczuk/go-chart/v2/drawing/util.go
diff --git a/vendor/github.com/wcharczuk/go-chart/ema_series.go b/vendor/github.com/wcharczuk/go-chart/v2/ema_series.go
similarity index 85%
rename from vendor/github.com/wcharczuk/go-chart/ema_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/ema_series.go
index ceaec39..44415b5 100644
--- a/vendor/github.com/wcharczuk/go-chart/ema_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/ema_series.go
@@ -7,6 +7,13 @@ const (
DefaultEMAPeriod = 12
)
+// Interface Assertions.
+var (
+ _ Series = (*EMASeries)(nil)
+ _ FirstValuesProvider = (*EMASeries)(nil)
+ _ LastValuesProvider = (*EMASeries)(nil)
+)
+
// EMASeries is a computed series.
type EMASeries struct {
Name string
@@ -66,6 +73,19 @@ func (ema *EMASeries) GetValues(index int) (x, y float64) {
return
}
+// GetFirstValues computes the first moving average value.
+func (ema *EMASeries) GetFirstValues() (x, y float64) {
+ if ema.InnerSeries == nil {
+ return
+ }
+ if len(ema.cache) == 0 {
+ ema.ensureCachedValues()
+ }
+ x, _ = ema.InnerSeries.GetValues(0)
+ y = ema.cache[0]
+ return
+}
+
// GetLastValues computes the last moving average value but walking back window size samples,
// and recomputing the last moving average chunk.
func (ema *EMASeries) GetLastValues() (x, y float64) {
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/fileutil.go b/vendor/github.com/wcharczuk/go-chart/v2/fileutil.go
new file mode 100644
index 0000000..f1a7768
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/fileutil.go
@@ -0,0 +1,49 @@
+package chart
+
+import (
+ "bufio"
+ "io"
+ "os"
+)
+
+// ReadLines reads a file and calls the handler for each line.
+func ReadLines(filePath string, handler func(string) error) error {
+ f, err := os.Open(filePath)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ scanner := bufio.NewScanner(f)
+ for scanner.Scan() {
+ line := scanner.Text()
+ err = handler(line)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// ReadChunks reads a file in `chunkSize` pieces, dispatched to the handler.
+func ReadChunks(filePath string, chunkSize int, handler func([]byte) error) error {
+ f, err := os.Open(filePath)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ chunk := make([]byte, chunkSize)
+ for {
+ readBytes, err := f.Read(chunk)
+ if err == io.EOF {
+ break
+ }
+ readData := chunk[:readBytes]
+ err = handler(readData)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/first_value_annotation.go b/vendor/github.com/wcharczuk/go-chart/v2/first_value_annotation.go
new file mode 100644
index 0000000..2b214b3
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/first_value_annotation.go
@@ -0,0 +1,37 @@
+package chart
+
+import "fmt"
+
+// FirstValueAnnotation returns an annotation series of just the first value of a value provider as an annotation.
+func FirstValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
+ var vf ValueFormatter
+ if len(vfs) > 0 {
+ vf = vfs[0]
+ } else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
+ _, vf = typed.GetValueFormatters()
+ } else {
+ vf = FloatValueFormatter
+ }
+
+ var firstValue Value2
+ if typed, isTyped := innerSeries.(FirstValuesProvider); isTyped {
+ firstValue.XValue, firstValue.YValue = typed.GetFirstValues()
+ firstValue.Label = vf(firstValue.YValue)
+ } else {
+ firstValue.XValue, firstValue.YValue = innerSeries.GetValues(0)
+ firstValue.Label = vf(firstValue.YValue)
+ }
+
+ var seriesName string
+ var seriesStyle Style
+ if typed, isTyped := innerSeries.(Series); isTyped {
+ seriesName = fmt.Sprintf("%s - First Value", typed.GetName())
+ seriesStyle = typed.GetStyle()
+ }
+
+ return AnnotationSeries{
+ Name: seriesName,
+ Style: seriesStyle,
+ Annotations: []Value2{firstValue},
+ }
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/font.go b/vendor/github.com/wcharczuk/go-chart/v2/font.go
similarity index 92%
rename from vendor/github.com/wcharczuk/go-chart/font.go
rename to vendor/github.com/wcharczuk/go-chart/v2/font.go
index a82880c..401143b 100644
--- a/vendor/github.com/wcharczuk/go-chart/font.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/font.go
@@ -4,7 +4,7 @@ import (
"sync"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/roboto"
+ "github.com/wcharczuk/go-chart/v2/roboto"
)
var (
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/go.mod b/vendor/github.com/wcharczuk/go-chart/v2/go.mod
new file mode 100644
index 0000000..3824b21
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/go.mod
@@ -0,0 +1,8 @@
+module github.com/wcharczuk/go-chart/v2
+
+go 1.15
+
+require (
+ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
+ golang.org/x/image v0.0.0-20200927104501-e162460cd6b5
+)
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/go.sum b/vendor/github.com/wcharczuk/go-chart/v2/go.sum
new file mode 100644
index 0000000..066121a
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/go.sum
@@ -0,0 +1,5 @@
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
+github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
+golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
+golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/vendor/github.com/wcharczuk/go-chart/grid_line.go b/vendor/github.com/wcharczuk/go-chart/v2/grid_line.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/grid_line.go
rename to vendor/github.com/wcharczuk/go-chart/v2/grid_line.go
diff --git a/vendor/github.com/wcharczuk/go-chart/histogram_series.go b/vendor/github.com/wcharczuk/go-chart/v2/histogram_series.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/histogram_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/histogram_series.go
diff --git a/vendor/github.com/wcharczuk/go-chart/image_writer.go b/vendor/github.com/wcharczuk/go-chart/v2/image_writer.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/image_writer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/image_writer.go
diff --git a/vendor/github.com/wcharczuk/go-chart/jet.go b/vendor/github.com/wcharczuk/go-chart/v2/jet.go
similarity index 93%
rename from vendor/github.com/wcharczuk/go-chart/jet.go
rename to vendor/github.com/wcharczuk/go-chart/v2/jet.go
index a948525..cce8c85 100644
--- a/vendor/github.com/wcharczuk/go-chart/jet.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/jet.go
@@ -1,6 +1,6 @@
package chart
-import "github.com/wcharczuk/go-chart/drawing"
+import "github.com/wcharczuk/go-chart/v2/drawing"
// Jet is a color map provider based on matlab's jet color map.
func Jet(v, vmin, vmax float64) drawing.Color {
diff --git a/vendor/github.com/wcharczuk/go-chart/last_value_annotation_series.go b/vendor/github.com/wcharczuk/go-chart/v2/last_value_annotation_series.go
similarity index 81%
rename from vendor/github.com/wcharczuk/go-chart/last_value_annotation_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/last_value_annotation_series.go
index f3d4b46..550c367 100644
--- a/vendor/github.com/wcharczuk/go-chart/last_value_annotation_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/last_value_annotation_series.go
@@ -2,8 +2,8 @@ package chart
import "fmt"
-// LastValueAnnotation returns an annotation series of just the last value of a value provider.
-func LastValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
+// LastValueAnnotationSeries returns an annotation series of just the last value of a value provider.
+func LastValueAnnotationSeries(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
var vf ValueFormatter
if len(vfs) > 0 {
vf = vfs[0]
diff --git a/vendor/github.com/wcharczuk/go-chart/legend.go b/vendor/github.com/wcharczuk/go-chart/v2/legend.go
similarity index 94%
rename from vendor/github.com/wcharczuk/go-chart/legend.go
rename to vendor/github.com/wcharczuk/go-chart/v2/legend.go
index 42c11a3..fbd48ed 100644
--- a/vendor/github.com/wcharczuk/go-chart/legend.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/legend.go
@@ -1,8 +1,7 @@
package chart
import (
- "github.com/wcharczuk/go-chart/drawing"
- "github.com/wcharczuk/go-chart/util"
+ "github.com/wcharczuk/go-chart/v2/drawing"
)
// Legend returns a legend renderable function.
@@ -36,7 +35,7 @@ func Legend(c *Chart, userDefaults ...Style) Renderable {
var labels []string
var lines []Style
for index, s := range c.Series {
- if s.GetStyle().IsZero() || s.GetStyle().Show {
+ if !s.GetStyle().Hidden {
if _, isAnnotationSeries := s.(AnnotationSeries); !isAnnotationSeries {
labels = append(labels, s.GetName())
lines = append(lines, s.GetStyle().InheritFrom(c.styleDefaultsSeries(index)))
@@ -69,7 +68,7 @@ func Legend(c *Chart, userDefaults ...Style) Renderable {
}
legendContent.Bottom += tb.Height()
right := legendContent.Left + tb.Width() + lineTextGap + lineLengthMinimum
- legendContent.Right = util.Math.MaxInt(legendContent.Right, right)
+ legendContent.Right = MaxInt(legendContent.Right, right)
labelCount++
}
}
@@ -150,7 +149,7 @@ func LegendThin(c *Chart, userDefaults ...Style) Renderable {
var labels []string
var lines []Style
for index, s := range c.Series {
- if s.GetStyle().IsZero() || s.GetStyle().Show {
+ if !s.GetStyle().Hidden {
if _, isAnnotationSeries := s.(AnnotationSeries); !isAnnotationSeries {
labels = append(labels, s.GetName())
lines = append(lines, s.GetStyle().InheritFrom(c.styleDefaultsSeries(index)))
@@ -164,8 +163,8 @@ func LegendThin(c *Chart, userDefaults ...Style) Renderable {
for x := 0; x < len(labels); x++ {
if len(labels[x]) > 0 {
textBox = r.MeasureText(labels[x])
- textHeight = util.Math.MaxInt(textBox.Height(), textHeight)
- textWidth = util.Math.MaxInt(textBox.Width(), textWidth)
+ textHeight = MaxInt(textBox.Height(), textHeight)
+ textWidth = MaxInt(textBox.Width(), textWidth)
}
}
@@ -248,7 +247,7 @@ func LegendLeft(c *Chart, userDefaults ...Style) Renderable {
var labels []string
var lines []Style
for index, s := range c.Series {
- if s.GetStyle().IsZero() || s.GetStyle().Show {
+ if !s.GetStyle().Hidden {
if _, isAnnotationSeries := s.(AnnotationSeries); !isAnnotationSeries {
labels = append(labels, s.GetName())
lines = append(lines, s.GetStyle().InheritFrom(c.styleDefaultsSeries(index)))
@@ -281,7 +280,7 @@ func LegendLeft(c *Chart, userDefaults ...Style) Renderable {
}
legendContent.Bottom += tb.Height()
right := legendContent.Left + tb.Width() + lineTextGap + lineLengthMinimum
- legendContent.Right = util.Math.MaxInt(legendContent.Right, right)
+ legendContent.Right = MaxInt(legendContent.Right, right)
labelCount++
}
}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/linear_coefficient_provider.go b/vendor/github.com/wcharczuk/go-chart/v2/linear_coefficient_provider.go
new file mode 100644
index 0000000..9701f6b
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/linear_coefficient_provider.go
@@ -0,0 +1,42 @@
+package chart
+
+// LinearCoefficientProvider is a type that returns linear cofficients.
+type LinearCoefficientProvider interface {
+ Coefficients() (m, b, stdev, avg float64)
+}
+
+// LinearCoefficients returns a fixed linear coefficient pair.
+func LinearCoefficients(m, b float64) LinearCoefficientSet {
+ return LinearCoefficientSet{
+ M: m,
+ B: b,
+ }
+}
+
+// NormalizedLinearCoefficients returns a fixed linear coefficient pair.
+func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet {
+ return LinearCoefficientSet{
+ M: m,
+ B: b,
+ StdDev: stdev,
+ Avg: avg,
+ }
+}
+
+// LinearCoefficientSet is the m and b values for the linear equation in the form:
+// y = (m*x) + b
+type LinearCoefficientSet struct {
+ M float64
+ B float64
+ StdDev float64
+ Avg float64
+}
+
+// Coefficients returns the coefficients.
+func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) {
+ m = lcs.M
+ b = lcs.B
+ stdev = lcs.StdDev
+ avg = lcs.Avg
+ return
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/linear_regression_series.go b/vendor/github.com/wcharczuk/go-chart/v2/linear_regression_series.go
similarity index 70%
rename from vendor/github.com/wcharczuk/go-chart/linear_regression_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/linear_regression_series.go
index 13c3cb0..8ff8b1a 100644
--- a/vendor/github.com/wcharczuk/go-chart/linear_regression_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/linear_regression_series.go
@@ -2,9 +2,14 @@ package chart
import (
"fmt"
+)
- "github.com/wcharczuk/go-chart/seq"
- util "github.com/wcharczuk/go-chart/util"
+// Interface Assertions.
+var (
+ _ Series = (*LinearRegressionSeries)(nil)
+ _ FirstValuesProvider = (*LinearRegressionSeries)(nil)
+ _ LastValuesProvider = (*LinearRegressionSeries)(nil)
+ _ LinearCoefficientProvider = (*LinearRegressionSeries)(nil)
)
// LinearRegressionSeries is a series that plots the n-nearest neighbors
@@ -24,6 +29,19 @@ type LinearRegressionSeries struct {
stddevx float64
}
+// Coefficients returns the linear coefficients for the series.
+func (lrs LinearRegressionSeries) Coefficients() (m, b, stdev, avg float64) {
+ if lrs.IsZero() {
+ lrs.computeCoefficients()
+ }
+
+ m = lrs.m
+ b = lrs.b
+ stdev = lrs.stddevx
+ avg = lrs.avgx
+ return
+}
+
// GetName returns the name of the time series.
func (lrs LinearRegressionSeries) GetName() string {
return lrs.Name
@@ -41,7 +59,7 @@ func (lrs LinearRegressionSeries) GetYAxis() YAxisType {
// Len returns the number of elements in the series.
func (lrs LinearRegressionSeries) Len() int {
- return util.Math.MinInt(lrs.GetLimit(), lrs.InnerSeries.Len()-lrs.GetOffset())
+ return MinInt(lrs.GetLimit(), lrs.InnerSeries.Len()-lrs.GetOffset())
}
// GetLimit returns the window size.
@@ -56,7 +74,7 @@ func (lrs LinearRegressionSeries) GetLimit() int {
func (lrs LinearRegressionSeries) GetEndIndex() int {
windowEnd := lrs.GetOffset() + lrs.GetLimit()
innerSeriesLastIndex := lrs.InnerSeries.Len() - 1
- return util.Math.MinInt(windowEnd, innerSeriesLastIndex)
+ return MinInt(windowEnd, innerSeriesLastIndex)
}
// GetOffset returns the data offset.
@@ -72,22 +90,35 @@ func (lrs *LinearRegressionSeries) GetValues(index int) (x, y float64) {
if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
return
}
- if lrs.m == 0 && lrs.b == 0 {
+ if lrs.IsZero() {
lrs.computeCoefficients()
}
offset := lrs.GetOffset()
- effectiveIndex := util.Math.MinInt(index+offset, lrs.InnerSeries.Len())
+ effectiveIndex := MinInt(index+offset, lrs.InnerSeries.Len())
x, y = lrs.InnerSeries.GetValues(effectiveIndex)
y = (lrs.m * lrs.normalize(x)) + lrs.b
return
}
+// GetFirstValues computes the first linear regression value.
+func (lrs *LinearRegressionSeries) GetFirstValues() (x, y float64) {
+ if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
+ return
+ }
+ if lrs.IsZero() {
+ lrs.computeCoefficients()
+ }
+ x, y = lrs.InnerSeries.GetValues(0)
+ y = (lrs.m * lrs.normalize(x)) + lrs.b
+ return
+}
+
// GetLastValues computes the last linear regression value.
func (lrs *LinearRegressionSeries) GetLastValues() (x, y float64) {
if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
return
}
- if lrs.m == 0 && lrs.b == 0 {
+ if lrs.IsZero() {
lrs.computeCoefficients()
}
endIndex := lrs.GetEndIndex()
@@ -96,6 +127,29 @@ func (lrs *LinearRegressionSeries) GetLastValues() (x, y float64) {
return
}
+// Render renders the series.
+func (lrs *LinearRegressionSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
+ style := lrs.Style.InheritFrom(defaults)
+ Draw.LineSeries(r, canvasBox, xrange, yrange, style, lrs)
+}
+
+// Validate validates the series.
+func (lrs *LinearRegressionSeries) Validate() error {
+ if lrs.InnerSeries == nil {
+ return fmt.Errorf("linear regression series requires InnerSeries to be set")
+ }
+ return nil
+}
+
+// IsZero returns if we've computed the coefficients or not.
+func (lrs *LinearRegressionSeries) IsZero() bool {
+ return lrs.m == 0 && lrs.b == 0
+}
+
+//
+// internal helpers
+//
+
func (lrs *LinearRegressionSeries) normalize(xvalue float64) float64 {
return (xvalue - lrs.avgx) / lrs.stddevx
}
@@ -107,14 +161,14 @@ func (lrs *LinearRegressionSeries) computeCoefficients() {
p := float64(endIndex - startIndex)
- xvalues := seq.NewBufferWithCapacity(lrs.Len())
+ xvalues := NewValueBufferWithCapacity(lrs.Len())
for index := startIndex; index < endIndex; index++ {
x, _ := lrs.InnerSeries.GetValues(index)
xvalues.Enqueue(x)
}
- lrs.avgx = seq.Seq{Provider: xvalues}.Average()
- lrs.stddevx = seq.Seq{Provider: xvalues}.StdDev()
+ lrs.avgx = Seq{xvalues}.Average()
+ lrs.stddevx = Seq{xvalues}.StdDev()
var sumx, sumy, sumxx, sumxy float64
for index := startIndex; index < endIndex; index++ {
@@ -131,17 +185,3 @@ func (lrs *LinearRegressionSeries) computeCoefficients() {
lrs.m = (p*sumxy - sumx*sumy) / (p*sumxx - sumx*sumx)
lrs.b = (sumy / p) - (lrs.m * sumx / p)
}
-
-// Render renders the series.
-func (lrs *LinearRegressionSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
- style := lrs.Style.InheritFrom(defaults)
- Draw.LineSeries(r, canvasBox, xrange, yrange, style, lrs)
-}
-
-// Validate validates the series.
-func (lrs *LinearRegressionSeries) Validate() error {
- if lrs.InnerSeries == nil {
- return fmt.Errorf("linear regression series requires InnerSeries to be set")
- }
- return nil
-}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/linear_sequence.go b/vendor/github.com/wcharczuk/go-chart/v2/linear_sequence.go
new file mode 100644
index 0000000..dda761b
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/linear_sequence.go
@@ -0,0 +1,73 @@
+package chart
+
+// LinearRange returns an array of values representing the range from start to end, incremented by 1.0.
+func LinearRange(start, end float64) []float64 {
+ return Seq{NewLinearSequence().WithStart(start).WithEnd(end).WithStep(1.0)}.Values()
+}
+
+// LinearRangeWithStep returns the array values of a linear seq with a given start, end and optional step.
+func LinearRangeWithStep(start, end, step float64) []float64 {
+ return Seq{NewLinearSequence().WithStart(start).WithEnd(end).WithStep(step)}.Values()
+}
+
+// NewLinearSequence returns a new linear generator.
+func NewLinearSequence() *LinearSeq {
+ return &LinearSeq{step: 1.0}
+}
+
+// LinearSeq is a stepwise generator.
+type LinearSeq struct {
+ start float64
+ end float64
+ step float64
+}
+
+// Start returns the start value.
+func (lg LinearSeq) Start() float64 {
+ return lg.start
+}
+
+// End returns the end value.
+func (lg LinearSeq) End() float64 {
+ return lg.end
+}
+
+// Step returns the step value.
+func (lg LinearSeq) Step() float64 {
+ return lg.step
+}
+
+// Len returns the number of elements in the seq.
+func (lg LinearSeq) Len() int {
+ if lg.start < lg.end {
+ return int((lg.end-lg.start)/lg.step) + 1
+ }
+ return int((lg.start-lg.end)/lg.step) + 1
+}
+
+// GetValue returns the value at a given index.
+func (lg LinearSeq) GetValue(index int) float64 {
+ fi := float64(index)
+ if lg.start < lg.end {
+ return lg.start + (fi * lg.step)
+ }
+ return lg.start - (fi * lg.step)
+}
+
+// WithStart sets the start and returns the linear generator.
+func (lg *LinearSeq) WithStart(start float64) *LinearSeq {
+ lg.start = start
+ return lg
+}
+
+// WithEnd sets the end and returns the linear generator.
+func (lg *LinearSeq) WithEnd(end float64) *LinearSeq {
+ lg.end = end
+ return lg
+}
+
+// WithStep sets the step and returns the linear generator.
+func (lg *LinearSeq) WithStep(step float64) *LinearSeq {
+ lg.step = step
+ return lg
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/linear_series.go b/vendor/github.com/wcharczuk/go-chart/v2/linear_series.go
new file mode 100644
index 0000000..89afa93
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/linear_series.go
@@ -0,0 +1,119 @@
+package chart
+
+import (
+ "fmt"
+)
+
+// Interface Assertions.
+var (
+ _ Series = (*LinearSeries)(nil)
+ _ FirstValuesProvider = (*LinearSeries)(nil)
+ _ LastValuesProvider = (*LinearSeries)(nil)
+)
+
+// LinearSeries is a series that plots a line in a given domain.
+type LinearSeries struct {
+ Name string
+ Style Style
+ YAxis YAxisType
+
+ XValues []float64
+ InnerSeries LinearCoefficientProvider
+
+ m float64
+ b float64
+ stdev float64
+ avg float64
+}
+
+// GetName returns the name of the time series.
+func (ls LinearSeries) GetName() string {
+ return ls.Name
+}
+
+// GetStyle returns the line style.
+func (ls LinearSeries) GetStyle() Style {
+ return ls.Style
+}
+
+// GetYAxis returns which YAxis the series draws on.
+func (ls LinearSeries) GetYAxis() YAxisType {
+ return ls.YAxis
+}
+
+// Len returns the number of elements in the series.
+func (ls LinearSeries) Len() int {
+ return len(ls.XValues)
+}
+
+// GetEndIndex returns the effective limit end.
+func (ls LinearSeries) GetEndIndex() int {
+ return len(ls.XValues) - 1
+}
+
+// GetValues gets a value at a given index.
+func (ls *LinearSeries) GetValues(index int) (x, y float64) {
+ if ls.InnerSeries == nil || len(ls.XValues) == 0 {
+ return
+ }
+ if ls.IsZero() {
+ ls.computeCoefficients()
+ }
+ x = ls.XValues[index]
+ y = (ls.m * ls.normalize(x)) + ls.b
+ return
+}
+
+// GetFirstValues computes the first linear regression value.
+func (ls *LinearSeries) GetFirstValues() (x, y float64) {
+ if ls.InnerSeries == nil || len(ls.XValues) == 0 {
+ return
+ }
+ if ls.IsZero() {
+ ls.computeCoefficients()
+ }
+ x, y = ls.GetValues(0)
+ return
+}
+
+// GetLastValues computes the last linear regression value.
+func (ls *LinearSeries) GetLastValues() (x, y float64) {
+ if ls.InnerSeries == nil || len(ls.XValues) == 0 {
+ return
+ }
+ if ls.IsZero() {
+ ls.computeCoefficients()
+ }
+ x, y = ls.GetValues(ls.GetEndIndex())
+ return
+}
+
+// Render renders the series.
+func (ls *LinearSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
+ Draw.LineSeries(r, canvasBox, xrange, yrange, ls.Style.InheritFrom(defaults), ls)
+}
+
+// Validate validates the series.
+func (ls LinearSeries) Validate() error {
+ if ls.InnerSeries == nil {
+ return fmt.Errorf("linear regression series requires InnerSeries to be set")
+ }
+ return nil
+}
+
+// IsZero returns if the linear series has computed coefficients or not.
+func (ls LinearSeries) IsZero() bool {
+ return ls.m == 0 && ls.b == 0
+}
+
+// computeCoefficients computes the `m` and `b` terms in the linear formula given by `y = mx+b`.
+func (ls *LinearSeries) computeCoefficients() {
+ ls.m, ls.b, ls.stdev, ls.avg = ls.InnerSeries.Coefficients()
+}
+
+func (ls *LinearSeries) normalize(xvalue float64) float64 {
+ if ls.avg > 0 && ls.stdev > 0 {
+ return (xvalue - ls.avg) / ls.stdev
+ }
+ return xvalue
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/logger.go b/vendor/github.com/wcharczuk/go-chart/v2/logger.go
new file mode 100644
index 0000000..28fc003
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/logger.go
@@ -0,0 +1,148 @@
+package chart
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "time"
+)
+
+var (
+ _ Logger = (*StdoutLogger)(nil)
+)
+
+// NewLogger returns a new logger.
+func NewLogger(options ...LoggerOption) Logger {
+ stl := &StdoutLogger{
+ TimeFormat: time.RFC3339Nano,
+ Stdout: os.Stdout,
+ Stderr: os.Stderr,
+ }
+ for _, option := range options {
+ option(stl)
+ }
+ return stl
+}
+
+// Logger is a type that implements the logging interface.
+type Logger interface {
+ Info(...interface{})
+ Infof(string, ...interface{})
+ Debug(...interface{})
+ Debugf(string, ...interface{})
+ Err(error)
+ FatalErr(error)
+ Error(...interface{})
+ Errorf(string, ...interface{})
+}
+
+// Info logs an info message if the logger is set.
+func Info(log Logger, arguments ...interface{}) {
+ if log == nil {
+ return
+ }
+ log.Info(arguments...)
+}
+
+// Infof logs an info message if the logger is set.
+func Infof(log Logger, format string, arguments ...interface{}) {
+ if log == nil {
+ return
+ }
+ log.Infof(format, arguments...)
+}
+
+// Debug logs an debug message if the logger is set.
+func Debug(log Logger, arguments ...interface{}) {
+ if log == nil {
+ return
+ }
+ log.Debug(arguments...)
+}
+
+// Debugf logs an debug message if the logger is set.
+func Debugf(log Logger, format string, arguments ...interface{}) {
+ if log == nil {
+ return
+ }
+ log.Debugf(format, arguments...)
+}
+
+// LoggerOption mutates a stdout logger.
+type LoggerOption = func(*StdoutLogger)
+
+//OptLoggerStdout sets the Stdout writer.
+func OptLoggerStdout(wr io.Writer) LoggerOption {
+ return func(stl *StdoutLogger) {
+ stl.Stdout = wr
+ }
+}
+
+// OptLoggerStderr sets the Stdout writer.
+func OptLoggerStderr(wr io.Writer) LoggerOption {
+ return func(stl *StdoutLogger) {
+ stl.Stderr = wr
+ }
+}
+
+// StdoutLogger is a basic logger.
+type StdoutLogger struct {
+ TimeFormat string
+ Stdout io.Writer
+ Stderr io.Writer
+}
+
+// Info writes an info message.
+func (l *StdoutLogger) Info(arguments ...interface{}) {
+ l.Println(append([]interface{}{"[INFO]"}, arguments...)...)
+}
+
+// Infof writes an info message.
+func (l *StdoutLogger) Infof(format string, arguments ...interface{}) {
+ l.Println(append([]interface{}{"[INFO]"}, fmt.Sprintf(format, arguments...))...)
+}
+
+// Debug writes an debug message.
+func (l *StdoutLogger) Debug(arguments ...interface{}) {
+ l.Println(append([]interface{}{"[DEBUG]"}, arguments...)...)
+}
+
+// Debugf writes an debug message.
+func (l *StdoutLogger) Debugf(format string, arguments ...interface{}) {
+ l.Println(append([]interface{}{"[DEBUG]"}, fmt.Sprintf(format, arguments...))...)
+}
+
+// Error writes an error message.
+func (l *StdoutLogger) Error(arguments ...interface{}) {
+ l.Println(append([]interface{}{"[ERROR]"}, arguments...)...)
+}
+
+// Errorf writes an error message.
+func (l *StdoutLogger) Errorf(format string, arguments ...interface{}) {
+ l.Println(append([]interface{}{"[ERROR]"}, fmt.Sprintf(format, arguments...))...)
+}
+
+// Err writes an error message.
+func (l *StdoutLogger) Err(err error) {
+ if err != nil {
+ l.Println(append([]interface{}{"[ERROR]"}, err.Error())...)
+ }
+}
+
+// FatalErr writes an error message and exits.
+func (l *StdoutLogger) FatalErr(err error) {
+ if err != nil {
+ l.Println(append([]interface{}{"[FATAL]"}, err.Error())...)
+ os.Exit(1)
+ }
+}
+
+// Println prints a new message.
+func (l *StdoutLogger) Println(arguments ...interface{}) {
+ fmt.Fprintln(l.Stdout, append([]interface{}{time.Now().UTC().Format(l.TimeFormat)}, arguments...)...)
+}
+
+// Errorln prints a new message.
+func (l *StdoutLogger) Errorln(arguments ...interface{}) {
+ fmt.Fprintln(l.Stderr, append([]interface{}{time.Now().UTC().Format(l.TimeFormat)}, arguments...)...)
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/macd_series.go b/vendor/github.com/wcharczuk/go-chart/v2/macd_series.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/macd_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/macd_series.go
diff --git a/vendor/github.com/wcharczuk/go-chart/util/math.go b/vendor/github.com/wcharczuk/go-chart/v2/mathutil.go
similarity index 53%
rename from vendor/github.com/wcharczuk/go-chart/util/math.go
rename to vendor/github.com/wcharczuk/go-chart/v2/mathutil.go
index 73f4976..d1f07f9 100644
--- a/vendor/github.com/wcharczuk/go-chart/util/math.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/mathutil.go
@@ -1,9 +1,6 @@
-package util
+package chart
-import (
- "math"
- "time"
-)
+import "math"
const (
_pi = math.Pi
@@ -19,86 +16,143 @@ const (
_r2d = (180.0 / math.Pi)
)
-var (
- // Math contains helper methods for common math operations.
- Math = &mathUtil{}
-)
-
-type mathUtil struct{}
-
-// Max returns the maximum value of a group of floats.
-func (m mathUtil) Max(values ...float64) float64 {
+// MinMax returns the minimum and maximum of a given set of values.
+func MinMax(values ...float64) (min, max float64) {
if len(values) == 0 {
- return 0
+ return
}
- max := values[0]
- for _, v := range values {
- if max < v {
- max = v
+
+ max = values[0]
+ min = values[0]
+ var value float64
+ for index := 1; index < len(values); index++ {
+ value = values[index]
+ if value < min {
+ min = value
+ }
+ if value > max {
+ max = value
}
}
- return max
+ return
}
-// MinAndMax returns both the min and max in one pass.
-func (m mathUtil) MinAndMax(values ...float64) (min float64, max float64) {
+// MinInt returns the minimum int.
+func MinInt(values ...int) (min int) {
if len(values) == 0 {
return
}
+
min = values[0]
- max = values[0]
- for _, v := range values[1:] {
- if max < v {
- max = v
- }
- if min > v {
- min = v
+ var value int
+ for index := 1; index < len(values); index++ {
+ value = values[index]
+ if value < min {
+ min = value
}
}
return
}
-// MinAndMaxOfTime returns the min and max of a given set of times
-// in one pass.
-func (m mathUtil) MinAndMaxOfTime(values ...time.Time) (min time.Time, max time.Time) {
+// MaxInt returns the maximum int.
+func MaxInt(values ...int) (max int) {
if len(values) == 0 {
return
}
- min = values[0]
max = values[0]
-
- for _, v := range values[1:] {
- if max.Before(v) {
- max = v
- }
- if min.After(v) {
- min = v
+ var value int
+ for index := 1; index < len(values); index++ {
+ value = values[index]
+ if value > max {
+ max = value
}
}
return
}
-// GetRoundToForDelta returns a `roundTo` value for a given delta.
-func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
- startingDeltaBound := math.Pow(10.0, 10.0)
- for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
- if delta > cursor {
- return cursor / 10.0
- }
+// AbsInt returns the absolute value of an int.
+func AbsInt(value int) int {
+ if value < 0 {
+ return -value
}
+ return value
+}
- return 0.0
+// DegreesToRadians returns degrees as radians.
+func DegreesToRadians(degrees float64) float64 {
+ return degrees * _d2r
+}
+
+// RadiansToDegrees translates a radian value to a degree value.
+func RadiansToDegrees(value float64) float64 {
+ return math.Mod(value, _2pi) * _r2d
+}
+
+// PercentToRadians converts a normalized value (0,1) to radians.
+func PercentToRadians(pct float64) float64 {
+ return DegreesToRadians(360.0 * pct)
+}
+
+// RadianAdd adds a delta to a base in radians.
+func RadianAdd(base, delta float64) float64 {
+ value := base + delta
+ if value > _2pi {
+ return math.Mod(value, _2pi)
+ } else if value < 0 {
+ return math.Mod(_2pi+value, _2pi)
+ }
+ return value
+}
+
+// DegreesAdd adds a delta to a base in radians.
+func DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
+ value := baseDegrees + deltaDegrees
+ if value > _2pi {
+ return math.Mod(value, 360.0)
+ } else if value < 0 {
+ return math.Mod(360.0+value, 360.0)
+ }
+ return value
+}
+
+// DegreesToCompass returns the degree value in compass / clock orientation.
+func DegreesToCompass(deg float64) float64 {
+ return DegreesAdd(deg, -90.0)
+}
+
+// CirclePoint returns the absolute position of a circle diameter point given
+// by the radius and the theta.
+func CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
+ x = cx + int(radius*math.Sin(thetaRadians))
+ y = cy - int(radius*math.Cos(thetaRadians))
+ return
+}
+
+// RotateCoordinate rotates a coordinate around a given center by a theta in radians.
+func RotateCoordinate(cx, cy, x, y int, thetaRadians float64) (rx, ry int) {
+ tempX, tempY := float64(x-cx), float64(y-cy)
+ rotatedX := tempX*math.Cos(thetaRadians) - tempY*math.Sin(thetaRadians)
+ rotatedY := tempX*math.Sin(thetaRadians) + tempY*math.Cos(thetaRadians)
+ rx = int(rotatedX) + cx
+ ry = int(rotatedY) + cy
+ return
}
// RoundUp rounds up to a given roundTo value.
-func (m mathUtil) RoundUp(value, roundTo float64) float64 {
+func RoundUp(value, roundTo float64) float64 {
+ if roundTo < 0.000000000000001 {
+ return value
+ }
d1 := math.Ceil(value / roundTo)
return d1 * roundTo
}
// RoundDown rounds down to a given roundTo value.
-func (m mathUtil) RoundDown(value, roundTo float64) float64 {
+func RoundDown(value, roundTo float64) float64 {
+ if roundTo < 0.000000000000001 {
+ return value
+ }
d1 := math.Floor(value / roundTo)
return d1 * roundTo
}
@@ -106,68 +160,30 @@ func (m mathUtil) RoundDown(value, roundTo float64) float64 {
// Normalize returns a set of numbers on the interval [0,1] for a given set of inputs.
// An example: 4,3,2,1 => 0.4, 0.3, 0.2, 0.1
// Caveat; the total may be < 1.0; there are going to be issues with irrational numbers etc.
-func (m mathUtil) Normalize(values ...float64) []float64 {
+func Normalize(values ...float64) []float64 {
var total float64
for _, v := range values {
total += v
}
output := make([]float64, len(values))
for x, v := range values {
- output[x] = m.RoundDown(v/total, 0.0001)
+ output[x] = RoundDown(v/total, 0.0001)
}
return output
}
-// MinInt returns the minimum of a set of integers.
-func (m mathUtil) MinInt(values ...int) int {
- min := math.MaxInt32
- for _, v := range values {
- if v < min {
- min = v
- }
- }
- return min
-}
-
-// MaxInt returns the maximum of a set of integers.
-func (m mathUtil) MaxInt(values ...int) int {
- max := math.MinInt32
- for _, v := range values {
- if v > max {
- max = v
- }
- }
- return max
-}
-
-// AbsInt returns the absolute value of an integer.
-func (m mathUtil) AbsInt(value int) int {
- if value < 0 {
- return -value
- }
- return value
-}
-
-// AbsInt64 returns the absolute value of a long.
-func (m mathUtil) AbsInt64(value int64) int64 {
- if value < 0 {
- return -value
- }
- return value
-}
-
// Mean returns the mean of a set of values
-func (m mathUtil) Mean(values ...float64) float64 {
- return m.Sum(values...) / float64(len(values))
+func Mean(values ...float64) float64 {
+ return Sum(values...) / float64(len(values))
}
// MeanInt returns the mean of a set of integer values.
-func (m mathUtil) MeanInt(values ...int) int {
- return m.SumInt(values...) / len(values)
+func MeanInt(values ...int) int {
+ return SumInt(values...) / len(values)
}
// Sum sums a set of values.
-func (m mathUtil) Sum(values ...float64) float64 {
+func Sum(values ...float64) float64 {
var total float64
for _, v := range values {
total += v
@@ -176,7 +192,7 @@ func (m mathUtil) Sum(values ...float64) float64 {
}
// SumInt sums a set of values.
-func (m mathUtil) SumInt(values ...int) int {
+func SumInt(values ...int) int {
var total int
for _, v := range values {
total += v
@@ -186,68 +202,51 @@ func (m mathUtil) SumInt(values ...int) int {
// PercentDifference computes the percentage difference between two values.
// The formula is (v2-v1)/v1.
-func (m mathUtil) PercentDifference(v1, v2 float64) float64 {
+func PercentDifference(v1, v2 float64) float64 {
if v1 == 0 {
return 0
}
return (v2 - v1) / v1
}
-// DegreesToRadians returns degrees as radians.
-func (m mathUtil) DegreesToRadians(degrees float64) float64 {
- return degrees * _d2r
-}
-
-// RadiansToDegrees translates a radian value to a degree value.
-func (m mathUtil) RadiansToDegrees(value float64) float64 {
- return math.Mod(value, _2pi) * _r2d
-}
+// GetRoundToForDelta returns a `roundTo` value for a given delta.
+func GetRoundToForDelta(delta float64) float64 {
+ startingDeltaBound := math.Pow(10.0, 10.0)
+ for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
+ if delta > cursor {
+ return cursor / 10.0
+ }
+ }
-// PercentToRadians converts a normalized value (0,1) to radians.
-func (m mathUtil) PercentToRadians(pct float64) float64 {
- return m.DegreesToRadians(360.0 * pct)
+ return 0.0
}
-// RadianAdd adds a delta to a base in radians.
-func (m mathUtil) RadianAdd(base, delta float64) float64 {
- value := base + delta
- if value > _2pi {
- return math.Mod(value, _2pi)
- } else if value < 0 {
- return math.Mod(_2pi+value, _2pi)
+// RoundPlaces rounds an input to a given places.
+func RoundPlaces(input float64, places int) (rounded float64) {
+ if math.IsNaN(input) {
+ return 0.0
}
- return value
-}
-// DegreesAdd adds a delta to a base in radians.
-func (m mathUtil) DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
- value := baseDegrees + deltaDegrees
- if value > _2pi {
- return math.Mod(value, 360.0)
- } else if value < 0 {
- return math.Mod(360.0+value, 360.0)
+ sign := 1.0
+ if input < 0 {
+ sign = -1
+ input *= -1
}
- return value
-}
-// DegreesToCompass returns the degree value in compass / clock orientation.
-func (m mathUtil) DegreesToCompass(deg float64) float64 {
- return m.DegreesAdd(deg, -90.0)
-}
+ precision := math.Pow(10, float64(places))
+ digit := input * precision
+ _, decimal := math.Modf(digit)
-// CirclePoint returns the absolute position of a circle diameter point given
-// by the radius and the theta.
-func (m mathUtil) CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
- x = cx + int(radius*math.Sin(thetaRadians))
- y = cy - int(radius*math.Cos(thetaRadians))
- return
+ if decimal >= 0.5 {
+ rounded = math.Ceil(digit)
+ } else {
+ rounded = math.Floor(digit)
+ }
+
+ return rounded / precision * sign
}
-func (m mathUtil) RotateCoordinate(cx, cy, x, y int, thetaRadians float64) (rx, ry int) {
- tempX, tempY := float64(x-cx), float64(y-cy)
- rotatedX := tempX*math.Cos(thetaRadians) - tempY*math.Sin(thetaRadians)
- rotatedY := tempX*math.Sin(thetaRadians) + tempY*math.Cos(thetaRadians)
- rx = int(rotatedX) + cx
- ry = int(rotatedY) + cy
- return
+func f64i(value float64) int {
+ r := RoundPlaces(value, 0)
+ return int(r)
}
diff --git a/vendor/github.com/wcharczuk/go-chart/matrix/matrix.go b/vendor/github.com/wcharczuk/go-chart/v2/matrix/matrix.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/matrix/matrix.go
rename to vendor/github.com/wcharczuk/go-chart/v2/matrix/matrix.go
diff --git a/vendor/github.com/wcharczuk/go-chart/matrix/regression.go b/vendor/github.com/wcharczuk/go-chart/v2/matrix/regression.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/matrix/regression.go
rename to vendor/github.com/wcharczuk/go-chart/v2/matrix/regression.go
diff --git a/vendor/github.com/wcharczuk/go-chart/matrix/util.go b/vendor/github.com/wcharczuk/go-chart/v2/matrix/util.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/matrix/util.go
rename to vendor/github.com/wcharczuk/go-chart/v2/matrix/util.go
diff --git a/vendor/github.com/wcharczuk/go-chart/matrix/vector.go b/vendor/github.com/wcharczuk/go-chart/v2/matrix/vector.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/matrix/vector.go
rename to vendor/github.com/wcharczuk/go-chart/v2/matrix/vector.go
diff --git a/vendor/github.com/wcharczuk/go-chart/min_max_series.go b/vendor/github.com/wcharczuk/go-chart/v2/min_max_series.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/min_max_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/min_max_series.go
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/parse.go b/vendor/github.com/wcharczuk/go-chart/v2/parse.go
new file mode 100644
index 0000000..5ecae0a
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/parse.go
@@ -0,0 +1,40 @@
+package chart
+
+import (
+ "strconv"
+ "strings"
+ "time"
+)
+
+// ParseFloats parses a list of floats.
+func ParseFloats(values ...string) ([]float64, error) {
+ var output []float64
+ var parsedValue float64
+ var err error
+ var cleaned string
+ for _, value := range values {
+ cleaned = strings.TrimSpace(strings.Replace(value, ",", "", -1))
+ if cleaned == "" {
+ continue
+ }
+ if parsedValue, err = strconv.ParseFloat(cleaned, 64); err != nil {
+ return nil, err
+ }
+ output = append(output, parsedValue)
+ }
+ return output, nil
+}
+
+// ParseTimes parses a list of times with a given format.
+func ParseTimes(layout string, values ...string) ([]time.Time, error) {
+ var output []time.Time
+ var parsedValue time.Time
+ var err error
+ for _, value := range values {
+ if parsedValue, err = time.Parse(layout, value); err != nil {
+ return nil, err
+ }
+ output = append(output, parsedValue)
+ }
+ return output, nil
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/percent_change_series.go b/vendor/github.com/wcharczuk/go-chart/v2/percent_change_series.go
new file mode 100644
index 0000000..3767893
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/percent_change_series.go
@@ -0,0 +1,89 @@
+package chart
+
+// Interface Assertions.
+var (
+ _ Series = (*PercentChangeSeries)(nil)
+ _ FirstValuesProvider = (*PercentChangeSeries)(nil)
+ _ LastValuesProvider = (*PercentChangeSeries)(nil)
+ _ ValueFormatterProvider = (*PercentChangeSeries)(nil)
+)
+
+// PercentChangeSeriesSource is a series that
+// can be used with a PercentChangeSeries
+type PercentChangeSeriesSource interface {
+ Series
+ FirstValuesProvider
+ LastValuesProvider
+ ValuesProvider
+ ValueFormatterProvider
+}
+
+// PercentChangeSeries applies a
+// percentage difference function to a given continuous series.
+type PercentChangeSeries struct {
+ Name string
+ Style Style
+ YAxis YAxisType
+ InnerSeries PercentChangeSeriesSource
+}
+
+// GetName returns the name of the time series.
+func (pcs PercentChangeSeries) GetName() string {
+ return pcs.Name
+}
+
+// GetStyle returns the line style.
+func (pcs PercentChangeSeries) GetStyle() Style {
+ return pcs.Style
+}
+
+// Len implements part of Series.
+func (pcs PercentChangeSeries) Len() int {
+ return pcs.InnerSeries.Len()
+}
+
+// GetFirstValues implements FirstValuesProvider.
+func (pcs PercentChangeSeries) GetFirstValues() (x, y float64) {
+ return pcs.InnerSeries.GetFirstValues()
+}
+
+// GetValues gets x, y values at a given index.
+func (pcs PercentChangeSeries) GetValues(index int) (x, y float64) {
+ _, fy := pcs.InnerSeries.GetFirstValues()
+ x0, y0 := pcs.InnerSeries.GetValues(index)
+ x = x0
+ y = PercentDifference(fy, y0)
+ return
+}
+
+// GetValueFormatters returns value formatter defaults for the series.
+func (pcs PercentChangeSeries) GetValueFormatters() (x, y ValueFormatter) {
+ x, _ = pcs.InnerSeries.GetValueFormatters()
+ y = PercentValueFormatter
+ return
+}
+
+// GetYAxis returns which YAxis the series draws on.
+func (pcs PercentChangeSeries) GetYAxis() YAxisType {
+ return pcs.YAxis
+}
+
+// GetLastValues gets the last values.
+func (pcs PercentChangeSeries) GetLastValues() (x, y float64) {
+ _, fy := pcs.InnerSeries.GetFirstValues()
+ x0, y0 := pcs.InnerSeries.GetLastValues()
+ x = x0
+ y = PercentDifference(fy, y0)
+ return
+}
+
+// Render renders the series.
+func (pcs PercentChangeSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
+ style := pcs.Style.InheritFrom(defaults)
+ Draw.LineSeries(r, canvasBox, xrange, yrange, style, pcs)
+}
+
+// Validate validates the series.
+func (pcs PercentChangeSeries) Validate() error {
+ return pcs.InnerSeries.Validate()
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/pie_chart.go b/vendor/github.com/wcharczuk/go-chart/v2/pie_chart.go
similarity index 87%
rename from vendor/github.com/wcharczuk/go-chart/pie_chart.go
rename to vendor/github.com/wcharczuk/go-chart/v2/pie_chart.go
index 6d5d75e..49b551f 100644
--- a/vendor/github.com/wcharczuk/go-chart/pie_chart.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/pie_chart.go
@@ -4,16 +4,8 @@ import (
"errors"
"fmt"
"io"
- "math"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/util"
-)
-
-const (
- _pi = math.Pi
- _pi2 = math.Pi / 2.0
- _pi4 = math.Pi / 4.0
)
// PieChart is a chart that draws sections of a circle based on percentages.
@@ -124,33 +116,40 @@ func (pc PieChart) drawCanvas(r Renderer, canvasBox Box) {
}
func (pc PieChart) drawTitle(r Renderer) {
- if len(pc.Title) > 0 && pc.TitleStyle.Show {
+ if len(pc.Title) > 0 && !pc.TitleStyle.Hidden {
Draw.TextWithin(r, pc.Title, pc.Box(), pc.styleDefaultsTitle())
}
}
func (pc PieChart) drawSlices(r Renderer, canvasBox Box, values []Value) {
cx, cy := canvasBox.Center()
- diameter := util.Math.MinInt(canvasBox.Width(), canvasBox.Height())
+ diameter := MinInt(canvasBox.Width(), canvasBox.Height())
radius := float64(diameter >> 1)
labelRadius := (radius * 2.0) / 3.0
// draw the pie slices
var rads, delta, delta2, total float64
var lx, ly int
- for index, v := range values {
- v.Style.InheritFrom(pc.stylePieChartValue(index)).WriteToRenderer(r)
+ if len(values) == 1 {
+ pc.stylePieChartValue(0).WriteToRenderer(r)
r.MoveTo(cx, cy)
- rads = util.Math.PercentToRadians(total)
- delta = util.Math.PercentToRadians(v.Value)
+ r.Circle(radius, cx, cy)
+ } else {
+ for index, v := range values {
+ v.Style.InheritFrom(pc.stylePieChartValue(index)).WriteToRenderer(r)
- r.ArcTo(cx, cy, radius, radius, rads, delta)
+ r.MoveTo(cx, cy)
+ rads = PercentToRadians(total)
+ delta = PercentToRadians(v.Value)
- r.LineTo(cx, cy)
- r.Close()
- r.FillStroke()
- total = total + v.Value
+ r.ArcTo(cx, cy, radius, radius, rads, delta)
+
+ r.LineTo(cx, cy)
+ r.Close()
+ r.FillStroke()
+ total = total + v.Value
+ }
}
// draw the labels
@@ -158,14 +157,21 @@ func (pc PieChart) drawSlices(r Renderer, canvasBox Box, values []Value) {
for index, v := range values {
v.Style.InheritFrom(pc.stylePieChartValue(index)).WriteToRenderer(r)
if len(v.Label) > 0 {
- delta2 = util.Math.PercentToRadians(total + (v.Value / 2.0))
- delta2 = util.Math.RadianAdd(delta2, _pi2)
- lx, ly = util.Math.CirclePoint(cx, cy, labelRadius, delta2)
+ delta2 = PercentToRadians(total + (v.Value / 2.0))
+ delta2 = RadianAdd(delta2, _pi2)
+ lx, ly = CirclePoint(cx, cy, labelRadius, delta2)
tb := r.MeasureText(v.Label)
lx = lx - (tb.Width() >> 1)
ly = ly + (tb.Height() >> 1)
+ if lx < 0 {
+ lx = 0
+ }
+ if ly < 0 {
+ lx = 0
+ }
+
r.Text(v.Label, lx, ly)
}
total = total + v.Value
@@ -185,7 +191,7 @@ func (pc PieChart) getDefaultCanvasBox() Box {
}
func (pc PieChart) getCircleAdjustedCanvasBox(canvasBox Box) Box {
- circleDiameter := util.Math.MinInt(canvasBox.Width(), canvasBox.Height())
+ circleDiameter := MinInt(canvasBox.Width(), canvasBox.Height())
square := Box{
Right: circleDiameter,
@@ -231,7 +237,7 @@ func (pc PieChart) stylePieChartValue(index int) Style {
}
func (pc PieChart) getScaledFontSize() float64 {
- effectiveDimension := util.Math.MinInt(pc.GetWidth(), pc.GetHeight())
+ effectiveDimension := MinInt(pc.GetWidth(), pc.GetHeight())
if effectiveDimension >= 2048 {
return 48.0
} else if effectiveDimension >= 1024 {
@@ -270,7 +276,7 @@ func (pc PieChart) styleDefaultsTitle() Style {
}
func (pc PieChart) getTitleFontSize() float64 {
- effectiveDimension := util.Math.MinInt(pc.GetWidth(), pc.GetHeight())
+ effectiveDimension := MinInt(pc.GetWidth(), pc.GetHeight())
if effectiveDimension >= 2048 {
return 48
} else if effectiveDimension >= 1024 {
diff --git a/vendor/github.com/wcharczuk/go-chart/polynomial_regression_series.go b/vendor/github.com/wcharczuk/go-chart/v2/polynomial_regression_series.go
similarity index 81%
rename from vendor/github.com/wcharczuk/go-chart/polynomial_regression_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/polynomial_regression_series.go
index 506a4cb..22cd3c1 100644
--- a/vendor/github.com/wcharczuk/go-chart/polynomial_regression_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/polynomial_regression_series.go
@@ -4,8 +4,14 @@ import (
"fmt"
"math"
- "github.com/wcharczuk/go-chart/matrix"
- util "github.com/wcharczuk/go-chart/util"
+ "github.com/wcharczuk/go-chart/v2/matrix"
+)
+
+// Interface Assertions.
+var (
+ _ Series = (*PolynomialRegressionSeries)(nil)
+ _ FirstValuesProvider = (*PolynomialRegressionSeries)(nil)
+ _ LastValuesProvider = (*PolynomialRegressionSeries)(nil)
)
// PolynomialRegressionSeries implements a polynomial regression over a given
@@ -40,7 +46,7 @@ func (prs PolynomialRegressionSeries) GetYAxis() YAxisType {
// Len returns the number of elements in the series.
func (prs PolynomialRegressionSeries) Len() int {
- return util.Math.MinInt(prs.GetLimit(), prs.InnerSeries.Len()-prs.GetOffset())
+ return MinInt(prs.GetLimit(), prs.InnerSeries.Len()-prs.GetOffset())
}
// GetLimit returns the window size.
@@ -55,7 +61,7 @@ func (prs PolynomialRegressionSeries) GetLimit() int {
func (prs PolynomialRegressionSeries) GetEndIndex() int {
windowEnd := prs.GetOffset() + prs.GetLimit()
innerSeriesLastIndex := prs.InnerSeries.Len() - 1
- return util.Math.MinInt(windowEnd, innerSeriesLastIndex)
+ return MinInt(windowEnd, innerSeriesLastIndex)
}
// GetOffset returns the data offset.
@@ -95,12 +101,29 @@ func (prs *PolynomialRegressionSeries) GetValues(index int) (x, y float64) {
}
offset := prs.GetOffset()
- effectiveIndex := util.Math.MinInt(index+offset, prs.InnerSeries.Len())
+ effectiveIndex := MinInt(index+offset, prs.InnerSeries.Len())
x, y = prs.InnerSeries.GetValues(effectiveIndex)
y = prs.apply(x)
return
}
+// GetFirstValues computes the first poly regression value.
+func (prs *PolynomialRegressionSeries) GetFirstValues() (x, y float64) {
+ if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
+ return
+ }
+ if prs.coeffs == nil {
+ coeffs, err := prs.computeCoefficients()
+ if err != nil {
+ panic(err)
+ }
+ prs.coeffs = coeffs
+ }
+ x, y = prs.InnerSeries.GetValues(0)
+ y = prs.apply(x)
+ return
+}
+
// GetLastValues computes the last poly regression value.
func (prs *PolynomialRegressionSeries) GetLastValues() (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/random.go b/vendor/github.com/wcharczuk/go-chart/v2/random_sequence.go
similarity index 64%
rename from vendor/github.com/wcharczuk/go-chart/seq/random.go
rename to vendor/github.com/wcharczuk/go-chart/v2/random_sequence.go
index ea65084..45c9971 100644
--- a/vendor/github.com/wcharczuk/go-chart/seq/random.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/random_sequence.go
@@ -1,4 +1,4 @@
-package seq
+package chart
import (
"math"
@@ -6,25 +6,29 @@ import (
"time"
)
+var (
+ _ Sequence = (*RandomSeq)(nil)
+)
+
// RandomValues returns an array of random values.
func RandomValues(count int) []float64 {
- return Seq{NewRandom().WithLen(count)}.Array()
+ return Seq{NewRandomSequence().WithLen(count)}.Values()
}
// RandomValuesWithMax returns an array of random values with a given average.
func RandomValuesWithMax(count int, max float64) []float64 {
- return Seq{NewRandom().WithMax(max).WithLen(count)}.Array()
+ return Seq{NewRandomSequence().WithMax(max).WithLen(count)}.Values()
}
-// NewRandom creates a new random seq.
-func NewRandom() *Random {
- return &Random{
+// NewRandomSequence creates a new random seq.
+func NewRandomSequence() *RandomSeq {
+ return &RandomSeq{
rnd: rand.New(rand.NewSource(time.Now().Unix())),
}
}
-// Random is a random number seq generator.
-type Random struct {
+// RandomSeq is a random number seq generator.
+type RandomSeq struct {
rnd *rand.Rand
max *float64
min *float64
@@ -32,7 +36,7 @@ type Random struct {
}
// Len returns the number of elements that will be generated.
-func (r *Random) Len() int {
+func (r *RandomSeq) Len() int {
if r.len != nil {
return *r.len
}
@@ -40,7 +44,7 @@ func (r *Random) Len() int {
}
// GetValue returns the value.
-func (r *Random) GetValue(_ int) float64 {
+func (r *RandomSeq) GetValue(_ int) float64 {
if r.min != nil && r.max != nil {
var delta float64
@@ -60,29 +64,29 @@ func (r *Random) GetValue(_ int) float64 {
}
// WithLen sets a maximum len
-func (r *Random) WithLen(length int) *Random {
+func (r *RandomSeq) WithLen(length int) *RandomSeq {
r.len = &length
return r
}
// Min returns the minimum value.
-func (r Random) Min() *float64 {
+func (r RandomSeq) Min() *float64 {
return r.min
}
// WithMin sets the scale and returns the Random.
-func (r *Random) WithMin(min float64) *Random {
+func (r *RandomSeq) WithMin(min float64) *RandomSeq {
r.min = &min
return r
}
// Max returns the maximum value.
-func (r Random) Max() *float64 {
+func (r RandomSeq) Max() *float64 {
return r.max
}
// WithMax sets the average and returns the Random.
-func (r *Random) WithMax(max float64) *Random {
+func (r *RandomSeq) WithMax(max float64) *RandomSeq {
r.max = &max
return r
}
diff --git a/vendor/github.com/wcharczuk/go-chart/range.go b/vendor/github.com/wcharczuk/go-chart/v2/range.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/range.go
rename to vendor/github.com/wcharczuk/go-chart/v2/range.go
diff --git a/vendor/github.com/wcharczuk/go-chart/raster_renderer.go b/vendor/github.com/wcharczuk/go-chart/v2/raster_renderer.go
similarity index 95%
rename from vendor/github.com/wcharczuk/go-chart/raster_renderer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/raster_renderer.go
index 1f18309..4de2655 100644
--- a/vendor/github.com/wcharczuk/go-chart/raster_renderer.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/raster_renderer.go
@@ -7,8 +7,7 @@ import (
"math"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/drawing"
- "github.com/wcharczuk/go-chart/util"
+ "github.com/wcharczuk/go-chart/v2/drawing"
)
// PNG returns a new png/raster renderer.
@@ -49,6 +48,9 @@ func (rr *rasterRenderer) SetDPI(dpi float64) {
rr.gc.SetDPI(dpi)
}
+// SetClassName implements the interface method. However, PNGs have no classes.
+func (rr *rasterRenderer) SetClassName(_ string) {}
+
// SetStrokeColor implements the interface method.
func (rr *rasterRenderer) SetStrokeColor(c drawing.Color) {
rr.s.StrokeColor = c
@@ -192,7 +194,7 @@ func (rr *rasterRenderer) MeasureText(body string) Box {
return textBox
}
- return textBox.Corners().Rotate(util.Math.RadiansToDegrees(*rr.rotateRadians)).Box()
+ return textBox.Corners().Rotate(RadiansToDegrees(*rr.rotateRadians)).Box()
}
// SetTextRotation sets a text rotation.
diff --git a/vendor/github.com/wcharczuk/go-chart/renderable.go b/vendor/github.com/wcharczuk/go-chart/v2/renderable.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/renderable.go
rename to vendor/github.com/wcharczuk/go-chart/v2/renderable.go
diff --git a/vendor/github.com/wcharczuk/go-chart/renderer.go b/vendor/github.com/wcharczuk/go-chart/v2/renderer.go
similarity index 94%
rename from vendor/github.com/wcharczuk/go-chart/renderer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/renderer.go
index 7eb06bb..589c773 100644
--- a/vendor/github.com/wcharczuk/go-chart/renderer.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/renderer.go
@@ -4,7 +4,7 @@ import (
"io"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/drawing"
+ "github.com/wcharczuk/go-chart/v2/drawing"
)
// Renderer represents the basic methods required to draw a chart.
@@ -18,6 +18,9 @@ type Renderer interface {
// SetDPI sets the DPI for the renderer.
SetDPI(dpi float64)
+ // SetClassName sets the current class name.
+ SetClassName(string)
+
// SetStrokeColor sets the current stroke color.
SetStrokeColor(drawing.Color)
diff --git a/vendor/github.com/wcharczuk/go-chart/renderer_provider.go b/vendor/github.com/wcharczuk/go-chart/v2/renderer_provider.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/renderer_provider.go
rename to vendor/github.com/wcharczuk/go-chart/v2/renderer_provider.go
diff --git a/vendor/github.com/wcharczuk/go-chart/roboto/roboto.go b/vendor/github.com/wcharczuk/go-chart/v2/roboto/roboto.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/roboto/roboto.go
rename to vendor/github.com/wcharczuk/go-chart/v2/roboto/roboto.go
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/sequence.go b/vendor/github.com/wcharczuk/go-chart/v2/seq.go
similarity index 84%
rename from vendor/github.com/wcharczuk/go-chart/seq/sequence.go
rename to vendor/github.com/wcharczuk/go-chart/v2/seq.go
index dfc369a..76ac40d 100644
--- a/vendor/github.com/wcharczuk/go-chart/seq/sequence.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/seq.go
@@ -1,33 +1,28 @@
-package seq
+package chart
import (
"math"
"sort"
)
-// New wraps a provider with a seq.
-func New(provider Provider) Seq {
- return Seq{Provider: provider}
+// ValueSequence returns a sequence for a given values set.
+func ValueSequence(values ...float64) Seq {
+ return Seq{NewArray(values...)}
}
-// Values returns a new seq composed of a given set of values.
-func Values(values ...float64) Seq {
- return Seq{Provider: Array(values)}
-}
-
-// Provider is a provider for values for a seq.
-type Provider interface {
+// Sequence is a provider for values for a seq.
+type Sequence interface {
Len() int
GetValue(int) float64
}
// Seq is a utility wrapper for seq providers.
type Seq struct {
- Provider
+ Sequence
}
-// Array enumerates the seq into a slice.
-func (s Seq) Array() (output []float64) {
+// Values enumerates the seq into a slice.
+func (s Seq) Values() (output []float64) {
if s.Len() == 0 {
return
}
@@ -148,9 +143,30 @@ func (s Seq) Sort() Seq {
if s.Len() == 0 {
return s
}
- values := s.Array()
+ values := s.Values()
sort.Float64s(values)
- return Seq{Provider: Array(values)}
+ return Seq{Array(values)}
+}
+
+// Reverse reverses the sequence
+func (s Seq) Reverse() Seq {
+ if s.Len() == 0 {
+ return s
+ }
+
+ values := s.Values()
+ valuesLen := len(values)
+ valuesLen1 := len(values) - 1
+ valuesLen2 := valuesLen >> 1
+ var i, j float64
+ for index := 0; index < valuesLen2; index++ {
+ i = values[index]
+ j = values[valuesLen1-index]
+ values[index] = j
+ values[valuesLen1-index] = i
+ }
+
+ return Seq{Array(values)}
}
// Median returns the median or middle value in the sorted seq.
@@ -255,5 +271,5 @@ func (s Seq) Normalize() Seq {
output[i] = (s.GetValue(i) - min) / delta
}
- return Seq{Provider: Array(output)}
+ return Seq{Array(output)}
}
diff --git a/vendor/github.com/wcharczuk/go-chart/series.go b/vendor/github.com/wcharczuk/go-chart/v2/series.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/series.go
diff --git a/vendor/github.com/wcharczuk/go-chart/sma_series.go b/vendor/github.com/wcharczuk/go-chart/v2/sma_series.go
similarity index 83%
rename from vendor/github.com/wcharczuk/go-chart/sma_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/sma_series.go
index 396ecaa..b952c0a 100644
--- a/vendor/github.com/wcharczuk/go-chart/sma_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/sma_series.go
@@ -2,8 +2,6 @@ package chart
import (
"fmt"
-
- util "github.com/wcharczuk/go-chart/util"
)
const (
@@ -11,6 +9,13 @@ const (
DefaultSimpleMovingAveragePeriod = 16
)
+// Interface Assertions.
+var (
+ _ Series = (*SMASeries)(nil)
+ _ FirstValuesProvider = (*SMASeries)(nil)
+ _ LastValuesProvider = (*SMASeries)(nil)
+)
+
// SMASeries is a computed series.
type SMASeries struct {
Name string
@@ -63,6 +68,17 @@ func (sma SMASeries) GetValues(index int) (x, y float64) {
return
}
+// GetFirstValues computes the first moving average value.
+func (sma SMASeries) GetFirstValues() (x, y float64) {
+ if sma.InnerSeries == nil || sma.InnerSeries.Len() == 0 {
+ return
+ }
+ px, _ := sma.InnerSeries.GetValues(0)
+ x = px
+ y = sma.getAverage(0)
+ return
+}
+
// GetLastValues computes the last moving average value but walking back window size samples,
// and recomputing the last moving average chunk.
func (sma SMASeries) GetLastValues() (x, y float64) {
@@ -78,7 +94,7 @@ func (sma SMASeries) GetLastValues() (x, y float64) {
func (sma SMASeries) getAverage(index int) float64 {
period := sma.GetPeriod()
- floor := util.Math.MaxInt(0, index-period)
+ floor := MaxInt(0, index-period)
var accum float64
var count float64
for x := index; x >= floor; x-- {
diff --git a/vendor/github.com/wcharczuk/go-chart/stacked_bar_chart.go b/vendor/github.com/wcharczuk/go-chart/v2/stacked_bar_chart.go
similarity index 56%
rename from vendor/github.com/wcharczuk/go-chart/stacked_bar_chart.go
rename to vendor/github.com/wcharczuk/go-chart/v2/stacked_bar_chart.go
index 0a5e723..10aa545 100644
--- a/vendor/github.com/wcharczuk/go-chart/stacked_bar_chart.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/stacked_bar_chart.go
@@ -7,8 +7,6 @@ import (
"math"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/seq"
- util "github.com/wcharczuk/go-chart/util"
)
// StackedBar is a bar within a StackedBarChart.
@@ -48,6 +46,8 @@ type StackedBarChart struct {
Font *truetype.Font
defaultFont *truetype.Font
+ IsHorizontal bool
+
Bars []StackedBar
Elements []Renderable
}
@@ -115,11 +115,20 @@ func (sbc StackedBarChart) Render(rp RendererProvider, w io.Writer) error {
}
r.SetDPI(sbc.GetDPI(DefaultDPI))
- canvasBox := sbc.getAdjustedCanvasBox(r, sbc.getDefaultCanvasBox())
- sbc.drawCanvas(r, canvasBox)
- sbc.drawBars(r, canvasBox)
- sbc.drawXAxis(r, canvasBox)
- sbc.drawYAxis(r, canvasBox)
+ var canvasBox Box
+ if sbc.IsHorizontal {
+ canvasBox = sbc.getHorizontalAdjustedCanvasBox(r, sbc.getDefaultCanvasBox())
+ sbc.drawCanvas(r, canvasBox)
+ sbc.drawHorizontalBars(r, canvasBox)
+ sbc.drawHorizontalXAxis(r, canvasBox)
+ sbc.drawHorizontalYAxis(r, canvasBox)
+ } else {
+ canvasBox = sbc.getAdjustedCanvasBox(r, sbc.getDefaultCanvasBox())
+ sbc.drawCanvas(r, canvasBox)
+ sbc.drawBars(r, canvasBox)
+ sbc.drawXAxis(r, canvasBox)
+ sbc.drawYAxis(r, canvasBox)
+ }
sbc.drawTitle(r)
for _, a := range sbc.Elements {
@@ -141,6 +150,14 @@ func (sbc StackedBarChart) drawBars(r Renderer, canvasBox Box) {
}
}
+func (sbc StackedBarChart) drawHorizontalBars(r Renderer, canvasBox Box) {
+ yOffset := canvasBox.Top
+ for _, bar := range sbc.Bars {
+ sbc.drawHorizontalBar(r, canvasBox, yOffset, bar)
+ yOffset += sbc.GetBarSpacing() + bar.GetWidth()
+ }
+}
+
func (sbc StackedBarChart) drawBar(r Renderer, canvasBox Box, xoffset int, bar StackedBar) int {
barSpacing2 := sbc.GetBarSpacing() >> 1
bxl := xoffset + barSpacing2
@@ -154,17 +171,93 @@ func (sbc StackedBarChart) drawBar(r Renderer, canvasBox Box, xoffset int, bar S
Top: yoffset,
Left: bxl,
Right: bxr,
- Bottom: util.Math.MinInt(yoffset+barHeight, canvasBox.Bottom-DefaultStrokeWidth),
+ Bottom: MinInt(yoffset+barHeight, canvasBox.Bottom-DefaultStrokeWidth),
}
Draw.Box(r, barBox, bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)))
yoffset += barHeight
}
+ // draw the labels
+ yoffset = canvasBox.Top
+ var lx, ly int
+ for index, bv := range normalizedBarComponents {
+ barHeight := int(math.Ceil(bv.Value * float64(canvasBox.Height())))
+
+ if len(bv.Label) > 0 {
+ lx = bxl + ((bxr - bxl) / 2)
+ ly = yoffset + (barHeight / 2)
+
+ bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)).WriteToRenderer(r)
+ tb := r.MeasureText(bv.Label)
+ lx = lx - (tb.Width() >> 1)
+ ly = ly + (tb.Height() >> 1)
+
+ if lx < 0 {
+ lx = 0
+ }
+ if ly < 0 {
+ lx = 0
+ }
+
+ r.Text(bv.Label, lx, ly)
+ }
+ yoffset += barHeight
+ }
+
return bxr
}
+func (sbc StackedBarChart) drawHorizontalBar(r Renderer, canvasBox Box, yoffset int, bar StackedBar) {
+ halfBarSpacing := sbc.GetBarSpacing() >> 1
+
+ boxTop := yoffset + halfBarSpacing
+ boxBottom := boxTop + bar.GetWidth()
+
+ normalizedBarComponents := Values(bar.Values).Normalize()
+
+ xOffset := canvasBox.Right
+ for index, bv := range normalizedBarComponents {
+ barHeight := int(math.Ceil(bv.Value * float64(canvasBox.Width())))
+ barBox := Box{
+ Top: boxTop,
+ Left: MinInt(xOffset-barHeight, canvasBox.Left+DefaultStrokeWidth),
+ Right: xOffset,
+ Bottom: boxBottom,
+ }
+ Draw.Box(r, barBox, bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)))
+ xOffset -= barHeight
+ }
+
+ // draw the labels
+ xOffset = canvasBox.Right
+ var lx, ly int
+ for index, bv := range normalizedBarComponents {
+ barHeight := int(math.Ceil(bv.Value * float64(canvasBox.Width())))
+
+ if len(bv.Label) > 0 {
+ lx = xOffset - (barHeight / 2)
+ ly = boxTop + ((boxBottom - boxTop) / 2)
+
+ bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)).WriteToRenderer(r)
+ tb := r.MeasureText(bv.Label)
+ lx = lx - (tb.Width() >> 1)
+ ly = ly + (tb.Height() >> 1)
+
+ if lx < 0 {
+ lx = 0
+ }
+ if ly < 0 {
+ lx = 0
+ }
+
+ r.Text(bv.Label, lx, ly)
+ }
+ xOffset -= barHeight
+ }
+}
+
func (sbc StackedBarChart) drawXAxis(r Renderer, canvasBox Box) {
- if sbc.XAxis.Show {
+ if !sbc.XAxis.Hidden {
axisStyle := sbc.XAxis.InheritFrom(sbc.styleDefaultsAxes())
axisStyle.WriteToRenderer(r)
@@ -197,8 +290,44 @@ func (sbc StackedBarChart) drawXAxis(r Renderer, canvasBox Box) {
}
}
+func (sbc StackedBarChart) drawHorizontalXAxis(r Renderer, canvasBox Box) {
+ if !sbc.XAxis.Hidden {
+ axisStyle := sbc.XAxis.InheritFrom(sbc.styleDefaultsAxes())
+ axisStyle.WriteToRenderer(r)
+ r.MoveTo(canvasBox.Left, canvasBox.Bottom)
+ r.LineTo(canvasBox.Right, canvasBox.Bottom)
+ r.Stroke()
+
+ r.MoveTo(canvasBox.Left, canvasBox.Bottom)
+ r.LineTo(canvasBox.Left, canvasBox.Bottom+DefaultVerticalTickHeight)
+ r.Stroke()
+
+ ticks := LinearRangeWithStep(0.0, 1.0, 0.2)
+ for _, t := range ticks {
+ axisStyle.GetStrokeOptions().WriteToRenderer(r)
+ tx := canvasBox.Left + int(t*float64(canvasBox.Width()))
+ r.MoveTo(tx, canvasBox.Bottom)
+ r.LineTo(tx, canvasBox.Bottom+DefaultVerticalTickHeight)
+ r.Stroke()
+
+ axisStyle.GetTextOptions().WriteToRenderer(r)
+ text := fmt.Sprintf("%0.0f%%", t*100)
+
+ textBox := r.MeasureText(text)
+ textX := tx - (textBox.Width() >> 1)
+ textY := canvasBox.Bottom + DefaultXAxisMargin + 10
+
+ if t == 1 {
+ textX = canvasBox.Right - textBox.Width()
+ }
+
+ Draw.Text(r, text, textX, textY, axisStyle)
+ }
+ }
+}
+
func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) {
- if sbc.YAxis.Show {
+ if !sbc.YAxis.Hidden {
axisStyle := sbc.YAxis.InheritFrom(sbc.styleDefaultsAxes())
axisStyle.WriteToRenderer(r)
r.MoveTo(canvasBox.Right, canvasBox.Top)
@@ -209,7 +338,7 @@ func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) {
r.LineTo(canvasBox.Right+DefaultHorizontalTickWidth, canvasBox.Bottom)
r.Stroke()
- ticks := seq.RangeWithStep(0.0, 1.0, 0.2)
+ ticks := LinearRangeWithStep(0.0, 1.0, 0.2)
for _, t := range ticks {
axisStyle.GetStrokeOptions().WriteToRenderer(r)
ty := canvasBox.Bottom - int(t*float64(canvasBox.Height()))
@@ -223,12 +352,44 @@ func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) {
tb := r.MeasureText(text)
Draw.Text(r, text, canvasBox.Right+DefaultYAxisMargin+5, ty+(tb.Height()>>1), axisStyle)
}
+ }
+}
+
+func (sbc StackedBarChart) drawHorizontalYAxis(r Renderer, canvasBox Box) {
+ if !sbc.YAxis.Hidden {
+ axisStyle := sbc.YAxis.InheritFrom(sbc.styleDefaultsHorizontalAxes())
+ axisStyle.WriteToRenderer(r)
+
+ r.MoveTo(canvasBox.Left, canvasBox.Bottom)
+ r.LineTo(canvasBox.Left, canvasBox.Top)
+ r.Stroke()
+ r.MoveTo(canvasBox.Left, canvasBox.Bottom)
+ r.LineTo(canvasBox.Left-DefaultHorizontalTickWidth, canvasBox.Bottom)
+ r.Stroke()
+
+ cursor := canvasBox.Top
+ for _, bar := range sbc.Bars {
+ barLabelBox := Box{
+ Top: cursor,
+ Left: 0,
+ Right: canvasBox.Left - DefaultYAxisMargin,
+ Bottom: cursor + bar.GetWidth() + sbc.GetBarSpacing(),
+ }
+ if len(bar.Name) > 0 {
+ Draw.TextWithin(r, bar.Name, barLabelBox, axisStyle)
+ }
+ axisStyle.WriteToRenderer(r)
+ r.MoveTo(canvasBox.Left, barLabelBox.Bottom)
+ r.LineTo(canvasBox.Left-DefaultHorizontalTickWidth, barLabelBox.Bottom)
+ r.Stroke()
+ cursor += bar.GetWidth() + sbc.GetBarSpacing()
+ }
}
}
func (sbc StackedBarChart) drawTitle(r Renderer) {
- if len(sbc.Title) > 0 && sbc.TitleStyle.Show {
+ if len(sbc.Title) > 0 && !sbc.TitleStyle.Hidden {
r.SetFont(sbc.TitleStyle.GetFont(sbc.GetFont()))
r.SetFontColor(sbc.TitleStyle.GetFontColor(sbc.GetColorPalette().TextColor()))
titleFontSize := sbc.TitleStyle.GetFontSize(DefaultTitleFontSize)
@@ -276,7 +437,7 @@ func (sbc StackedBarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box) Box {
totalWidth += bar.GetWidth() + sbc.GetBarSpacing()
}
- if sbc.XAxis.Show {
+ if !sbc.XAxis.Hidden {
xaxisHeight := DefaultVerticalTickHeight
axisStyle := sbc.XAxis.InheritFrom(sbc.styleDefaultsAxes())
@@ -294,7 +455,7 @@ func (sbc StackedBarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box) Box {
lines := Text.WrapFit(r, bar.Name, barLabelBox.Width(), axisStyle)
linesBox := Text.MeasureLines(r, lines, axisStyle)
- xaxisHeight = util.Math.MaxInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
+ xaxisHeight = MaxInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
}
}
return Box{
@@ -313,6 +474,48 @@ func (sbc StackedBarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box) Box {
}
+func (sbc StackedBarChart) getHorizontalAdjustedCanvasBox(r Renderer, canvasBox Box) Box {
+ var totalHeight int
+ for _, bar := range sbc.Bars {
+ totalHeight += bar.GetWidth() + sbc.GetBarSpacing()
+ }
+
+ if !sbc.YAxis.Hidden {
+ yAxisWidth := DefaultHorizontalTickWidth
+
+ axisStyle := sbc.YAxis.InheritFrom(sbc.styleDefaultsHorizontalAxes())
+ axisStyle.WriteToRenderer(r)
+
+ cursor := canvasBox.Top
+ for _, bar := range sbc.Bars {
+ if len(bar.Name) > 0 {
+ barLabelBox := Box{
+ Top: cursor,
+ Left: 0,
+ Right: canvasBox.Left + DefaultYAxisMargin,
+ Bottom: cursor + bar.GetWidth() + sbc.GetBarSpacing(),
+ }
+ lines := Text.WrapFit(r, bar.Name, barLabelBox.Width(), axisStyle)
+ linesBox := Text.MeasureLines(r, lines, axisStyle)
+
+ yAxisWidth = MaxInt(linesBox.Height()+(2*DefaultXAxisMargin), yAxisWidth)
+ }
+ }
+ return Box{
+ Top: canvasBox.Top,
+ Left: canvasBox.Left + yAxisWidth,
+ Right: canvasBox.Right,
+ Bottom: canvasBox.Top + totalHeight,
+ }
+ }
+ return Box{
+ Top: canvasBox.Top,
+ Left: canvasBox.Left,
+ Right: canvasBox.Right,
+ Bottom: canvasBox.Top + totalHeight,
+ }
+}
+
// Box returns the chart bounds as a box.
func (sbc StackedBarChart) Box() Box {
dpr := sbc.Background.Padding.GetRight(10)
@@ -331,6 +534,9 @@ func (sbc StackedBarChart) styleDefaultsStackedBarValue(index int) Style {
StrokeColor: sbc.GetColorPalette().GetSeriesColor(index),
StrokeWidth: 3.0,
FillColor: sbc.GetColorPalette().GetSeriesColor(index),
+ FontSize: sbc.getScaledFontSize(),
+ FontColor: sbc.GetColorPalette().TextColor(),
+ Font: sbc.GetFont(),
}
}
@@ -345,8 +551,22 @@ func (sbc StackedBarChart) styleDefaultsTitle() Style {
})
}
+func (sbc StackedBarChart) getScaledFontSize() float64 {
+ effectiveDimension := MinInt(sbc.GetWidth(), sbc.GetHeight())
+ if effectiveDimension >= 2048 {
+ return 48.0
+ } else if effectiveDimension >= 1024 {
+ return 24.0
+ } else if effectiveDimension > 512 {
+ return 18.0
+ } else if effectiveDimension > 256 {
+ return 12.0
+ }
+ return 10.0
+}
+
func (sbc StackedBarChart) getTitleFontSize() float64 {
- effectiveDimension := util.Math.MinInt(sbc.GetWidth(), sbc.GetHeight())
+ effectiveDimension := MinInt(sbc.GetWidth(), sbc.GetHeight())
if effectiveDimension >= 2048 {
return 48
} else if effectiveDimension >= 1024 {
@@ -370,6 +590,19 @@ func (sbc StackedBarChart) styleDefaultsAxes() Style {
TextWrap: TextWrapWord,
}
}
+
+func (sbc StackedBarChart) styleDefaultsHorizontalAxes() Style {
+ return Style{
+ StrokeColor: DefaultAxisColor,
+ Font: sbc.GetFont(),
+ FontSize: DefaultAxisFontSize,
+ FontColor: DefaultAxisColor,
+ TextHorizontalAlign: TextHorizontalAlignCenter,
+ TextVerticalAlign: TextVerticalAlignMiddle,
+ TextWrap: TextWrapWord,
+ }
+}
+
func (sbc StackedBarChart) styleDefaultsElements() Style {
return Style{
Font: sbc.GetFont(),
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/stringutil.go b/vendor/github.com/wcharczuk/go-chart/v2/stringutil.go
new file mode 100644
index 0000000..858d447
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/stringutil.go
@@ -0,0 +1,57 @@
+package chart
+
+import "strings"
+
+// SplitCSV splits a corpus by the `,`, dropping leading or trailing whitespace unless quoted.
+func SplitCSV(text string) (output []string) {
+ if len(text) == 0 {
+ return
+ }
+
+ var state int
+ var word []rune
+ var opened rune
+ for _, r := range text {
+ switch state {
+ case 0: // word
+ if isQuote(r) {
+ opened = r
+ state = 1
+ } else if isCSVDelim(r) {
+ output = append(output, strings.TrimSpace(string(word)))
+ word = nil
+ } else {
+ word = append(word, r)
+ }
+ case 1: // we're in a quoted section
+ if matchesQuote(opened, r) {
+ state = 0
+ continue
+ }
+ word = append(word, r)
+ }
+ }
+
+ if len(word) > 0 {
+ output = append(output, strings.TrimSpace(string(word)))
+ }
+ return
+}
+
+func isCSVDelim(r rune) bool {
+ return r == rune(',')
+}
+
+func isQuote(r rune) bool {
+ return r == '"' || r == '\'' || r == '“' || r == '”' || r == '`'
+}
+
+func matchesQuote(a, b rune) bool {
+ if a == '“' && b == '”' {
+ return true
+ }
+ if a == '”' && b == '“' {
+ return true
+ }
+ return a == b
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/style.go b/vendor/github.com/wcharczuk/go-chart/v2/style.go
similarity index 89%
rename from vendor/github.com/wcharczuk/go-chart/style.go
rename to vendor/github.com/wcharczuk/go-chart/v2/style.go
index 9d1b268..c601d6d 100644
--- a/vendor/github.com/wcharczuk/go-chart/style.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/style.go
@@ -5,8 +5,7 @@ import (
"strings"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/drawing"
- "github.com/wcharczuk/go-chart/util"
+ "github.com/wcharczuk/go-chart/v2/drawing"
)
const (
@@ -15,10 +14,18 @@ const (
Disabled = -1
)
-// StyleShow is a prebuilt style with the `Show` property set to true.
-func StyleShow() Style {
+// Hidden is a prebuilt style with the `Hidden` property set to true.
+func Hidden() Style {
return Style{
- Show: true,
+ Hidden: true,
+ }
+}
+
+// Shown is a prebuilt style with the `Hidden` property set to false.
+// You can also think of this as the default.
+func Shown() Style {
+ return Style{
+ Hidden: false,
}
}
@@ -27,7 +34,7 @@ func StyleShow() Style {
func StyleTextDefaults() Style {
font, _ := GetDefaultFont()
return Style{
- Show: true,
+ Hidden: false,
Font: font,
FontColor: DefaultTextColor,
FontSize: DefaultTitleFontSize,
@@ -36,9 +43,11 @@ func StyleTextDefaults() Style {
// Style is a simple style set.
type Style struct {
- Show bool
+ Hidden bool
Padding Box
+ ClassName string
+
StrokeWidth float64
StrokeColor drawing.Color
StrokeDashArray []float64
@@ -64,14 +73,16 @@ type Style struct {
// IsZero returns if the object is set or not.
func (s Style) IsZero() bool {
- return s.StrokeColor.IsZero() &&
+ return !s.Hidden &&
+ s.StrokeColor.IsZero() &&
s.StrokeWidth == 0 &&
s.DotColor.IsZero() &&
s.DotWidth == 0 &&
s.FillColor.IsZero() &&
s.FontColor.IsZero() &&
s.FontSize == 0 &&
- s.Font == nil
+ s.Font == nil &&
+ s.ClassName == ""
}
// String returns a text representation of the style.
@@ -81,10 +92,16 @@ func (s Style) String() string {
}
var output []string
- if s.Show {
- output = []string{"\"show\": true"}
+ if s.Hidden {
+ output = []string{"\"hidden\": true"}
+ } else {
+ output = []string{"\"hidden\": false"}
+ }
+
+ if s.ClassName != "" {
+ output = append(output, fmt.Sprintf("\"class_name\": %s", s.ClassName))
} else {
- output = []string{"\"show\": false"}
+ output = append(output, "\"class_name\": null")
}
if !s.Padding.IsZero() {
@@ -155,6 +172,17 @@ func (s Style) String() string {
return "{" + strings.Join(output, ", ") + "}"
}
+// GetClassName returns the class name or a default.
+func (s Style) GetClassName(defaults ...string) string {
+ if s.ClassName == "" {
+ if len(defaults) > 0 {
+ return defaults[0]
+ }
+ return ""
+ }
+ return s.ClassName
+}
+
// GetStrokeColor returns the stroke color.
func (s Style) GetStrokeColor(defaults ...drawing.Color) drawing.Color {
if s.StrokeColor.IsZero() {
@@ -321,6 +349,7 @@ func (s Style) GetTextRotationDegrees(defaults ...float64) float64 {
// WriteToRenderer passes the style's options to a renderer.
func (s Style) WriteToRenderer(r Renderer) {
+ r.SetClassName(s.GetClassName())
r.SetStrokeColor(s.GetStrokeColor())
r.SetStrokeWidth(s.GetStrokeWidth())
r.SetStrokeDashArray(s.GetStrokeDashArray())
@@ -331,12 +360,13 @@ func (s Style) WriteToRenderer(r Renderer) {
r.ClearTextRotation()
if s.GetTextRotationDegrees() != 0 {
- r.SetTextRotation(util.Math.DegreesToRadians(s.GetTextRotationDegrees()))
+ r.SetTextRotation(DegreesToRadians(s.GetTextRotationDegrees()))
}
}
// WriteDrawingOptionsToRenderer passes just the drawing style options to a renderer.
func (s Style) WriteDrawingOptionsToRenderer(r Renderer) {
+ r.SetClassName(s.GetClassName())
r.SetStrokeColor(s.GetStrokeColor())
r.SetStrokeWidth(s.GetStrokeWidth())
r.SetStrokeDashArray(s.GetStrokeDashArray())
@@ -345,6 +375,7 @@ func (s Style) WriteDrawingOptionsToRenderer(r Renderer) {
// WriteTextOptionsToRenderer passes just the text style options to a renderer.
func (s Style) WriteTextOptionsToRenderer(r Renderer) {
+ r.SetClassName(s.GetClassName())
r.SetFont(s.GetFont())
r.SetFontColor(s.GetFontColor())
r.SetFontSize(s.GetFontSize())
@@ -352,6 +383,8 @@ func (s Style) WriteTextOptionsToRenderer(r Renderer) {
// InheritFrom coalesces two styles into a new style.
func (s Style) InheritFrom(defaults Style) (final Style) {
+ final.ClassName = s.GetClassName(defaults.ClassName)
+
final.StrokeColor = s.GetStrokeColor(defaults.StrokeColor)
final.StrokeWidth = s.GetStrokeWidth(defaults.StrokeWidth)
final.StrokeDashArray = s.GetStrokeDashArray(defaults.StrokeDashArray)
@@ -379,6 +412,7 @@ func (s Style) InheritFrom(defaults Style) (final Style) {
// GetStrokeOptions returns the stroke components.
func (s Style) GetStrokeOptions() Style {
return Style{
+ ClassName: s.ClassName,
StrokeDashArray: s.StrokeDashArray,
StrokeColor: s.StrokeColor,
StrokeWidth: s.StrokeWidth,
@@ -388,6 +422,7 @@ func (s Style) GetStrokeOptions() Style {
// GetFillOptions returns the fill components.
func (s Style) GetFillOptions() Style {
return Style{
+ ClassName: s.ClassName,
FillColor: s.FillColor,
}
}
@@ -395,6 +430,7 @@ func (s Style) GetFillOptions() Style {
// GetDotOptions returns the dot components.
func (s Style) GetDotOptions() Style {
return Style{
+ ClassName: s.ClassName,
StrokeDashArray: nil,
FillColor: s.DotColor,
StrokeColor: s.DotColor,
@@ -405,6 +441,7 @@ func (s Style) GetDotOptions() Style {
// GetFillAndStrokeOptions returns the fill and stroke components.
func (s Style) GetFillAndStrokeOptions() Style {
return Style{
+ ClassName: s.ClassName,
StrokeDashArray: s.StrokeDashArray,
FillColor: s.FillColor,
StrokeColor: s.StrokeColor,
@@ -415,6 +452,7 @@ func (s Style) GetFillAndStrokeOptions() Style {
// GetTextOptions returns just the text components of the style.
func (s Style) GetTextOptions() Style {
return Style{
+ ClassName: s.ClassName,
FontColor: s.FontColor,
FontSize: s.FontSize,
Font: s.Font,
diff --git a/vendor/github.com/wcharczuk/go-chart/text.go b/vendor/github.com/wcharczuk/go-chart/v2/text.go
similarity index 96%
rename from vendor/github.com/wcharczuk/go-chart/text.go
rename to vendor/github.com/wcharczuk/go-chart/v2/text.go
index a312c5b..0a9dfd0 100644
--- a/vendor/github.com/wcharczuk/go-chart/text.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/text.go
@@ -2,8 +2,6 @@ package chart
import (
"strings"
-
- util "github.com/wcharczuk/go-chart/util"
)
// TextHorizontalAlign is an enum for the horizontal alignment options.
@@ -48,7 +46,7 @@ const (
TextVerticalAlignBottom TextVerticalAlign = 2
// TextVerticalAlignMiddle aligns the text so that there is an equal amount of space above and below the top and bottom of the ligatures.
TextVerticalAlignMiddle TextVerticalAlign = 3
- // TextVerticalAlignMiddleBaseline aligns the text veritcally so that there is an equal number of pixels above and below the baseline of the string.
+ // TextVerticalAlignMiddleBaseline aligns the text vertically so that there is an equal number of pixels above and below the baseline of the string.
TextVerticalAlignMiddleBaseline TextVerticalAlign = 4
// TextVerticalAlignTop alignts the text so that the top of the ligatures are at y-pixel 0 in the container.
TextVerticalAlignTop TextVerticalAlign = 5
@@ -149,7 +147,7 @@ func (t text) MeasureLines(r Renderer, lines []string, style Style) Box {
var output Box
for index, line := range lines {
lineBox := r.MeasureText(line)
- output.Right = util.Math.MaxInt(lineBox.Right, output.Right)
+ output.Right = MaxInt(lineBox.Right, output.Right)
output.Bottom += lineBox.Height()
if index < len(lines)-1 {
output.Bottom += +style.GetTextLineSpacing()
diff --git a/vendor/github.com/wcharczuk/go-chart/tick.go b/vendor/github.com/wcharczuk/go-chart/v2/tick.go
similarity index 87%
rename from vendor/github.com/wcharczuk/go-chart/tick.go
rename to vendor/github.com/wcharczuk/go-chart/v2/tick.go
index 72ff9c5..1732c60 100644
--- a/vendor/github.com/wcharczuk/go-chart/tick.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/tick.go
@@ -4,8 +4,6 @@ import (
"fmt"
"math"
"strings"
-
- util "github.com/wcharczuk/go-chart/util"
)
// TicksProvider is a type that provides ticks.
@@ -85,15 +83,15 @@ func GenerateContinuousTicks(r Renderer, ra Range, isVertical bool, style Style,
rangeDelta := math.Abs(max - min)
tickStep := rangeDelta / float64(intermediateTickCount)
- roundTo := util.Math.GetRoundToForDelta(rangeDelta) / 10
- intermediateTickCount = util.Math.MinInt(intermediateTickCount, DefaultTickCountSanityCheck)
+ roundTo := GetRoundToForDelta(rangeDelta) / 10
+ intermediateTickCount = MinInt(intermediateTickCount, DefaultTickCountSanityCheck)
for x := 1; x < intermediateTickCount; x++ {
var tickValue float64
if ra.IsDescending() {
- tickValue = max - util.Math.RoundUp(tickStep*float64(x), roundTo)
+ tickValue = max - RoundUp(tickStep*float64(x), roundTo)
} else {
- tickValue = min + util.Math.RoundUp(tickStep*float64(x), roundTo)
+ tickValue = min + RoundUp(tickStep*float64(x), roundTo)
}
ticks = append(ticks, Tick{
Value: tickValue,
diff --git a/vendor/github.com/wcharczuk/go-chart/time_series.go b/vendor/github.com/wcharczuk/go-chart/v2/time_series.go
similarity index 73%
rename from vendor/github.com/wcharczuk/go-chart/time_series.go
rename to vendor/github.com/wcharczuk/go-chart/v2/time_series.go
index d2636a1..83ee905 100644
--- a/vendor/github.com/wcharczuk/go-chart/time_series.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/time_series.go
@@ -3,8 +3,14 @@ package chart
import (
"fmt"
"time"
+)
- util "github.com/wcharczuk/go-chart/util"
+// Interface Assertions.
+var (
+ _ Series = (*TimeSeries)(nil)
+ _ FirstValuesProvider = (*TimeSeries)(nil)
+ _ LastValuesProvider = (*TimeSeries)(nil)
+ _ ValueFormatterProvider = (*TimeSeries)(nil)
)
// TimeSeries is a line on a chart.
@@ -33,16 +39,23 @@ func (ts TimeSeries) Len() int {
return len(ts.XValues)
}
-// GetValues gets a value at a given index.
+// GetValues gets x, y values at a given index.
func (ts TimeSeries) GetValues(index int) (x, y float64) {
- x = util.Time.ToFloat64(ts.XValues[index])
+ x = TimeToFloat64(ts.XValues[index])
y = ts.YValues[index]
return
}
-// GetLastValues gets the last value.
+// GetFirstValues gets the first values.
+func (ts TimeSeries) GetFirstValues() (x, y float64) {
+ x = TimeToFloat64(ts.XValues[0])
+ y = ts.YValues[0]
+ return
+}
+
+// GetLastValues gets the last values.
func (ts TimeSeries) GetLastValues() (x, y float64) {
- x = util.Time.ToFloat64(ts.XValues[len(ts.XValues)-1])
+ x = TimeToFloat64(ts.XValues[len(ts.XValues)-1])
y = ts.YValues[len(ts.YValues)-1]
return
}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/times.go b/vendor/github.com/wcharczuk/go-chart/v2/times.go
new file mode 100644
index 0000000..95e2acd
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/times.go
@@ -0,0 +1,46 @@
+package chart
+
+import (
+ "sort"
+ "time"
+)
+
+// Assert types implement interfaces.
+var (
+ _ Sequence = (*Times)(nil)
+ _ sort.Interface = (*Times)(nil)
+)
+
+// Times are an array of times.
+// It wraps the array with methods that implement `seq.Provider`.
+type Times []time.Time
+
+// Array returns the times to an array.
+func (t Times) Array() []time.Time {
+ return []time.Time(t)
+}
+
+// Len returns the length of the array.
+func (t Times) Len() int {
+ return len(t)
+}
+
+// GetValue returns a value at an index as a time.
+func (t Times) GetValue(index int) float64 {
+ return ToFloat64(t[index])
+}
+
+// Swap implements sort.Interface.
+func (t Times) Swap(i, j int) {
+ t[i], t[j] = t[j], t[i]
+}
+
+// Less implements sort.Interface.
+func (t Times) Less(i, j int) bool {
+ return t[i].Before(t[j])
+}
+
+// ToFloat64 returns a float64 representation of a time.
+func ToFloat64(t time.Time) float64 {
+ return float64(t.UnixNano())
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/v2/timeutil.go b/vendor/github.com/wcharczuk/go-chart/v2/timeutil.go
new file mode 100644
index 0000000..aa6b9e4
--- /dev/null
+++ b/vendor/github.com/wcharczuk/go-chart/v2/timeutil.go
@@ -0,0 +1,150 @@
+package chart
+
+import "time"
+
+// SecondsPerXYZ
+const (
+ SecondsPerHour = 60 * 60
+ SecondsPerDay = 60 * 60 * 24
+)
+
+// TimeMillis returns a duration as a float millis.
+func TimeMillis(d time.Duration) float64 {
+ return float64(d) / float64(time.Millisecond)
+}
+
+// DiffHours returns the difference in hours between two times.
+func DiffHours(t1, t2 time.Time) (hours int) {
+ t1n := t1.Unix()
+ t2n := t2.Unix()
+ var diff int64
+ if t1n > t2n {
+ diff = t1n - t2n
+ } else {
+ diff = t2n - t1n
+ }
+ return int(diff / (SecondsPerHour))
+}
+
+// TimeMin returns the minimum and maximum times in a given range.
+func TimeMin(times ...time.Time) (min time.Time) {
+ if len(times) == 0 {
+ return
+ }
+ min = times[0]
+ for index := 1; index < len(times); index++ {
+ if times[index].Before(min) {
+ min = times[index]
+ }
+
+ }
+ return
+}
+
+// TimeMax returns the minimum and maximum times in a given range.
+func TimeMax(times ...time.Time) (max time.Time) {
+ if len(times) == 0 {
+ return
+ }
+ max = times[0]
+
+ for index := 1; index < len(times); index++ {
+ if times[index].After(max) {
+ max = times[index]
+ }
+ }
+ return
+}
+
+// TimeMinMax returns the minimum and maximum times in a given range.
+func TimeMinMax(times ...time.Time) (min, max time.Time) {
+ if len(times) == 0 {
+ return
+ }
+ min = times[0]
+ max = times[0]
+
+ for index := 1; index < len(times); index++ {
+ if times[index].Before(min) {
+ min = times[index]
+ }
+ if times[index].After(max) {
+ max = times[index]
+ }
+ }
+ return
+}
+
+// TimeToFloat64 returns a float64 representation of a time.
+func TimeToFloat64(t time.Time) float64 {
+ return float64(t.UnixNano())
+}
+
+// TimeFromFloat64 returns a time from a float64.
+func TimeFromFloat64(tf float64) time.Time {
+ return time.Unix(0, int64(tf))
+}
+
+// TimeDescending sorts a given list of times ascending, or min to max.
+type TimeDescending []time.Time
+
+// Len implements sort.Sorter
+func (d TimeDescending) Len() int { return len(d) }
+
+// Swap implements sort.Sorter
+func (d TimeDescending) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
+
+// Less implements sort.Sorter
+func (d TimeDescending) Less(i, j int) bool { return d[i].After(d[j]) }
+
+// TimeAscending sorts a given list of times ascending, or min to max.
+type TimeAscending []time.Time
+
+// Len implements sort.Sorter
+func (a TimeAscending) Len() int { return len(a) }
+
+// Swap implements sort.Sorter
+func (a TimeAscending) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+
+// Less implements sort.Sorter
+func (a TimeAscending) Less(i, j int) bool { return a[i].Before(a[j]) }
+
+// Days generates a seq of timestamps by day, from -days to today.
+func Days(days int) []time.Time {
+ var values []time.Time
+ for day := days; day >= 0; day-- {
+ values = append(values, time.Now().AddDate(0, 0, -day))
+ }
+ return values
+}
+
+// Hours returns a sequence of times by the hour for a given number of hours
+// after a given start.
+func Hours(start time.Time, totalHours int) []time.Time {
+ times := make([]time.Time, totalHours)
+
+ last := start
+ for i := 0; i < totalHours; i++ {
+ times[i] = last
+ last = last.Add(time.Hour)
+ }
+
+ return times
+}
+
+// HoursFilled adds zero values for the data bounded by the start and end of the xdata array.
+func HoursFilled(xdata []time.Time, ydata []float64) ([]time.Time, []float64) {
+ start, end := TimeMinMax(xdata...)
+ totalHours := DiffHours(start, end)
+
+ finalTimes := Hours(start, totalHours+1)
+ finalValues := make([]float64, totalHours+1)
+
+ var hoursFromStart int
+ for i, xd := range xdata {
+ hoursFromStart = DiffHours(start, xd)
+ finalValues[hoursFromStart] = ydata[i]
+ }
+
+ return finalTimes, finalValues
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/value.go b/vendor/github.com/wcharczuk/go-chart/v2/value.go
similarity index 85%
rename from vendor/github.com/wcharczuk/go-chart/value.go
rename to vendor/github.com/wcharczuk/go-chart/v2/value.go
index 75eedbb..783e304 100644
--- a/vendor/github.com/wcharczuk/go-chart/value.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/value.go
@@ -1,7 +1,5 @@
package chart
-import util "github.com/wcharczuk/go-chart/util"
-
// Value is a chart value.
type Value struct {
Style Style
@@ -23,7 +21,7 @@ func (vs Values) Values() []float64 {
// ValuesNormalized returns normalized values.
func (vs Values) ValuesNormalized() []float64 {
- return util.Math.Normalize(vs.Values()...)
+ return Normalize(vs.Values()...)
}
// Normalize returns the values normalized.
@@ -40,7 +38,7 @@ func (vs Values) Normalize() []Value {
output = append(output, Value{
Style: v.Style,
Label: v.Label,
- Value: util.Math.RoundDown(v.Value/total, 0.0001),
+ Value: RoundDown(v.Value/total, 0.0001),
})
}
}
diff --git a/vendor/github.com/wcharczuk/go-chart/seq/buffer.go b/vendor/github.com/wcharczuk/go-chart/v2/value_buffer.go
similarity index 79%
rename from vendor/github.com/wcharczuk/go-chart/seq/buffer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/value_buffer.go
index be7c32e..d544bd3 100644
--- a/vendor/github.com/wcharczuk/go-chart/seq/buffer.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/value_buffer.go
@@ -1,10 +1,8 @@
-package seq
+package chart
import (
"fmt"
"strings"
-
- util "github.com/wcharczuk/go-chart/util"
)
const (
@@ -14,19 +12,15 @@ const (
bufferDefaultCapacity = 4
)
-var (
- emptyArray = make([]float64, 0)
-)
-
-// NewBuffer creates a new value buffer with an optional set of values.
-func NewBuffer(values ...float64) *Buffer {
+// NewValueBuffer creates a new value buffer with an optional set of values.
+func NewValueBuffer(values ...float64) *ValueBuffer {
var tail int
- array := make([]float64, util.Math.MaxInt(len(values), bufferDefaultCapacity))
+ array := make([]float64, MaxInt(len(values), bufferDefaultCapacity))
if len(values) > 0 {
copy(array, values)
tail = len(values)
}
- return &Buffer{
+ return &ValueBuffer{
array: array,
head: 0,
tail: tail,
@@ -34,9 +28,9 @@ func NewBuffer(values ...float64) *Buffer {
}
}
-// NewBufferWithCapacity creates a new ValueBuffer pre-allocated with the given capacity.
-func NewBufferWithCapacity(capacity int) *Buffer {
- return &Buffer{
+// NewValueBufferWithCapacity creates a new ValueBuffer pre-allocated with the given capacity.
+func NewValueBufferWithCapacity(capacity int) *ValueBuffer {
+ return &ValueBuffer{
array: make([]float64, capacity),
head: 0,
tail: 0,
@@ -44,11 +38,11 @@ func NewBufferWithCapacity(capacity int) *Buffer {
}
}
-// Buffer is a fifo datastructure that is backed by a pre-allocated array.
+// ValueBuffer is a fifo datastructure that is backed by a pre-allocated array.
// Instead of allocating a whole new node object for each element, array elements are re-used (which saves GC churn).
// Enqueue can be O(n), Dequeue is generally O(1).
// Buffer implements `seq.Provider`
-type Buffer struct {
+type ValueBuffer struct {
array []float64
head int
tail int
@@ -57,23 +51,23 @@ type Buffer struct {
// Len returns the length of the Buffer (as it is currently populated).
// Actual memory footprint may be different.
-func (b *Buffer) Len() int {
+func (b *ValueBuffer) Len() int {
return b.size
}
// GetValue implements seq provider.
-func (b *Buffer) GetValue(index int) float64 {
+func (b *ValueBuffer) GetValue(index int) float64 {
effectiveIndex := (b.head + index) % len(b.array)
return b.array[effectiveIndex]
}
// Capacity returns the total size of the Buffer, including empty elements.
-func (b *Buffer) Capacity() int {
+func (b *ValueBuffer) Capacity() int {
return len(b.array)
}
// SetCapacity sets the capacity of the Buffer.
-func (b *Buffer) SetCapacity(capacity int) {
+func (b *ValueBuffer) SetCapacity(capacity int) {
newArray := make([]float64, capacity)
if b.size > 0 {
if b.head < b.tail {
@@ -93,7 +87,7 @@ func (b *Buffer) SetCapacity(capacity int) {
}
// Clear removes all objects from the Buffer.
-func (b *Buffer) Clear() {
+func (b *ValueBuffer) Clear() {
b.array = make([]float64, bufferDefaultCapacity)
b.head = 0
b.tail = 0
@@ -101,7 +95,7 @@ func (b *Buffer) Clear() {
}
// Enqueue adds an element to the "back" of the Buffer.
-func (b *Buffer) Enqueue(value float64) {
+func (b *ValueBuffer) Enqueue(value float64) {
if b.size == len(b.array) {
newCapacity := int(len(b.array) * int(bufferGrowFactor/100))
if newCapacity < (len(b.array) + bufferMinimumGrow) {
@@ -116,7 +110,7 @@ func (b *Buffer) Enqueue(value float64) {
}
// Dequeue removes the first element from the RingBuffer.
-func (b *Buffer) Dequeue() float64 {
+func (b *ValueBuffer) Dequeue() float64 {
if b.size == 0 {
return 0
}
@@ -128,7 +122,7 @@ func (b *Buffer) Dequeue() float64 {
}
// Peek returns but does not remove the first element.
-func (b *Buffer) Peek() float64 {
+func (b *ValueBuffer) Peek() float64 {
if b.size == 0 {
return 0
}
@@ -136,7 +130,7 @@ func (b *Buffer) Peek() float64 {
}
// PeekBack returns but does not remove the last element.
-func (b *Buffer) PeekBack() float64 {
+func (b *ValueBuffer) PeekBack() float64 {
if b.size == 0 {
return 0
}
@@ -147,7 +141,7 @@ func (b *Buffer) PeekBack() float64 {
}
// TrimExcess resizes the capacity of the buffer to better fit the contents.
-func (b *Buffer) TrimExcess() {
+func (b *ValueBuffer) TrimExcess() {
threshold := float64(len(b.array)) * 0.9
if b.size < int(threshold) {
b.SetCapacity(b.size)
@@ -155,7 +149,7 @@ func (b *Buffer) TrimExcess() {
}
// Array returns the ring buffer, in order, as an array.
-func (b *Buffer) Array() Array {
+func (b *ValueBuffer) Array() Array {
newArray := make([]float64, b.size)
if b.size == 0 {
@@ -173,7 +167,7 @@ func (b *Buffer) Array() Array {
}
// Each calls the consumer for each element in the buffer.
-func (b *Buffer) Each(mapfn func(int, float64)) {
+func (b *ValueBuffer) Each(mapfn func(int, float64)) {
if b.size == 0 {
return
}
@@ -197,7 +191,7 @@ func (b *Buffer) Each(mapfn func(int, float64)) {
}
// String returns a string representation for value buffers.
-func (b *Buffer) String() string {
+func (b *ValueBuffer) String() string {
var values []string
for _, elem := range b.Array() {
values = append(values, fmt.Sprintf("%v", elem))
diff --git a/vendor/github.com/wcharczuk/go-chart/value_formatter.go b/vendor/github.com/wcharczuk/go-chart/v2/value_formatter.go
similarity index 80%
rename from vendor/github.com/wcharczuk/go-chart/value_formatter.go
rename to vendor/github.com/wcharczuk/go-chart/v2/value_formatter.go
index 1c264c2..468f3bd 100644
--- a/vendor/github.com/wcharczuk/go-chart/value_formatter.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/value_formatter.go
@@ -2,6 +2,7 @@ package chart
import (
"fmt"
+ "strconv"
"time"
)
@@ -49,6 +50,22 @@ func formatTime(v interface{}, dateFormat string) string {
return ""
}
+// IntValueFormatter is a ValueFormatter for float64.
+func IntValueFormatter(v interface{}) string {
+ switch v.(type) {
+ case int:
+ return strconv.Itoa(v.(int))
+ case int64:
+ return strconv.FormatInt(v.(int64), 10)
+ case float32:
+ return strconv.FormatInt(int64(v.(float32)), 10)
+ case float64:
+ return strconv.FormatInt(int64(v.(float64)), 10)
+ default:
+ return ""
+ }
+}
+
// FloatValueFormatter is a ValueFormatter for float64.
func FloatValueFormatter(v interface{}) string {
return FloatValueFormatterWithFormat(v, DefaultFloatFormat)
@@ -65,17 +82,24 @@ func PercentValueFormatter(v interface{}) string {
// FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format.
func FloatValueFormatterWithFormat(v interface{}, floatFormat string) string {
- if typed, isTyped := v.(float64); isTyped {
- return fmt.Sprintf(floatFormat, typed)
- }
- if typed, isTyped := v.(float32); isTyped {
- return fmt.Sprintf(floatFormat, typed)
- }
if typed, isTyped := v.(int); isTyped {
return fmt.Sprintf(floatFormat, float64(typed))
}
if typed, isTyped := v.(int64); isTyped {
return fmt.Sprintf(floatFormat, float64(typed))
}
+ if typed, isTyped := v.(float32); isTyped {
+ return fmt.Sprintf(floatFormat, typed)
+ }
+ if typed, isTyped := v.(float64); isTyped {
+ return fmt.Sprintf(floatFormat, typed)
+ }
return ""
}
+
+// KValueFormatter is a formatter for K values.
+func KValueFormatter(k float64, vf ValueFormatter) ValueFormatter {
+ return func(v interface{}) string {
+ return fmt.Sprintf("%0.0fσ %s", k, vf(v))
+ }
+}
diff --git a/vendor/github.com/wcharczuk/go-chart/value_formatter_provider.go b/vendor/github.com/wcharczuk/go-chart/v2/value_formatter_provider.go
similarity index 100%
rename from vendor/github.com/wcharczuk/go-chart/value_formatter_provider.go
rename to vendor/github.com/wcharczuk/go-chart/v2/value_formatter_provider.go
diff --git a/vendor/github.com/wcharczuk/go-chart/value_provider.go b/vendor/github.com/wcharczuk/go-chart/v2/value_provider.go
similarity index 86%
rename from vendor/github.com/wcharczuk/go-chart/value_provider.go
rename to vendor/github.com/wcharczuk/go-chart/v2/value_provider.go
index e93c30d..be985eb 100644
--- a/vendor/github.com/wcharczuk/go-chart/value_provider.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/value_provider.go
@@ -1,6 +1,6 @@
package chart
-import "github.com/wcharczuk/go-chart/drawing"
+import "github.com/wcharczuk/go-chart/v2/drawing"
// ValuesProvider is a type that produces values.
type ValuesProvider interface {
@@ -14,6 +14,11 @@ type BoundedValuesProvider interface {
GetBoundedValues(index int) (x, y1, y2 float64)
}
+// FirstValuesProvider is a special type of value provider that can return it's (potentially computed) first value.
+type FirstValuesProvider interface {
+ GetFirstValues() (x, y float64)
+}
+
// LastValuesProvider is a special type of value provider that can return it's (potentially computed) last value.
type LastValuesProvider interface {
GetLastValues() (x, y float64)
diff --git a/vendor/github.com/wcharczuk/go-chart/vector_renderer.go b/vendor/github.com/wcharczuk/go-chart/v2/vector_renderer.go
similarity index 74%
rename from vendor/github.com/wcharczuk/go-chart/vector_renderer.go
rename to vendor/github.com/wcharczuk/go-chart/v2/vector_renderer.go
index 6f9b6f4..eb2fc83 100644
--- a/vendor/github.com/wcharczuk/go-chart/vector_renderer.go
+++ b/vendor/github.com/wcharczuk/go-chart/v2/vector_renderer.go
@@ -10,8 +10,7 @@ import (
"golang.org/x/image/font"
"github.com/golang/freetype/truetype"
- "github.com/wcharczuk/go-chart/drawing"
- "github.com/wcharczuk/go-chart/util"
+ "github.com/wcharczuk/go-chart/v2/drawing"
)
// SVG returns a new png/raster renderer.
@@ -28,6 +27,25 @@ func SVG(width, height int) (Renderer, error) {
}, nil
}
+// SVGWithCSS returns a new png/raster renderer with attached custom CSS
+// The optional nonce argument sets a CSP nonce.
+func SVGWithCSS(css string, nonce string) func(width, height int) (Renderer, error) {
+ return func(width, height int) (Renderer, error) {
+ buffer := bytes.NewBuffer([]byte{})
+ canvas := newCanvas(buffer)
+ canvas.css = css
+ canvas.nonce = nonce
+ canvas.Start(width, height)
+ return &vectorRenderer{
+ b: buffer,
+ c: canvas,
+ s: &Style{},
+ p: []string{},
+ dpi: DefaultDPI,
+ }, nil
+ }
+}
+
// vectorRenderer renders chart commands to a bitmap.
type vectorRenderer struct {
dpi float64
@@ -54,6 +72,11 @@ func (vr *vectorRenderer) SetDPI(dpi float64) {
vr.c.dpi = dpi
}
+// SetClassName implements the interface method.
+func (vr *vectorRenderer) SetClassName(classname string) {
+ vr.s.ClassName = classname
+}
+
// SetStrokeColor implements the interface method.
func (vr *vectorRenderer) SetStrokeColor(c drawing.Color) {
vr.s.StrokeColor = c
@@ -90,8 +113,8 @@ func (vr *vectorRenderer) QuadCurveTo(cx, cy, x, y int) {
}
func (vr *vectorRenderer) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) {
- startAngle = util.Math.RadianAdd(startAngle, _pi2)
- endAngle := util.Math.RadianAdd(startAngle, delta)
+ startAngle = RadianAdd(startAngle, _pi2)
+ endAngle := RadianAdd(startAngle, delta)
startx := cx + int(rx*math.Sin(startAngle))
starty := cy - int(ry*math.Cos(startAngle))
@@ -105,7 +128,7 @@ func (vr *vectorRenderer) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) {
endx := cx + int(rx*math.Sin(endAngle))
endy := cy - int(ry*math.Cos(endAngle))
- dd := util.Math.RadiansToDegrees(delta)
+ dd := RadiansToDegrees(delta)
largeArcFlag := 0
if delta > _pi {
@@ -182,7 +205,7 @@ func (vr *vectorRenderer) MeasureText(body string) (box Box) {
if vr.c.textTheta == nil {
return
}
- box = box.Corners().Rotate(util.Math.RadiansToDegrees(*vr.c.textTheta)).Box()
+ box = box.Corners().Rotate(RadiansToDegrees(*vr.c.textTheta)).Box()
}
return
}
@@ -217,12 +240,23 @@ type canvas struct {
textTheta *float64
width int
height int
+ css string
+ nonce string
}
func (c *canvas) Start(width, height int) {
c.width = width
c.height = height
c.w.Write([]byte(fmt.Sprintf(`