You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It defines two methods to display go-echarts charts: Display
that immediately display the chart, and DisplayContent that returns the HTML content needed to generate
the chart -- useful for instance if the chart needs to be laid out inside other HTML content.
Note: being just screenshots these are not animated -- see examples for animated version.
Bar Chart (with code)
import (
"math/rand""github.com/go-echarts/go-echarts/v2/charts""github.com/go-echarts/go-echarts/v2/opts"
gonb_echarts "github.com/janpfeifer/gonb-echarts"
)
// generate random data for bar chartfuncgenerateBarItems() []opts.BarData {
items:=make([]opts.BarData, 0)
fori:=0; i<7; i++ {
items=append(items, opts.BarData{Value: rand.Intn(300)})
}
returnitems
}
%%bar:=charts.NewBar()
// set some global options like Title/Legend/ToolTip or anything elsebar.SetGlobalOptions(charts.WithTitleOpts(opts.Title{
Title: "My first bar chart generated by go-echarts",
Subtitle: "It's extremely easy to use, right?",
}))
// Put data into instancebar.SetXAxis([]string{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}).
AddSeries("Category A", generateBarItems()).
AddSeries("Category B", generateBarItems())
// Displayerr:=gonb_echarts.Display(bar, "width: 1024px; height:400px; background: white;")
iferr!=nil {
fmt.Printf("Error: %+v\n", err)
}
Stacked Lines
Geo Map example
Limitations
Because the charts depend on Javascript, they won't display in GitHub.
But exporting notebooks to HTML using JupyterLab will correctly include the charts.