@@ -171,7 +171,7 @@ func TestAddChart(t *testing.T) {
171
171
Width : 1 ,
172
172
},
173
173
},
174
- },
174
+ Legend : ChartLegend { Font : & Font { Family : "Arial" , Size : 11 , Strike : true , Color : "777777" }} },
175
175
}
176
176
series2 := []ChartSeries {
177
177
{
@@ -225,7 +225,7 @@ func TestAddChart(t *testing.T) {
225
225
{sheetName : "Sheet1" , cell : "P1" , opts : & Chart {Type : Col , Series : series , Format : format , Legend : ChartLegend {Position : "none" , ShowLegendKey : true }, Title : []RichTextRun {{Text : "2D Column Chart" , Font : & Font {Size : 11 , Family : "Calibri" }}}, PlotArea : plotArea , Border : ChartLine {Type : ChartLineNone }, ShowBlanksAs : "zero" , XAxis : ChartAxis {Font : Font {Bold : true , Italic : true , Underline : "dbl" , Family : "Times New Roman" , Size : 15 , Strike : true , Color : "000000" }, Title : []RichTextRun {{Text : "Primary Horizontal Axis Title" }}}, YAxis : ChartAxis {Font : Font {Bold : false , Italic : false , Underline : "sng" , Color : "777777" }, Title : []RichTextRun {{Text : "Primary Vertical Axis Title" , Font : & Font {Color : "777777" , Bold : true , Italic : true , Size : 12 }}}}}},
226
226
{sheetName : "Sheet1" , cell : "X1" , opts : & Chart {Type : ColStacked , Series : series , Format : format , Legend : legend , Title : []RichTextRun {{Text : "2D Stacked Column Chart" }}, PlotArea : plotArea , Fill : Fill {Type : "pattern" , Pattern : 1 }, Border : ChartLine {Type : ChartLineAutomatic }, ShowBlanksAs : "zero" , GapWidth : uintPtr (10 ), Overlap : intPtr (100 )}},
227
227
{sheetName : "Sheet1" , cell : "P16" , opts : & Chart {Type : ColPercentStacked , Series : series , Format : format , Legend : legend , Title : []RichTextRun {{Text : "100% Stacked Column Chart" }}, PlotArea : plotArea , Fill : Fill {Type : "pattern" , Color : []string {"EEEEEE" }, Pattern : 1 }, Border : ChartLine {Type : ChartLineSolid , Width : 2 }, ShowBlanksAs : "zero" , XAxis : ChartAxis {Alignment : Alignment {Vertical : "wordArtVertRtl" , TextRotation : 0 }}}},
228
- {sheetName : "Sheet1" , cell : "X16" , opts : & Chart {Type : Col3DClustered , Series : series , Format : format , Legend : ChartLegend {Position : "bottom" , ShowLegendKey : false }, Title : []RichTextRun {{Text : "3D Clustered Column Chart" }}, PlotArea : plotArea , ShowBlanksAs : "zero" }},
228
+ {sheetName : "Sheet1" , cell : "X16" , opts : & Chart {Type : Col3DClustered , Series : series , Format : format , Legend : ChartLegend {Position : "bottom" , ShowLegendKey : false , Font : & Font { Size : 10 } }, Title : []RichTextRun {{Text : "3D Clustered Column Chart" }}, PlotArea : plotArea , ShowBlanksAs : "zero" }},
229
229
{sheetName : "Sheet1" , cell : "P30" , opts : & Chart {Type : Col3DStacked , Series : series , Format : format , Legend : legend , Title : []RichTextRun {{Text : "3D Stacked Column Chart" }}, PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis {Alignment : Alignment {Vertical : "vert" , TextRotation : 0 }}}},
230
230
{sheetName : "Sheet1" , cell : "X30" , opts : & Chart {Type : Col3DPercentStacked , Series : series , Format : format , Legend : legend , Title : []RichTextRun {{Text : "3D 100% Stacked Column Chart" }}, PlotArea : plotArea , ShowBlanksAs : "zero" }},
231
231
{sheetName : "Sheet1" , cell : "X45" , opts : & Chart {Type : Radar , Series : series , Format : format , Legend : ChartLegend {Position : "top_right" , ShowLegendKey : false }, Title : []RichTextRun {{Text : "Radar Chart" }}, PlotArea : plotArea , ShowBlanksAs : "span" }},
@@ -324,57 +324,6 @@ func TestAddChart(t *testing.T) {
324
324
assert .EqualError (t , f .AddChart ("Sheet1" , "P1" , & Chart {Type : Col , Series : []ChartSeries {{Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" }}, Title : []RichTextRun {{Text : "2D Column Chart" }}}), "XML syntax error on line 1: invalid UTF-8" )
325
325
}
326
326
327
- func TestChartLegendFont (t * testing.T ) {
328
- f := NewFile ()
329
- categories := map [string ]string {"A2" : "Small" , "A3" : "Normal" , "A4" : "Large" , "B1" : "Apple" , "C1" : "Orange" , "D1" : "Pear" }
330
- values := map [string ]int {"B2" : 2 , "C2" : 3 , "D2" : 3 , "B3" : 5 , "C3" : 2 , "D3" : 4 , "B4" : 6 , "C4" : 7 , "D4" : 8 }
331
-
332
- for k , v := range categories {
333
- assert .NoError (t , f .SetCellValue ("Sheet1" , k , v ))
334
- }
335
- for k , v := range values {
336
- assert .NoError (t , f .SetCellValue ("Sheet1" , k , v ))
337
- }
338
-
339
- series := []ChartSeries {
340
- {Name : "Sheet1!$B$1" , Categories : "Sheet1!$A$2:$A$4" , Values : "Sheet1!$B$2:$B$4" },
341
- {Name : "Sheet1!$C$1" , Categories : "Sheet1!$A$2:$A$4" , Values : "Sheet1!$C$2:$C$4" },
342
- {Name : "Sheet1!$D$1" , Categories : "Sheet1!$A$2:$A$4" , Values : "Sheet1!$D$2:$D$4" },
343
- }
344
-
345
- // Test chart with legend font settings
346
- assert .NoError (t , f .AddChart ("Sheet1" , "E1" , & Chart {
347
- Type : Col ,
348
- Series : series ,
349
- Title : []RichTextRun {{Text : "Chart with Legend Font" }},
350
- Legend : ChartLegend {
351
- Position : "bottom" ,
352
- Font : Font {
353
- Family : "Aptos" ,
354
- Color : "#3E3E3E" ,
355
- Size : 10 ,
356
- Bold : true ,
357
- },
358
- },
359
- }))
360
-
361
- // Test chart with none position (should not cause errors)
362
- assert .NoError (t , f .AddChart ("Sheet1" , "E16" , & Chart {
363
- Type : Col ,
364
- Series : series ,
365
- Title : []RichTextRun {{Text : "Chart without Legend" }},
366
- Legend : ChartLegend {
367
- Position : "none" ,
368
- Font : Font {
369
- Family : "Calibri" ,
370
- Size : 12 ,
371
- },
372
- },
373
- }))
374
-
375
- assert .NoError (t , f .SaveAs (filepath .Join ("test" , "TestChartLegendFont.xlsx" )))
376
- }
377
-
378
327
func TestAddChartSheet (t * testing.T ) {
379
328
categories := map [string ]string {"A2" : "Small" , "A3" : "Normal" , "A4" : "Large" , "B1" : "Apple" , "C1" : "Orange" , "D1" : "Pear" }
380
329
values := map [string ]int {"B2" : 2 , "C2" : 3 , "D2" : 3 , "B3" : 5 , "C3" : 2 , "D3" : 4 , "B4" : 6 , "C4" : 7 , "D4" : 8 }
0 commit comments