Skip to content

Commit db34b1d

Browse files
committed
Add 4 stock chart support for AddChart function
1 parent dd07139 commit db34b1d

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

chart.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ const (
7878
WireframeContour
7979
Bubble
8080
Bubble3D
81+
HighLowCloseChart
82+
OpenHighLowCloseChart
8183
)
8284

8385
// ChartDashType is the type of supported chart dash types.
@@ -755,6 +757,8 @@ func (opts *Chart) parseTitle() {
755757
// 52 | WireframeContour | wireframe contour chart
756758
// 53 | Bubble | bubble chart
757759
// 54 | Bubble3D | 3D bubble chart
760+
// 55 | HighLowCloseChart | High-Low-Close stock chart
761+
// 56 | OpenHighLowCloseChart | Open-High-Low-Close stock chart
758762
//
759763
// In Excel a chart series is a collection of information that defines which
760764
// data is plotted such as values, axis labels and formatting.

drawing.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ func (f *File) addChart(opts *Chart, comboCharts []*Chart) {
159159
WireframeContour: f.drawSurfaceChart,
160160
Bubble: f.drawBubbleChart,
161161
Bubble3D: f.drawBubbleChart,
162+
HighLowCloseChart: f.drawStockChart,
163+
OpenHighLowCloseChart: f.drawStockChart,
162164
}
163165
xlsxChartSpace.Chart.drawChartLegend(opts)
164166
xlsxChartSpace.Chart.PlotArea.SpPr = f.drawShapeFill(opts.PlotArea.Fill, xlsxChartSpace.Chart.PlotArea.SpPr)
@@ -689,6 +691,26 @@ func (f *File) drawBubbleChart(pa *cPlotArea, opts *Chart) *cPlotArea {
689691
return plotArea
690692
}
691693

694+
func (f *File) drawStockChart(pa *cPlotArea, opts *Chart) *cPlotArea {
695+
plotArea := &cPlotArea{
696+
StockChart: []*cCharts{
697+
{
698+
VaryColors: &attrValBool{
699+
Val: opts.VaryColors,
700+
},
701+
Ser: f.drawChartSeries(opts),
702+
DLbls: f.drawChartDLbls(opts),
703+
AxID: f.genAxID(opts),
704+
},
705+
},
706+
ValAx: f.drawPlotAreaValAx(pa, opts),
707+
DateAx: f.drawPlotAreaCatAx(pa, opts),
708+
}
709+
ser := *plotArea.StockChart[0].Ser
710+
ser[0].Val.NumRef.NumCache = &cNumCache{}
711+
return plotArea
712+
}
713+
692714
// drawChartGapWidth provides a function to draw the c:gapWidth element by given
693715
// format sets.
694716
func (f *File) drawChartGapWidth(opts *Chart) *attrValInt {

xmlChart.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ type cPlotArea struct {
356356
DoughnutChart []*cCharts `xml:"doughnutChart"`
357357
LineChart []*cCharts `xml:"lineChart"`
358358
Line3DChart []*cCharts `xml:"line3DChart"`
359+
StockChart []*cCharts `xml:"stockChart"`
359360
PieChart []*cCharts `xml:"pieChart"`
360361
Pie3DChart []*cCharts `xml:"pie3DChart"`
361362
OfPieChart []*cCharts `xml:"ofPieChart"`
@@ -365,6 +366,7 @@ type cPlotArea struct {
365366
SurfaceChart []*cCharts `xml:"surfaceChart"`
366367
CatAx []*cAxs `xml:"catAx"`
367368
ValAx []*cAxs `xml:"valAx"`
369+
DateAx []*cAxs `xml:"dateAx"`
368370
SerAx []*cAxs `xml:"serAx"`
369371
DTable *cDTable `xml:"dTable"`
370372
SpPr *cSpPr `xml:"spPr"`

0 commit comments

Comments
 (0)