forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcategoryaxisdatasource.go
55 lines (46 loc) · 1.72 KB
/
categoryaxisdatasource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// Use of this software package and source code is governed by the terms of the
// UniDoc End User License Agreement (EULA) that is available at:
// https://unidoc.io/eula/
// A trial license code for evaluation can be obtained at https://unidoc.io.
package chart
import (
crt "github.com/unidoc/unioffice/schema/soo/dml/chart"
)
// CategoryAxisDataSource specifies the data for an axis. It's commonly used with
// SetReference to set the axis data to a range of cells.
type CategoryAxisDataSource struct {
x *crt.CT_AxDataSource
}
// MakeAxisDataSource constructs an AxisDataSource wrapper.
func MakeAxisDataSource(x *crt.CT_AxDataSource) CategoryAxisDataSource {
return CategoryAxisDataSource{x}
}
// SetLabelReference is used to set the source data to a range of cells
// containing strings.
func (a CategoryAxisDataSource) SetLabelReference(s string) {
a.x.Choice = crt.NewCT_AxDataSourceChoice()
a.x.Choice.StrRef = crt.NewCT_StrRef()
a.x.Choice.StrRef.F = s
}
// SetNumberReference is used to set the source data to a range of cells containing
// numbers.
func (a CategoryAxisDataSource) SetNumberReference(s string) {
a.x.Choice = crt.NewCT_AxDataSourceChoice()
a.x.Choice.NumRef = crt.NewCT_NumRef()
a.x.Choice.NumRef.F = s
}
// SetValues is used to set the source data to a set of values.
func (a CategoryAxisDataSource) SetValues(v []string) {
a.x.Choice = crt.NewCT_AxDataSourceChoice()
a.x.Choice.StrLit = crt.NewCT_StrData()
a.x.Choice.StrLit.PtCount = crt.NewCT_UnsignedInt()
a.x.Choice.StrLit.PtCount.ValAttr = uint32(len(v))
for i, x := range v {
a.x.Choice.StrLit.Pt = append(a.x.Choice.StrLit.Pt,
&crt.CT_StrVal{
IdxAttr: uint32(i),
V: x})
}
}