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

Question: Tooltip, Corss, Indicator Label does not shown if Tooltip component is not turned off/on in inspector. #315

Open
HajiyevEl opened this issue Apr 11, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@HajiyevEl
Copy link

HajiyevEl commented Apr 11, 2024

I think something is wrong with 'AxisHandler.UpdatePointerValue()' or pointer value does not get updated after i manually change axis split number, depending on xDataZoom current data quantity.

Screenshot

Screenshot 2024-04-11 195915

private void UpdateXAxisSplitNumber()
{
    var serie = chart.GetSerie(0);
    chart.GetDataZoomOfSerie(serie, out DataZoom xDataZoom, out DataZoom yDataZoom);

    var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);

    xAxis.splitNumber = serie.GetDataList(xDataZoom).Count;
}

Also, please help me understand behaviour of indicator labels on axises when tooltip is set to Corss mode.

Problem is, when tooltip in Corss mode, indicator labels are hidden, even thought they are enabled on axises.

Indicator Labels Hidden (Play-mode)

Screenshot 2024-04-12 115031
Screenshot 2024-04-12 114930
Screenshot 2024-04-12 120512

But if i disable and than enable Tooltip (Play-mode), they are shown and cannot be disabled.

Indicator Shown (Play-mode)

Screenshot 2024-04-12 120557
Screenshot 2024-04-12 120643
Screenshot 2024-04-12 120759

Somehow, when indicator labels shown/or hidden - enabling/or disabling Indicator labels (Play-mode) on axises does not change their active state. Is it intended?
By the way, i downloaded Demo project, and seen there same behavior in candlestick charts. If you enable/disable tooltip component (Play-mode), indicator labels are shown and cannot be disabled.

@monitor1394

@HajiyevEl
Copy link
Author

HajiyevEl commented Apr 12, 2024

Well, i think indicator label with 'dynamic axis split number when zooming' problem solved. Changed some code in TooltipHandler.cs :

private void SetTooltipIndicatorLabel(Tooltip tooltip, Axis axis, ChartLabel label)
{
 ...
    if (axis.IsCategory())
    {
        // Old
        //var index = (int)axis.context.pointerValue;
        //var category = axis.GetData(index);
        //label.SetText(axis.indicatorLabel.GetFormatterContent(index, category));

        // Edited
        var index = (int)axis.context.pointerValue;
        var dataZoom = chart.GetDataZoomOfAxis(axis);
        var category = axis.GetData(index, dataZoom);
        label.SetText(axis.indicatorLabel.GetFormatterContent(index, category));
    }
...
}
Screenshot

Screenshot 2024-04-12 163114
Screenshot 2024-04-12 163148

But still, can't make Tooltip Indicator Labels show itself without turning on/off Tooltip component. Any ideas?

@HajiyevEl
Copy link
Author

Also, it seems that Indicator labels and labels of axis cannot be disabled by just un-ticking active component, you must change at least some value inside component (for example sprite color) from default to custom, otherwise enabling/disabling component will not do anything. Tested on 'background' settings of indicatorLabel of axis.

@HajiyevEl HajiyevEl changed the title Question: Tooltip, Corss Question: Tooltip, Corss, Indicator Label does not shown if Tooltip component is not re-enabled/disabled manually. Apr 27, 2024
@HajiyevEl HajiyevEl changed the title Question: Tooltip, Corss, Indicator Label does not shown if Tooltip component is not re-enabled/disabled manually. Question: Tooltip, Corss, Indicator Label does not shown if Tooltip component is not turned off/on in inspector. Apr 27, 2024
@HajiyevEl
Copy link
Author

HajiyevEl commented Apr 27, 2024

Hi again! Same problem: can't make Tooltip Indicator Labels show itself without turning off/on Tooltip component in inspector.
Please check this.

My Tooltip is set to Corss.

Tooltip Settings

Screenshot 2024-04-27 130130

When tooltip component is initialized, Tooltip type becomes 'Line', and updates to Corss only later.
Also, 'm_LabelRoot' object is setting itself via 'ChartHelper.AddObject', but somewhere before code reaches 'UpdateTooltipIndicatorLabelText' - 'm_LabelRoot' again becomes null.

Screenshots

Screenshot 2024-04-27 125100
Screenshot 2024-04-27 125750
Screenshot 2024-04-27 130018

I ended up adding label object manually. Even tho it's spaghetti code, tooltip indicator labels is shown without need for turning on/off Tooltip component in inspector.
Can you please check in-depth about what causes this issue?

@monitor1394

@monitor1394
Copy link
Collaborator

Hi again! Same problem: can't make Tooltip Indicator Labels show itself without turning off/on Tooltip component in inspector. Please check this.

My Tooltip is set to Corss.

Tooltip Settings
Screenshot 2024-04-27 130130

When tooltip component is initialized, Tooltip type becomes 'Line', and updates to Corss only later. Also, 'm_LabelRoot' object is setting itself via 'ChartHelper.AddObject', but somewhere before code reaches 'UpdateTooltipIndicatorLabelText' - 'm_LabelRoot' again becomes null.

Screenshots
Screenshot 2024-04-27 125100 Screenshot 2024-04-27 125750 Screenshot 2024-04-27 130018

I ended up adding label object manually. Even tho it's spaghetti code, tooltip indicator labels is shown without need for turning on/off Tooltip component in inspector. Can you please check in-depth about what causes this issue?

@monitor1394

I'm unable to replicate the issue you've described. Could you please provide detailed steps to reproduce it?
Additionally, I attempted to set the type to 'Cross' both before and after execution, and in both cases, the operation performed normally.

@HajiyevEl
Copy link
Author

HajiyevEl commented Apr 29, 2024

I'm unable to replicate the issue you've described. Could you please provide detailed steps to reproduce it? Additionally, I attempted to set the type to 'Cross' both before and after execution, and in both cases, the operation performed normally.

You should try to instantiate prefab containing chart, because when i tried to replicate issue for you, i found out that even tho examples work fine, when i try to pack example script into prefab and instantiate it later, this issue with 'labels not showing' comes up (it seems that indicator line style color and other components will not be set properly either). So, it seems that if chart script exists in scene before play mode - all work as intended, but if you instantiate it later at runtime - issue comes up.
Also, even tho i disabled/enabled Tooltip component in steps to replicate below, actually, disabling/enabling any of most of components will force labels to update (e.g. serie, axis, etc..)

I'm using XCharts version 3.10.2 in my project, but same issue exists in demo project.

Steps to replicate:

  1. Download Demo Project (https://github.com/XCharts-Team/XCharts-Demo)
  2. Enter Play Mode
  3. Select any chart with Corss type Tooltip (e.g. i selected Built-In Charts => Candlestick Chart => ShangHai Index)
Select chart

Screenshot 2024-04-29 111343

  1. Check if chart shows indicator labels. Check if all settings is correct. If no => go next
Check indicator labels and settings

Screenshot 2024-04-29 111411
Screenshot 2024-04-29 111524
Screenshot 2024-04-29 111549
Screenshot 2024-04-29 111606

  1. Disable Tooltip component in inspector
Disable Tooltip

Screenshot 2024-04-29 111629

  1. Enable Tooltip component in inspector
Enable Tooltip

Screenshot 2024-04-29 111653

  1. Check if indicator labels is shown
Check indicator labels

Screenshot 2024-04-29 111717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants