> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# GetBarPaintWidth()

## Definition

Returns the width of the bars in the primary Bars object on the chart, in pixels.

## Method Return Value

A double representing the pixel width of bars on the chart.

## Syntax

`\<chartcontrol\>.GetBarPaintWidth(ChartBars chartBars)`

## Method Parameters

| Parameter     | Description                                                                                |
| ------------- | ------------------------------------------------------------------------------------------ |
| **chartBars** | A [ChartBars](/developer/desktop-sdk/references/common/charts/chartbars) object to measure |

## Examples

```csharp
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
   // Use BarsArray[0] to pass in a ChartBars object representing the primary Bars object on the chart
   double barPixelWidth = chartControl.GetBarPaintWidth(chartControl.BarsArray[0]);
 
   // Print the pixel width of bars painted on the chart
   Print(String.Format("Bars on the chart are {0} pixels wide", barPixelWidth));   
}
```

In the image below, **GetBarPaintWidth()** reveals that the bars are being drawn 27 pixels wide on the chart:

![ChartControl\_GetBarPaintWidth](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/ninjatrader-public.docs.buildwithfern.com/867d095253a0226b6078ac66ed0e089f9d36ab341d6dee9408dd32d2333106e8/docs/assets/developer/desktop-sdk/references/chartcontrol-getbarpaintwidth-chartcontrol-getbarpaintwidth.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260729%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260729T062135Z&X-Amz-Expires=604800&X-Amz-Signature=d13ae7d38a0f409ebdfaef3edc10782c50295055761a9fc6c22cd82b91b96a30&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)