When creating a data bar conditional formatting with middle axis, a plain data bar with left axis is created instead. Using the following code:
var dataBarValueContext = new DataBarValueContext
{
MaximumValue = new NumericValue(1),
MinimumValue = new NumericValue(-1)
};
// Create the rule and set the desired formatting
var rule = new DataBarRule(dataBarValueContext)
{
UseGradientFill = false,
Direction = DataBarDirection.Context,
FillColor = ThemableColor.FromColor(Colors.Green),
NegativeFillColor = ThemableColor.FromColor(Colors.Red),
ShowBarsOnly = true,
AxisPosition = DataBarAxisPosition.Automatic
};
var conditionalFormat = new ConditionalFormatting(rule);
worksheet.Cells[0, 0, 1, 0].AddConditionalFormatting(conditionalFormat);
worksheet.Cells[0, 0].SetValue(0.5);
worksheet.Cells[1, 0].SetValue(-0.5);
The expected value is this:
The result value is instead: