diff --git a/go.mod b/go.mod index b1d443a..6e082e8 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/unidoc/pkcs7 v0.2.0 github.com/unidoc/unichart v0.3.0 github.com/unidoc/unipdf/v3 v3.62.0 - github.com/wcharczuk/go-chart/v2 v2.1.0 golang.org/x/crypto v0.22.0 golang.org/x/image v0.18.0 golang.org/x/text v0.16.0 @@ -32,7 +31,6 @@ require ( github.com/adrg/sysfont v0.1.2 // indirect github.com/adrg/xdg v0.4.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect diff --git a/go.sum b/go.sum index a5c66f9..4d37d19 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -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= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -134,8 +132,6 @@ github.com/unidoc/unipdf/v3 v3.62.0 h1:CVsxq6k1SSIrprotlFvq6iBhA+5745dWaApB0LKtG github.com/unidoc/unipdf/v3 v3.62.0/go.mod h1:0OIzSHHno23Y8WzaK+852abK8d3AxUZ1GQkMqpyCzu8= github.com/unidoc/unitype v0.4.0 h1:/TMZ3wgwfWWX64mU5x2O9no9UmoBqYCB089LYYqHyQQ= github.com/unidoc/unitype v0.4.0/go.mod h1:HV5zuUeqMKA4QgYQq3KDlJY/P96XF90BQB+6czK6LVA= -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= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -143,7 +139,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= diff --git a/report/pdf_report.go b/report/pdf_report.go index 496900d..09bdc62 100644 --- a/report/pdf_report.go +++ b/report/pdf_report.go @@ -5,25 +5,24 @@ */ /* * NOTE: This example depends on github.com/boombuler/barcode, MIT licensed, - * and github.com/wcharczuk/go-chart, MIT licensed, + * and github.com/unidoc/unichart, MIT licensed, * and the Roboto font (Roboto-Bold.ttf, Roboto-Regular.ttf), Apache-2 licensed. */ package main import ( - "bytes" "fmt" "image" "math" "os" "time" - "github.com/wcharczuk/go-chart/v2" - "github.com/boombuler/barcode" "github.com/boombuler/barcode/qr" + "github.com/unidoc/unichart" + "github.com/unidoc/unichart/dataset" "github.com/unidoc/unipdf/v3/common" "github.com/unidoc/unipdf/v3/common/license" "github.com/unidoc/unipdf/v3/creator" @@ -452,7 +451,7 @@ func DoFeatureOverview(c *creator.Creator, fontRegular *model.PdfFont, fontBold sc.GetHeading().SetFontSize(chapterFontSize) sc.GetHeading().SetColor(chapterFontColor) - p = c.NewParagraph("Graphs can be generated via packages such as github.com/wcharczuk/go-chart as illustrated " + + p = c.NewParagraph("Graphs can be generated via packages such as github.com/unidoc/unichart as illustrated " + "in the following plot:") p.SetFont(normalFont) p.SetFontSize(normalFontSize) @@ -460,26 +459,18 @@ func DoFeatureOverview(c *creator.Creator, fontRegular *model.PdfFont, fontBold p.SetMargins(0, 0, 5, 0) sc.Add(p) - graph := chart.PieChart{ - Width: 200, - Height: 200, - Values: []chart.Value{ + chart := &unichart.PieChart{ + Values: []dataset.Value{ {Value: 70, Label: "Compliant"}, {Value: 30, Label: "Non-Compliant"}, }, } + chart.SetWidth(175) + chart.SetHeight(175) - buffer := bytes.NewBuffer([]byte{}) - err = graph.Render(chart.PNG, buffer) - if err != nil { - panic(err) - } - img, err = c.NewImageFromData(buffer.Bytes()) - if err != nil { - panic(err) - } - img.SetMargins(0, 0, 10, 0) - sc.Add(img) + // Create unipdf chart component. + chartComponent := creator.NewChart(chart) + sc.Add(chartComponent) sc = ch.NewSubchapter("Headers and footers") sc.GetHeading().SetMargins(0, 0, 20, 0) diff --git a/report/pdf_report_landscape.go b/report/pdf_report_landscape.go index 179dca3..a69d78e 100644 --- a/report/pdf_report_landscape.go +++ b/report/pdf_report_landscape.go @@ -6,25 +6,24 @@ /* * NOTE: This example depends on github.com/boombuler/barcode, MIT licensed, - * and github.com/wcharczuk/go-chart, MIT licensed, + * and github.com/unidoc/unichart, MIT licensed, * and the Roboto font (Roboto-Bold.ttf, Roboto-Regular.ttf), Apache-2 licensed. */ package main import ( - "bytes" "fmt" "image" "math" "os" "time" - "github.com/wcharczuk/go-chart/v2" - "github.com/boombuler/barcode" "github.com/boombuler/barcode/qr" + "github.com/unidoc/unichart" + "github.com/unidoc/unichart/dataset" "github.com/unidoc/unipdf/v3/common" "github.com/unidoc/unipdf/v3/common/license" "github.com/unidoc/unipdf/v3/creator" @@ -457,7 +456,7 @@ func DoFeatureOverview(c *creator.Creator, fontRegular *model.PdfFont, fontBold sc.GetHeading().SetFontSize(chapterFontSize) sc.GetHeading().SetColor(chapterFontColor) - p = c.NewParagraph("Graphs can be generated via packages such as github.com/wcharczuk/go-chart as illustrated " + + p = c.NewParagraph("Graphs can be generated via packages such as github.com/unidoc/unichart as illustrated " + "in the following plot:") p.SetFont(normalFont) p.SetFontSize(normalFontSize) @@ -465,26 +464,18 @@ func DoFeatureOverview(c *creator.Creator, fontRegular *model.PdfFont, fontBold p.SetMargins(0, 0, 5, 0) sc.Add(p) - graph := chart.PieChart{ - Width: 200, - Height: 200, - Values: []chart.Value{ + chart := &unichart.PieChart{ + Values: []dataset.Value{ {Value: 70, Label: "Compliant"}, {Value: 30, Label: "Non-Compliant"}, }, } + chart.SetWidth(175) + chart.SetHeight(175) - buffer := bytes.NewBuffer([]byte{}) - err = graph.Render(chart.PNG, buffer) - if err != nil { - panic(err) - } - img, err = c.NewImageFromData(buffer.Bytes()) - if err != nil { - panic(err) - } - img.SetMargins(0, 0, 10, 0) - sc.Add(img) + // Create unipdf chart component. + chartComponent := creator.NewChart(chart) + sc.Add(chartComponent) sc = ch.NewSubchapter("Headers and footers") sc.GetHeading().SetMargins(0, 0, 20, 0) diff --git a/report/unidoc-report-landscape.pdf b/report/unidoc-report-landscape.pdf index 7d979b1..0d5113d 100644 Binary files a/report/unidoc-report-landscape.pdf and b/report/unidoc-report-landscape.pdf differ diff --git a/report/unidoc-report.pdf b/report/unidoc-report.pdf index f876ea8..31b8f30 100644 Binary files a/report/unidoc-report.pdf and b/report/unidoc-report.pdf differ