3

I would like to customize the format of the numeric values shown on the auto cursor's x-axis tick marker. I can customize my x-axis by setting the tick strategy(Numeric) and defining a formatting function, but the auto cursor x-axis tick marker text is unchanged. Is it possible to set the formatting function of an auto cursor axis tick marker as well?

Current workarounds I've been able to find involve disabling the auto cursor altogether and making a custom one with custom ticks as done in this LightningChart interactive example: https://www.arction.com/lightningchart-js-interactive-examples/edit/lcjs-example-0702-customCursor.html

and here: Show custom tick in X-axis on Hover

I would like to use the existing auto cursor if possible.

hardestee
  • 33
  • 5

1 Answers1

1

thanks for your question.

I was surprised to find that there actually isn't a convenient method of changing tick label formatting of default auto cursor in LC JS v.3.1.

It's great that this came to our information, because now we can make some improvements on this and include them in the next release that will be coming later this month.

I'm sorry but you'll have to do with workarounds for the time being. I will post an updated answer here when version 3.2 is out.

EDIT: LC JS version 3.2 is now public.

We have added a new method NumericTickStrategy.setCursorFormatter, which can be used like this:

axis.setTickStrategy(AxisTickStrategies.Numeric, ticks => ticks
   .setCursorFormatter((value, range, locale) => {
      // Your formatting logic goes here.
      return 'todo'
   })
)

As mentioned in the linked API reference, this will affect following components:

  • Default cursor result table formatters.
  • Default cursor tick formatters along Axis which uses this TickStrategy.
  • Axis.formatValue method of the Axis which uses this TickStrategy.
Niilo Keinänen
  • 2,187
  • 1
  • 7
  • 12
  • When using AxisTickStrategies.Empty for later creation of custom axis ticks, the default auto cursor exists but the .setCursorFormatter method is unavailable. – hardestee Feb 03 '22 at 22:24
  • So this later issue is about modifying default auto cursor formatting when using manually created ticks if I understood correctly. This one we've been informed about quite recently. I would suggest opening another Stack Overflow thread about it if you want to be informed in future when we improve it. Please include the motivation why you have to manually create ticks instead of using some tick strategy. – Niilo Keinänen Feb 04 '22 at 06:58