@@ -291,18 +291,12 @@ internal void SetLegend(SvgChart sc, double entryWidth, double entryHeight)
291291 private void SetLineLegend ( SvgChart sc , int index , SvgLegendSerie pSls , eLegendPosition pos , ExcelChartSerie s , SvgLegendSerie sls , double entryWidth , double entryHeight )
292292 {
293293 var ls = ( ExcelLineChartSerie ) s ;
294- var tm = _seriesHeadersMeasure [ index ] ;
295- TextMeasurement prevTm = tm ;
296- if ( pSls != null )
297- {
298- prevTm = _seriesHeadersMeasure [ index - 1 ] ;
299- }
300294
301- var si = GetLineSeriesIcon ( sc , ls , prevTm , tm , pSls , entryWidth , entryHeight ) ;
295+ var si = GetLineSeriesIcon ( sc , ls , pSls , entryWidth , entryHeight ) ;
302296 sls . SeriesIcon = si ;
303297
304298 var tbLeft = si . X2 + MarginExtra ;
305- var tbTop = si . Y2 - tm . Height * 0.5 ; //TODO:Should probably be font ascent
299+ var tbTop = si . Y2 - entryHeight * 0.5 ; //TODO:Should probably be font ascent
306300 double tbWidth ;
307301 if ( pos == eLegendPosition . Left || pos == eLegendPosition . Right )
308302 {
@@ -313,15 +307,13 @@ private void SetLineLegend(SvgChart sc, int index, SvgLegendSerie pSls, eLegendP
313307 tbWidth = Bounds . Width - tbLeft - RightMargin ;
314308 }
315309
316- var tbHeight = tm . Height ;
310+ var tbHeight = entryHeight ;
317311 sls . Textbox = new SvgTextBodyItem ( ChartRenderer , Bounds , tbLeft , tbTop , tbWidth , tbHeight , false , true ) ;
318- //sls.Textbox.Bounds.Left = si.X2 + MarginExtra;
319312
320313 var entry = Chart . Legend . Entries . FirstOrDefault ( x => x . Index == index ) ;
321314 var headerText = s . GetHeaderText ( index ) ;
322315 if ( entry == null || entry . Font . IsEmpty )
323316 {
324- //sls.Textbox.AddText(s.GetHeaderText(), sc.Chart.Legend.Font);
325317 sls . Textbox . ImportParagraph ( sc . Chart . Legend . TextBody . Paragraphs . FirstOrDefault ( ) , 0 , headerText ) ;
326318 }
327319 else
@@ -352,12 +344,7 @@ private void SetBarLegend(SvgChart sc, int index, SvgLegendSerie pSls, eLegendPo
352344 {
353345 var bs = ( ExcelBarChartSerie ) s ;
354346 var tm = _seriesHeadersMeasure [ index ] ;
355- TextMeasurement prevTm = tm ;
356- if ( pSls != null )
357- {
358- prevTm = _seriesHeadersMeasure [ index - 1 ] ;
359- }
360- var si = GetBarSeriesIcon ( sc , bs , prevTm , tm , pSls , entryWidth , entryHeight ) ;
347+ var si = GetBarSeriesIcon ( sc , bs , pSls , entryWidth , entryHeight ) ;
361348 sls . SeriesIcon = si ;
362349
363350 var tbLeft = si . Right + MarginExtra ;
@@ -384,14 +371,14 @@ private void SetBarLegend(SvgChart sc, int index, SvgLegendSerie pSls, eLegendPo
384371 }
385372 }
386373
387- private SvgRenderLineItem GetLineSeriesIcon ( SvgChart sc , ExcelChartStandardSerie cStandardSerie , TextMeasurement pTm , TextMeasurement tm , SvgLegendSerie pSls , double entryWidth , double entryHeight )
374+ private SvgRenderLineItem GetLineSeriesIcon ( SvgChart sc , ExcelChartStandardSerie cStandardSerie , SvgLegendSerie pSls , double entryWidth , double entryHeight )
388375 {
389376 var line = new SvgRenderLineItem ( sc , Rectangle . Bounds ) ;
390377 line . SetDrawingPropertiesFill ( cStandardSerie . Fill , sc . Chart . StyleManager . Style . SeriesLine . FillReference . Color ) ;
391378 line . SetDrawingPropertiesBorder ( cStandardSerie . Border , sc . Chart . StyleManager . Style . SeriesLine . BorderReference . Color , cStandardSerie . Border . Fill . Style != eFillStyle . NoFill , 0.75 ) ;
392379 var icon = pSls ? . SeriesIcon as SvgRenderLineItem ;
393380
394- GetItemPosition ( sc , pTm , tm , pSls , entryWidth , entryHeight , icon ? . X1 ?? 0D , icon ? . Y1 ?? 0D , out double x , out double y ) ;
381+ GetItemPosition ( sc , pSls , entryWidth , entryHeight , icon ? . X1 ?? 0D , icon ? . Y1 ?? 0D , out double x , out double y ) ;
395382
396383 line . X1 = x ;
397384 line . Y1 = y ;
@@ -402,15 +389,15 @@ private SvgRenderLineItem GetLineSeriesIcon(SvgChart sc, ExcelChartStandardSerie
402389 return line ;
403390 }
404391
405- private SvgRenderRectItem GetBarSeriesIcon ( SvgChart sc , ExcelChartStandardSerie cStandardSerie , TextMeasurement pTm , TextMeasurement tm , SvgLegendSerie pSls , double entryWidth , double entryHeight )
392+ private SvgRenderRectItem GetBarSeriesIcon ( SvgChart sc , ExcelChartStandardSerie cStandardSerie , SvgLegendSerie pSls , double entryWidth , double entryHeight )
406393 {
407394 var item = new SvgRenderRectItem ( sc , Rectangle . Bounds ) ;
408395 item . SetDrawingPropertiesFill ( cStandardSerie . Fill , sc . Chart . StyleManager . Style . SeriesLine . FillReference . Color ) ;
409396 item . SetDrawingPropertiesBorder ( cStandardSerie . Border , sc . Chart . StyleManager . Style . SeriesLine . BorderReference . Color , cStandardSerie . Border . Fill . Style != eFillStyle . NoFill , 0.75 ) ;
410397 var iconHeight = GetIconLenght ( sc , entryHeight ) ;
411398 var icon = pSls ? . SeriesIcon as SvgRenderRectItem ;
412399
413- GetItemPosition ( sc , pTm , tm , pSls , entryWidth , entryHeight , icon ? . Left ?? 0D , icon ? . Top ?? 0D , out double x , out double y ) ;
400+ GetItemPosition ( sc , pSls , entryWidth , entryHeight , icon ? . Left ?? 0D , icon ? . Top ?? 0D , out double x , out double y ) ;
414401
415402 item . LineCap = eLineCap . Round ;
416403 item . Left = x ;
@@ -421,7 +408,7 @@ private SvgRenderRectItem GetBarSeriesIcon(SvgChart sc, ExcelChartStandardSerie
421408 return item ;
422409 }
423410
424- private double GetItemPosition ( SvgChart sc , TextMeasurement pTm , TextMeasurement tm , SvgLegendSerie pSls , double entryWidth , double entryHeight , double iconLeft , double iconTop , out double x , out double y )
411+ private double GetItemPosition ( SvgChart sc , SvgLegendSerie pSls , double entryWidth , double entryHeight , double iconLeft , double iconTop , out double x , out double y )
425412 {
426413 var topOffset = 0D ;
427414 if ( sc . Chart . Legend . Position == eLegendPosition . Top ||
@@ -445,7 +432,7 @@ private double GetItemPosition(SvgChart sc, TextMeasurement pTm, TextMeasurement
445432 }
446433 if ( pSls == null )
447434 {
448- y = Rectangle . Top + TopMargin + tm . Height / 2 ;
435+ y = Rectangle . Top + TopMargin + entryHeight / 2 ;
449436 }
450437 else
451438 {
@@ -458,11 +445,11 @@ private double GetItemPosition(SvgChart sc, TextMeasurement pTm, TextMeasurement
458445 {
459446 if ( pSls == null )
460447 {
461- y = TopMargin ;
448+ y = TopMargin + entryHeight / 2 ;
462449 }
463450 else
464451 {
465- y = pSls . Textbox . Bounds . Bottom + MiddleMargin ;
452+ y = pSls . Textbox . Bounds . Top + entryHeight + MiddleMargin ;
466453 }
467454 x = LeftMargin ;
468455
0 commit comments