-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 gsheet improvement structure of code
- Loading branch information
StanGirard
committed
Aug 2, 2022
1 parent
3980071
commit 790f199
Showing
8 changed files
with
390 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package gsheet | ||
|
||
import ( | ||
"google.golang.org/api/sheets/v4" | ||
) | ||
|
||
func createBasicChartSeries(values [][]interface{}) []*sheets.BasicChartSeries { | ||
var BasicChartSeries []*sheets.BasicChartSeries | ||
for i := range values { | ||
if i == 0 { | ||
continue | ||
} | ||
BasicChartSeries = append(BasicChartSeries, &sheets.BasicChartSeries{ | ||
Series: &sheets.ChartData{ | ||
SourceRange: &sheets.ChartSourceRange{ | ||
Sources: []*sheets.GridRange{ | ||
{ //A2:O2 | ||
SheetId: 1023, | ||
StartRowIndex: int64(i), | ||
EndRowIndex: int64(i + 1), | ||
StartColumnIndex: 0, | ||
EndColumnIndex: int64(len(values[i])), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
return BasicChartSeries | ||
} | ||
|
||
func createHistogramSeries(values [][]interface{}) []*sheets.HistogramSeries { | ||
var HistogramSeries []*sheets.HistogramSeries | ||
for i := range values { | ||
if i == 0 { | ||
continue | ||
} | ||
HistogramSeries = append(HistogramSeries, &sheets.HistogramSeries{ | ||
Data: &sheets.ChartData{ | ||
SourceRange: &sheets.ChartSourceRange{ | ||
Sources: []*sheets.GridRange{ | ||
{ //A2:O2 | ||
SheetId: 1023, | ||
StartRowIndex: int64(i), | ||
EndRowIndex: int64(i + 1), | ||
StartColumnIndex: 0, | ||
EndColumnIndex: int64(len(values[i])), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
return HistogramSeries | ||
} | ||
|
||
func createBasicChartSpec(legendPosition, chartype, stackedType string, sourceSheetId int64, values [][]interface{}, basicChartSeries []*sheets.BasicChartSeries) *sheets.BasicChartSpec { | ||
var BasicChartSpec *sheets.BasicChartSpec | ||
BasicChartSpec = &sheets.BasicChartSpec{ | ||
HeaderCount: 1, | ||
Series: basicChartSeries, | ||
LegendPosition: "BOTTOM_LEGEND", | ||
ChartType: "COLUMN", | ||
StackedType: "STACKED", | ||
Domains: []*sheets.BasicChartDomain{ | ||
{ | ||
Domain: &sheets.ChartData{ | ||
SourceRange: &sheets.ChartSourceRange{ | ||
Sources: []*sheets.GridRange{ | ||
{ | ||
SheetId: 1023, | ||
StartRowIndex: 0, | ||
EndRowIndex: 1, | ||
StartColumnIndex: 0, | ||
EndColumnIndex: int64(len(values[0])), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
return BasicChartSpec | ||
} |
Oops, something went wrong.