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

Title not consistent when xAxis label shortened #7179

Closed
zbycz opened this issue Sep 21, 2017 · 4 comments
Closed

Title not consistent when xAxis label shortened #7179

zbycz opened this issue Sep 21, 2017 · 4 comments

Comments

@zbycz
Copy link

zbycz commented Sep 21, 2017

Expected behaviour

Shortened xAxis label displays the same text in label and its title including html entities.

Actual behaviour

Html entities for title are not processed.

Note, they are processed for the label by this method:

unescapeEntities = function (inputStr) {
objectEach(renderer.escapes, function (value, key) {

You should probably extend this section of titleSetter() method:

// #3276, #3895
(String(pick(value), '')).replace(/<[^>]*>/g, '')

Live demo with steps to reproduce

Hover over the first label on xAxis
http://jsfiddle.net/nhgh1Lz9/

Affected browser(s)

Chrome 61 on macos

Related issue

#3276

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Sep 22, 2017

Hi @zbycz
Thank you for the reporting.

Workaround

Demo:

Based on solution from buildText method:

unescapeAngleBrackets = function(inputStr) {
     return inputStr.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
};

@pawelfus
Copy link
Contributor

Hi @zbycz

You are right, it should be consistent.

Workaround:
Unescape entities:

(function(H) {
  H.wrap(H.SVGElement.prototype, 'titleSetter', function(p, value) {
    var renderer = this.renderer;

    unescapeEntities = function(inputStr) {
      H.objectEach({
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        "'": '&#39;',
        '"': '&quot'
      }, function(value, key) {
        inputStr = inputStr.replace(
          new RegExp(value, 'g'),
          key
        );
      });
      return inputStr;
    };

    return p.call(this, unescapeEntities(value));
  });
})(Highcharts)

Demo: http://jsfiddle.net/BlackLabel/nhgh1Lz9/2/

@zbycz
Copy link
Author

zbycz commented Sep 22, 2017

Thanks for the help.

@TorsteinHonsi
Copy link
Collaborator

Demo with the fix applied: http://jsfiddle.net/highcharts/nhgh1Lz9/3/

TorsteinHonsi added a commit that referenced this issue Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants