Feature Description
Summary
It would be useful if klinecharts allowed the bar space zoom limits to be overridden at runtime instead of being hard-coded to:
Right now those limits appear fixed inside the distributed bundle, which makes it difficult for applications with dense historical datasets or specialized zoom behavior to support narrower or wider bar spacing without patching the package.
Current behavior
The library currently defines fixed limits similar to:
var BarSpaceLimitConstants = {
MIN: 1,
MAX: 50
};
And uses them when setting bar spacing:
if (barSpace < BarSpaceLimitConstants.MIN || barSpace > BarSpaceLimitConstants.MAX || this._barSpace === barSpace) {
return;
}
Requested behavior
Allow consumers to override these limits through a supported configuration mechanism.
One lightweight option would be to read from a global override if present, and fall back to the existing defaults otherwise. That would preserve current behavior for all existing users while making the limits configurable for advanced integrations.
Proposed implementation
Something along these lines:
var __kline_bar_space_limit_override = {
MIN: 1,
MAX: 50
};
function getBarSpaceLimitConstants() {
var override =
typeof globalThis !== "undefined"
? globalThis.KLINE_BAR_SPACE_LIMIT_CONSTANTS
: void 0;
return override || __kline_bar_space_limit_override;
}
var BarSpaceLimitConstants = getBarSpaceLimitConstants();
And then in setBarSpace:
var limit = getBarSpaceLimitConstants();
if (barSpace < limit.MIN || barSpace > limit.MAX || this._barSpace === barSpace) {
return;
}
Why this would help
- It removes the need to maintain a local patch for a small but important behavior change.
- It keeps the current defaults intact for existing users.
- It enables more flexibility for applications that need different zoom bounds because of their dataset size or UX requirements.
- It is a minimal, backward-compatible extension point.
Suggested API alternatives
If a global hook is not desirable, any of these would also solve the problem cleanly:
- Expose
minBarSpace / maxBarSpace in chart options.
- Add a dedicated API such as
setBarSpaceLimit({ min, max }).
- Export the defaults and allow them to be overridden during initialization.
Backward compatibility
This request is intended to be fully backward compatible:
- default behavior remains unchanged
- existing consumers do not need to update anything
- only applications that need custom limits would opt in
Context
At the moment this requires patching the built output locally, which is fragile across upgrades. Having an official extension point upstream would make this much easier to maintain.
To Do
- Add a supported way to override the default bar space limits.
- Update
setBarSpace to use the configured limits instead of fixed constants.
- Keep existing defaults unchanged for backward compatibility.
- Add tests for default and overridden limit behavior.
- Document the new configuration option.
Feature Description
Summary
It would be useful if
klinechartsallowed the bar space zoom limits to be overridden at runtime instead of being hard-coded to:Right now those limits appear fixed inside the distributed bundle, which makes it difficult for applications with dense historical datasets or specialized zoom behavior to support narrower or wider bar spacing without patching the package.
Current behavior
The library currently defines fixed limits similar to:
And uses them when setting bar spacing:
Requested behavior
Allow consumers to override these limits through a supported configuration mechanism.
One lightweight option would be to read from a global override if present, and fall back to the existing defaults otherwise. That would preserve current behavior for all existing users while making the limits configurable for advanced integrations.
Proposed implementation
Something along these lines:
And then in
setBarSpace:Why this would help
Suggested API alternatives
If a global hook is not desirable, any of these would also solve the problem cleanly:
minBarSpace/maxBarSpacein chart options.setBarSpaceLimit({ min, max }).Backward compatibility
This request is intended to be fully backward compatible:
Context
At the moment this requires patching the built output locally, which is fragile across upgrades. Having an official extension point upstream would make this much easier to maintain.
To Do
setBarSpaceto use the configured limits instead of fixed constants.