Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shouldResetTickmarkLabels #1591

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

illetid
Copy link
Contributor

@illetid illetid commented May 10, 2024

Type of PR: bugfix

PR checklist:

Overview of change:
Added the shouldResetTickmarkLabels method to IHorzScaleBehavior and e2e test with an example of how users could fix issues like #1588 using this method

@SlicedSilver SlicedSilver self-requested a review May 10, 2024 13:14
Copy link
Contributor

@SlicedSilver SlicedSilver left a comment

Choose a reason for hiding this comment

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

The changes work well on the test case, however I'm concerned about implementing this fix within the tick-marks.ts file. This fix is specific to the case where the horizontal scale is time based. So I think it would be better to try fix this within the horz-scale-behavior-time.ts and time-scale-point-weight-generator.ts files since that code is only used for a time based scale and it is only run when new data is provided instead of when the chart is scrolled or zoomed (therefore the performance should be better as well).

.size-limit.js Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
src/model/time-scale.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
@illetid
Copy link
Contributor Author

illetid commented May 13, 2024

The changes work well on the test case, however I'm concerned about implementing this fix within the tick-marks.ts file. This fix is specific to the case where the horizontal scale is time based. So I think it would be better to try fix this within the horz-scale-behavior-time.ts and time-scale-point-weight-generator.ts files since that code is only used for a time based scale and it is only run when new data is provided instead of when the chart is scrolled or zoomed (therefore the performance should be better as well).

@SlicedSilver I addressed all other issues but for this one. it probably make more sense to leave it here. due to all marks are valid and the issue dependent on zoom and/or width of the chart and this check need to be triggered on each buildTickMarks not only on data change and we can't fix it in time-scale-point-weight-generator.ts

@illetid illetid requested a review from SlicedSilver May 13, 2024 14:40
src/model/horz-scale-behavior-time/time-utils.ts Outdated Show resolved Hide resolved
src/model/tick-marks.ts Outdated Show resolved Hide resolved
@illetid
Copy link
Contributor Author

illetid commented May 14, 2024

hi @eugene-korobko, could you pls check this PR and the issue? what do you think about this approach, is it okay? as an alternative instead of changing day tickmark to month we could hide the tickmark entirely

const startOfTheMonthUtcSeconds = Math.floor(startOfTheMonth.getTime() / 1000);

const monthMark = marks.find((m: TickMark) => {
return m.weight === TickMarkWeight.Month && (m.originalTime as number) >= startOfTheMonthUtcSeconds;
Copy link
Contributor

Choose a reason for hiding this comment

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

is m.originalTime as number conversion correct? Several lines above we call convertTime(mark.originalTime as Time)

lets check this code with different format of input data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that, added convertTime

@illetid illetid changed the title replace day mark with month if month didn't fit add shouldResetTickmarksLabels Jun 10, 2024
@illetid illetid changed the title add shouldResetTickmarksLabels add shouldResetTickmarkLabels Jun 10, 2024
* Use this if you want to extend the default behavior of the horizontal time scale.
* This should be used with the createChartEx function
*
* @returns An uninitialized class implementing the {@link IHorzScaleBehavior}`<Time>` interface
Copy link
Contributor

Choose a reason for hiding this comment

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

We could probably 'link' Time as well here.

Comment on lines 76 to 77
* Use this if you want to extend the default behavior of the horizontal time scale.
* This should be used with the createChartEx function
Copy link
Contributor

Choose a reason for hiding this comment

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

This was 'placeholder' text. Lets use a more detailed and helpful description.

/**
 * Provides the default implementation of the horizontal scale (time-based) that can be used as a base for extending the horizontal scale with custom behavior.
 * This allows for the introduction of custom functionality without re-implementing the entire {@link IHorzScaleBehavior<Time>} interface.
 * 
 * For further details, refer to the {@link createChartEx} chart constructor method.
 *
 * @returns {new () => IHorzScaleBehavior<Time>} - An uninitialized class implementing the {@link IHorzScaleBehavior<Time>} interface.
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time scale date render bug
3 participants