@@ -747,6 +747,16 @@ private static bool IsCompatibleUnitOfMeasure(UnitOfMeasure seriesUnitOfMeasure,
747747 return seriesUnitOfMeasure == filterUnitOfMeasure ;
748748 }
749749
750+ private static string GetChartLabel ( SeriesTransformations seriesTransformation , string ? customTransformation , string defaultLabel , SeriesAggregationOptions seriesAggregationOptions )
751+ {
752+ return seriesTransformation switch
753+ {
754+ SeriesTransformations . DayOfYearIfFrost => seriesAggregationOptions == SeriesAggregationOptions . Maximum ? "Last day of frost" : "First day of frost" ,
755+ SeriesTransformations . Custom => ChartSeriesDefinition . GetFriendlyCustomTransformationLabel ( customTransformation ?? "Custom transformation" ) ,
756+ _ => defaultLabel ,
757+ } ;
758+ }
759+
750760 private object CreateChartOptions ( string title , string subtitle , dynamic scales )
751761 {
752762 return new
@@ -1109,44 +1119,6 @@ await ChartLogic.AddDataSetToChart(
11091119 return trendlines ;
11101120 }
11111121
1112- private void RebuildChartSeriesListToReflectSelectedYears ( )
1113- {
1114- var years = SelectedYears ! . Any ( ) ? SelectedYears ! . Select ( x => ( short ? ) x ) . ToList ( ) : new List < short ? > ( ) { null } ;
1115-
1116- List < ChartSeriesDefinition > newCsds = new List < ChartSeriesDefinition > ( ) ;
1117-
1118- var uniqueChartSeriesList = ChartSeriesList ! . Distinct ( new ChartSeriesDefinition . ChartSeriesDefinitionComparerWhichIgnoresYearAndIsLocked ( ) ) . ToArray ( ) ;
1119-
1120- foreach ( var csd in uniqueChartSeriesList )
1121- {
1122- foreach ( var year in years )
1123- {
1124- newCsds . Add (
1125- new ChartSeriesDefinition ( )
1126- {
1127- SeriesDerivationType = SeriesDerivationTypes . ReturnSingleSeries ,
1128- SourceSeriesSpecifications = csd . SourceSeriesSpecifications ,
1129- Aggregation = csd . Aggregation ,
1130- BinGranularity = year == null ? BinGranularities . ByYear : BinGranularities . ByYearAndMonth ,
1131- DisplayStyle = csd . DisplayStyle ,
1132- IsLocked = csd . IsLocked ,
1133- ShowTrendline = csd . ShowTrendline ,
1134- SecondaryCalculation = csd . SecondaryCalculation ,
1135- Smoothing = csd . Smoothing ,
1136- SmoothingWindow = csd . SmoothingWindow ,
1137- Value = csd . Value ,
1138- Year = year ,
1139- SeriesTransformation = csd . SeriesTransformation ,
1140- GroupingThreshold = csd . GroupingThreshold ,
1141- MinimumDataResolution = csd . MinimumDataResolution ,
1142- } ) ;
1143- }
1144- }
1145-
1146- Logger ! . LogInformation ( "RebuildChartSeriesListToReflectSelectedYears() setting ChartSeriesList" ) ;
1147- ChartSeriesList = newCsds ;
1148- }
1149-
11501122 private void BuildProcessedDataSets ( List < SeriesWithData > chartSeriesWithData , bool chartAllData )
11511123 {
11521124 var l = new LogAugmenter ( Logger ! , "BuildProcessedDataSets" ) ;
@@ -1318,16 +1290,6 @@ [.. chartBins
13181290 l . LogInformation ( "leaving" ) ;
13191291 }
13201292
1321- private string GetChartLabel ( SeriesTransformations seriesTransformation , string ? customTransformation , string defaultLabel , SeriesAggregationOptions seriesAggregationOptions )
1322- {
1323- return seriesTransformation switch
1324- {
1325- SeriesTransformations . DayOfYearIfFrost => seriesAggregationOptions == SeriesAggregationOptions . Maximum ? "Last day of frost" : "First day of frost" ,
1326- SeriesTransformations . Custom => ChartSeriesDefinition . GetFriendlyCustomTransformationLabel ( customTransformation ?? "Custom transformation" ) ,
1327- _ => defaultLabel ,
1328- } ;
1329- }
1330-
13311293 private dynamic BuildChartScales ( )
13321294 {
13331295 dynamic scales = new ExpandoObject ( ) ;
@@ -1351,12 +1313,18 @@ private dynamic BuildChartScales()
13511313 // Build a global min/max per axis from the full source datasets, before any display range filtering.
13521314 // This ensures the y-axis range reflects the complete dataset even when ChartAllData is false.
13531315 var axisMinMax = new Dictionary < string , ( double Min , double Max ) > ( ) ;
1316+ var axisHasBarSeries = new HashSet < string > ( ) ;
13541317 foreach ( var swd in ChartSeriesWithData ! )
13551318 {
13561319 var cs = swd . ChartSeries ! ;
13571320 var uom = cs . SourceSeriesSpecifications ! . First ( ) . MeasurementDefinition ! . UnitOfMeasure ;
13581321 var axisId = ChartLogic . GetYAxisId ( cs . SeriesTransformation , cs . CustomTransformation , uom , cs . Aggregation ) ;
13591322
1323+ if ( cs . DisplayStyle == SeriesDisplayStyle . Bar )
1324+ {
1325+ axisHasBarSeries . Add ( axisId ) ;
1326+ }
1327+
13601328 var values = swd . PreProcessedDataSet ! . DataRecords !
13611329 . Select ( x => x . Value )
13621330 . Where ( v => v . HasValue )
@@ -1390,7 +1358,7 @@ private dynamic BuildChartScales()
13901358 {
13911359 axisMinMax . TryGetValue ( axisId , out var globalMinMax ) ;
13921360 var axisRange = globalMinMax . Max - globalMinMax . Min ;
1393- var axisPadding = axisRange * 0.02 ;
1361+ var axisPadding = ! axisHasBarSeries . Contains ( axisId ) ? axisRange * 0.02 : 0.0 ;
13941362 ( ( IDictionary < string , object > ) scales ) . Add (
13951363 axisId ,
13961364 new
0 commit comments