Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/scale/Time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ class TimeScale extends IntervalScale<TimeScaleSetting> {
let upperUnitIndex = primaryTimeUnits.length - 1;
let maxLevel = 0;
each(ticks, tick => {
upperUnitIndex = Math.min(upperUnitIndex, indexOf(primaryTimeUnits, tick.time.upperTimeUnit));
maxLevel = Math.max(maxLevel, tick.time.level);
if (tick.time) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that TypeScript suppresses this TypeError as per the current tsconfig.json, where the strictNullChecks option is disabled. But if we enable it, there are many errors to be fixed. For simplicity, I agree with your current fix by adding the safeguard.

@100pah How do you think about this?

upperUnitIndex = Math.min(upperUnitIndex, indexOf(primaryTimeUnits, tick.time.upperTimeUnit));
maxLevel = Math.max(maxLevel, tick.time.level);
}
});

if (scaleBreakHelper) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export function leveledFormat(
else if (zrUtil.isFunction(formatter)) {
const extra: TimeAxisLabelFormatterExtraParams = {
time: tick.time,
level: tick.time.level,
level: tick.time ? tick.time.level : 0,
};
const scaleBreakHelper = getScaleBreakHelper();
if (scaleBreakHelper) {
Expand Down
55 changes: 55 additions & 0 deletions test/axis-customTicks.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.