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

Comments

Projects
None yet
4 participants
@zbycz

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

This comment has been minimized.

Show comment
Hide comment
@sebastianbochan

sebastianbochan Sep 22, 2017

Contributor

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, '>');
};
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

This comment has been minimized.

Show comment
Hide comment
@pawelfus

pawelfus Sep 22, 2017

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/

Contributor

pawelfus commented Sep 22, 2017

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/

@pawelfus pawelfus added the Bug label Sep 22, 2017

@zbycz

This comment has been minimized.

Show comment
Hide comment
@zbycz

zbycz Sep 22, 2017

Thanks for the help.

zbycz commented Sep 22, 2017

Thanks for the help.

@TorsteinHonsi

This comment has been minimized.

Show comment
Hide comment
@TorsteinHonsi
Collaborator

TorsteinHonsi commented Dec 21, 2017

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