- Introduce new exported ChartTickLabelPositionType enumeration - Update unit tests
This commit is contained in:
parent
53b65150ce
commit
431c31029e
21
chart.go
21
chart.go
|
@ -90,6 +90,19 @@ const (
|
|||
ChartLineAutomatic
|
||||
)
|
||||
|
||||
// ChartTickLabelPositionType is the type of supported chart tick label position
|
||||
// types.
|
||||
type ChartTickLabelPositionType byte
|
||||
|
||||
// This section defines the supported chart tick label position types
|
||||
// enumeration.
|
||||
const (
|
||||
ChartTickLabelNextToAxis ChartTickLabelPositionType = iota
|
||||
ChartTickLabelHigh
|
||||
ChartTickLabelLow
|
||||
ChartTickLabelNone
|
||||
)
|
||||
|
||||
// This section defines the default value of chart properties.
|
||||
var (
|
||||
chartView3DRotX = map[ChartType]int{
|
||||
|
@ -484,7 +497,13 @@ var (
|
|||
true: "r",
|
||||
false: "l",
|
||||
}
|
||||
valTickLblPos = map[ChartType]string{
|
||||
tickLblPosVal = map[ChartTickLabelPositionType]string{
|
||||
ChartTickLabelNextToAxis: "nextTo",
|
||||
ChartTickLabelHigh: "high",
|
||||
ChartTickLabelLow: "low",
|
||||
ChartTickLabelNone: "none",
|
||||
}
|
||||
tickLblPosNone = map[ChartType]string{
|
||||
Contour: "none",
|
||||
WireframeContour: "none",
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ func TestAddChart(t *testing.T) {
|
|||
{sheetName: "Sheet2", cell: "P1", opts: &Chart{Type: Line3D, Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: []RichTextRun{{Text: "3D Line Chart"}}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}}},
|
||||
{sheetName: "Sheet2", cell: "X1", opts: &Chart{Type: Scatter, Series: series, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: []RichTextRun{{Text: "Scatter Chart"}}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
|
||||
{sheetName: "Sheet2", cell: "P16", opts: &Chart{Type: Doughnut, Series: series3, Format: format, Legend: ChartLegend{Position: "right", ShowLegendKey: false}, Title: []RichTextRun{{Text: "Doughnut Chart"}}, PlotArea: ChartPlotArea{ShowBubbleSize: false, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false}, ShowBlanksAs: "zero", HoleSize: 30}},
|
||||
{sheetName: "Sheet2", cell: "X16", opts: &Chart{Type: Line, Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: []RichTextRun{{Text: "Line Chart"}}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1}}},
|
||||
{sheetName: "Sheet2", cell: "X16", opts: &Chart{Type: Line, Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: []RichTextRun{{Text: "Line Chart"}}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1, TickLabelPosition: ChartTickLabelLow}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1}}},
|
||||
{sheetName: "Sheet2", cell: "P32", opts: &Chart{Type: Pie3D, Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: []RichTextRun{{Text: "3D Column Chart"}}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
|
||||
{sheetName: "Sheet2", cell: "X32", opts: &Chart{Type: Pie, Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: []RichTextRun{{Text: "Pie Chart"}}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false, NumFmt: ChartNumFmt{CustomNumFmt: "0.00%;0;;"}}, ShowBlanksAs: "gap"}},
|
||||
// bar series chart
|
||||
|
|
|
@ -1001,7 +1001,7 @@ func (f *File) drawPlotAreaCatAx(pa *cPlotArea, opts *Chart) []*cAxs {
|
|||
MajorTickMark: &attrValString{Val: stringPtr("none")},
|
||||
MinorTickMark: &attrValString{Val: stringPtr("none")},
|
||||
Title: f.drawPlotAreaTitles(opts.XAxis.Title, ""),
|
||||
TickLblPos: &attrValString{Val: stringPtr("nextTo")},
|
||||
TickLblPos: &attrValString{Val: stringPtr(tickLblPosVal[opts.XAxis.TickLabelPosition])},
|
||||
SpPr: f.drawPlotAreaSpPr(),
|
||||
TxPr: f.drawPlotAreaTxPr(&opts.XAxis),
|
||||
CrossAx: &attrValInt{Val: intPtr(100000001)},
|
||||
|
@ -1063,7 +1063,7 @@ func (f *File) drawPlotAreaValAx(pa *cPlotArea, opts *Chart) []*cAxs {
|
|||
},
|
||||
MajorTickMark: &attrValString{Val: stringPtr("none")},
|
||||
MinorTickMark: &attrValString{Val: stringPtr("none")},
|
||||
TickLblPos: &attrValString{Val: stringPtr("nextTo")},
|
||||
TickLblPos: &attrValString{Val: stringPtr(tickLblPosVal[opts.YAxis.TickLabelPosition])},
|
||||
SpPr: f.drawPlotAreaSpPr(),
|
||||
TxPr: f.drawPlotAreaTxPr(&opts.YAxis),
|
||||
CrossAx: &attrValInt{Val: intPtr(100000000)},
|
||||
|
@ -1079,7 +1079,7 @@ func (f *File) drawPlotAreaValAx(pa *cPlotArea, opts *Chart) []*cAxs {
|
|||
if opts.YAxis.MinorGridLines {
|
||||
ax.MinorGridlines = &cChartLines{SpPr: f.drawPlotAreaSpPr()}
|
||||
}
|
||||
if pos, ok := valTickLblPos[opts.Type]; ok {
|
||||
if pos, ok := tickLblPosNone[opts.Type]; ok {
|
||||
ax.TickLblPos.Val = stringPtr(pos)
|
||||
}
|
||||
if opts.YAxis.MajorUnit != 0 {
|
||||
|
@ -1115,7 +1115,7 @@ func (f *File) drawPlotAreaSerAx(opts *Chart) []*cAxs {
|
|||
},
|
||||
Delete: &attrValBool{Val: boolPtr(opts.YAxis.None)},
|
||||
AxPos: &attrValString{Val: stringPtr(catAxPos[opts.XAxis.ReverseOrder])},
|
||||
TickLblPos: &attrValString{Val: stringPtr("nextTo")},
|
||||
TickLblPos: &attrValString{Val: stringPtr(tickLblPosVal[opts.YAxis.TickLabelPosition])},
|
||||
SpPr: f.drawPlotAreaSpPr(),
|
||||
TxPr: f.drawPlotAreaTxPr(nil),
|
||||
CrossAx: &attrValInt{Val: intPtr(100000001)},
|
||||
|
|
|
@ -534,6 +534,7 @@ type ChartAxis struct {
|
|||
MajorGridLines bool
|
||||
MinorGridLines bool
|
||||
MajorUnit float64
|
||||
TickLabelPosition ChartTickLabelPositionType
|
||||
TickLabelSkip int
|
||||
ReverseOrder bool
|
||||
Secondary bool
|
||||
|
|
Loading…
Reference in New Issue