Skip to main content

SetMaxPointValue

Sets the value for the maximum value condition for the data bar.

Syntax

expression.SetMaxPointValue(value);

expression - A variable that represents a ApiDatabar class.

Parameters

NameRequired/OptionalData typeDefaultDescription
valueRequiredstring | numberThe value of the maximum value condition.

Returns

This method doesn't return any data.

Example

Specify the upper threshold at which a data bar reaches its full length in a spreadsheet.

// How do I set the exact number that represents the maximum bar length in a spreadsheet?

// Cap the data bar scale at a specific value so bars do not grow beyond a known limit in a spreadsheet.

let worksheet = Api.GetActiveSheet();

worksheet.GetRange("A1").SetValue("Sales Data");
worksheet.GetRange("A2").SetValue(100);
worksheet.GetRange("A3").SetValue(250);
worksheet.GetRange("A4").SetValue(150);
worksheet.GetRange("A5").SetValue(300);
worksheet.GetRange("A6").SetValue(75);

let dataRange = worksheet.GetRange("A2:A6");
let formatConditions = dataRange.GetFormatConditions();

let dataBar = formatConditions.AddDatabar();

worksheet.GetRange("C1").SetValue("Before:");
worksheet.GetRange("C2").SetValue(dataBar.GetMaxPointValue() || "Auto");

dataBar.SetMaxPointValue(500);

worksheet.GetRange("C3").SetValue("After:");
worksheet.GetRange("C4").SetValue(dataBar.GetMaxPointValue() || "Auto");