color maps
This commit is contained in:
parent
4f15ced303
commit
fdb1b191b2
11 changed files with 577 additions and 170 deletions
28
pie_chart.go
28
pie_chart.go
|
|
@ -13,6 +13,8 @@ type PieChart struct {
|
|||
Title string
|
||||
TitleStyle Style
|
||||
|
||||
ColorPalette ColorPalette
|
||||
|
||||
Width int
|
||||
Height int
|
||||
DPI float64
|
||||
|
|
@ -195,17 +197,17 @@ func (pc PieChart) getCanvasStyle() Style {
|
|||
|
||||
func (pc PieChart) styleDefaultsCanvas() Style {
|
||||
return Style{
|
||||
FillColor: DefaultCanvasColor,
|
||||
StrokeColor: DefaultCanvasStrokeColor,
|
||||
FillColor: pc.GetColorPalette().CanvasColor(),
|
||||
StrokeColor: pc.GetColorPalette().CanvasStrokeColor(),
|
||||
StrokeWidth: DefaultStrokeWidth,
|
||||
}
|
||||
}
|
||||
|
||||
func (pc PieChart) styleDefaultsPieChartValue() Style {
|
||||
return Style{
|
||||
StrokeColor: ColorWhite,
|
||||
StrokeColor: pc.GetColorPalette().TextColor(),
|
||||
StrokeWidth: 5.0,
|
||||
FillColor: ColorWhite,
|
||||
FillColor: pc.GetColorPalette().TextColor(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,9 +215,9 @@ func (pc PieChart) stylePieChartValue(index int) Style {
|
|||
return pc.SliceStyle.InheritFrom(Style{
|
||||
StrokeColor: ColorWhite,
|
||||
StrokeWidth: 5.0,
|
||||
FillColor: GetAlternateColor(index),
|
||||
FillColor: pc.GetColorPalette().GetSeriesColor(index),
|
||||
FontSize: pc.getScaledFontSize(),
|
||||
FontColor: ColorWhite,
|
||||
FontColor: pc.GetColorPalette().TextColor(),
|
||||
Font: pc.GetFont(),
|
||||
})
|
||||
}
|
||||
|
|
@ -236,8 +238,8 @@ func (pc PieChart) getScaledFontSize() float64 {
|
|||
|
||||
func (pc PieChart) styleDefaultsBackground() Style {
|
||||
return Style{
|
||||
FillColor: DefaultBackgroundColor,
|
||||
StrokeColor: DefaultBackgroundStrokeColor,
|
||||
FillColor: pc.GetColorPalette().BackgroundColor(),
|
||||
StrokeColor: pc.GetColorPalette().BackgroundStrokeColor(),
|
||||
StrokeWidth: DefaultStrokeWidth,
|
||||
}
|
||||
}
|
||||
|
|
@ -250,7 +252,7 @@ func (pc PieChart) styleDefaultsElements() Style {
|
|||
|
||||
func (pc PieChart) styleDefaultsTitle() Style {
|
||||
return pc.TitleStyle.InheritFrom(Style{
|
||||
FontColor: ColorWhite,
|
||||
FontColor: pc.GetColorPalette().TextColor(),
|
||||
Font: pc.GetFont(),
|
||||
FontSize: pc.getTitleFontSize(),
|
||||
TextHorizontalAlign: TextHorizontalAlignCenter,
|
||||
|
|
@ -273,6 +275,14 @@ func (pc PieChart) getTitleFontSize() float64 {
|
|||
return 10
|
||||
}
|
||||
|
||||
// GetColorPalette returns the color palette for the chart.
|
||||
func (pc PieChart) GetColorPalette() ColorPalette {
|
||||
if pc.ColorPalette != nil {
|
||||
return pc.ColorPalette
|
||||
}
|
||||
return AlternateColorPalette
|
||||
}
|
||||
|
||||
// Box returns the chart bounds as a box.
|
||||
func (pc PieChart) Box() Box {
|
||||
dpr := pc.Background.Padding.GetRight(DefaultBackgroundPadding.Right)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue