This closes #1290 and closes #1328

- Add new smooth field in chart format parameter, support specify if smooth line chart
- Fix decimal number format round issue with build-in number format
pull/2/head
xuri 2 years ago
parent ab12307393
commit cb8bca0e92
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

@ -699,6 +699,14 @@ func TestFormattedValue2(t *testing.T) {
}) })
v = f.formattedValue(1, "43528", false) v = f.formattedValue(1, "43528", false)
assert.Equal(t, "43528", v) assert.Equal(t, "43528", v)
// formatted decimal value with build-in number format ID
styleID, err := f.NewStyle(&Style{
NumFmt: 1,
})
assert.NoError(t, err)
v = f.formattedValue(styleID, "310.56", false)
assert.Equal(t, "311", v)
} }
func TestSharedStringsError(t *testing.T) { func TestSharedStringsError(t *testing.T) {

@ -543,9 +543,6 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
}, },
Ser: f.drawChartSeries(formatSet), Ser: f.drawChartSeries(formatSet),
DLbls: f.drawChartDLbls(formatSet), DLbls: f.drawChartDLbls(formatSet),
Smooth: &attrValBool{
Val: boolPtr(false),
},
AxID: []*attrValInt{ AxID: []*attrValInt{
{Val: intPtr(754001152)}, {Val: intPtr(754001152)},
{Val: intPtr(753999904)}, {Val: intPtr(753999904)},
@ -757,6 +754,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
DLbls: f.drawChartSeriesDLbls(formatSet), DLbls: f.drawChartSeriesDLbls(formatSet),
InvertIfNegative: &attrValBool{Val: boolPtr(false)}, InvertIfNegative: &attrValBool{Val: boolPtr(false)},
Cat: f.drawChartSeriesCat(formatSet.Series[k], formatSet), Cat: f.drawChartSeriesCat(formatSet.Series[k], formatSet),
Smooth: &attrValBool{Val: boolPtr(formatSet.Series[k].Line.Smooth)},
Val: f.drawChartSeriesVal(formatSet.Series[k], formatSet), Val: f.drawChartSeriesVal(formatSet.Series[k], formatSet),
XVal: f.drawChartSeriesXVal(formatSet.Series[k], formatSet), XVal: f.drawChartSeriesXVal(formatSet.Series[k], formatSet),
YVal: f.drawChartSeriesYVal(formatSet.Series[k], formatSet), YVal: f.drawChartSeriesYVal(formatSet.Series[k], formatSet),

@ -852,7 +852,7 @@ func formatToInt(v, format string, date1904 bool) string {
if err != nil { if err != nil {
return v return v
} }
return fmt.Sprintf("%d", int64(f)) return fmt.Sprintf("%d", int64(math.Round(f)))
} }
// formatToFloat provides a function to convert original string to float // formatToFloat provides a function to convert original string to float

@ -620,9 +620,10 @@ type formatChartSeries struct {
Categories string `json:"categories"` Categories string `json:"categories"`
Values string `json:"values"` Values string `json:"values"`
Line struct { Line struct {
None bool `json:"none"` None bool `json:"none"`
Color string `json:"color"` Color string `json:"color"`
Width float64 `json:"width"` Smooth bool `json:"smooth"`
Width float64 `json:"width"`
} `json:"line"` } `json:"line"`
Marker struct { Marker struct {
Symbol string `json:"symbol"` Symbol string `json:"symbol"`

Loading…
Cancel
Save