Creating Radar Chart

This guide will demonstrate how to create a radar chart using UniOffice.

Before you begin

You should get your API key from your UniCloud account.

If this is your first time using UniOffice SDK, follow this guide to set up a local development environment.

Clone the project repository

In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.

git clone

To get the example navigate to the path spreadsheet/radar-chart folder in the unioffice-examples directory.

cd unioffice-examples/spreadsheet/radar-chart/

How it works

The `import` section in lines `4-11`, imports the necessary libraries. The `init` function defined in lines `13-20` the metered license key is set to authorize the use of the `UniOffice` library.

The main function starts in line 22. Then a new workbook with an empty sheet is created in lines 23-25 using:

ss := spreadsheet.New()
defer ss.Close()
sheet := ss.AddSheet()

In lines 28-32, the header row is created. Then using the for loop in lines 33-39 creates the rest of the rows with data. The drawing and the chart are created using:

dwng := ss.AddDrawing()
chart, anc := dwng.AddChart(spreadsheet.AnchorTypeTwoCell)

Line 46 creates a radar chart by calling AddRadarChart method of the Chart object. A RadarChartSeries with a text price is created from RadarChart. The labels for this series is taken from the cells A2-A6 of Sheet1, And the values are taken from the cell ranges B2:B6 of sheet1. This is accomplished using the following piece of code.

priceSeries.CategoryAxis().SetLabelReference(`'Sheet 1'!A2:A6`)
priceSeries.Values().SetReference(`'Sheet 1'!B2:B6`)

Lines 53-61 create two RadarChartSeries named soldSeries and totalSeriese using the same way. Only the cell range for the value reference are changed. Then the axis are set in lines 64-70. Setting the title and legend is done 73-75. In line 78 the drawing is set using sheet.SetDrawing(dwng). Finally, the workbook is validated and saved to file using:

if err := ss.Validate(); err != nil {
  log.Fatalf("error validating sheet: %s", err)

Run the code

Use the following command to run the code.

go run main.go

Sample Output

preview image

Got any Questions?

We're here to help you.