question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ct-point with horizontal label

See original GitHub issue

Hi Gion Would be nice if ct-point element contains also value from horizontal axis, something like:

<line x1="" y1="" x2="" y2="" class="ct-point" ct:value="" ct:horizontal-label="27.02.2015"></line>

This value is needed for tooltips. Currently I have workaround for this, which doesn’t work when showLabel is false.

chart.on('created', function() {
    var horizontalLabels = svgElement.find('.ct-labels .ct-label.ct-horizontal');

    svgElement.find('.ct-series').each(function() {
        $(this).find('.ct-point').each(function(i) {
            $(this).attr('ct:horizontal-label', horizontalLabels.eq(i).text());
        });
    });
});

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
gionkunzcommented, Mar 4, 2015

Also useful in this context is that meta can also be a complex object where it will be serialized with Chartist.serialize and can be deserialized from the DOM attribute with Chartist.deserialize.

function buildMeta(data) {
  data.series = data.series.map(function(values, valuesIndex) {
    return values.map(function(value, valueIndex) {
      return {
        value: value,
        meta: {
          label: data.labels[valueIndex],
          labelIndex: valuesIndex,
          value: value,
          valueIndex: valueIndex
        }
      };
    });
  });
}

var chart = new Chartist.Line('.ct-chart', {
  labels: ['One', 'Two', 'Three', 'Four', 'Five'],
  series: [
    [1, 5, 4, 3, 4],
    [2, 3, 2, 2, 3]
  ]
});

chart.on('data', function(data) {
  buildMeta(data.data);
});

$(document).on('mouseenter', '.ct-point', function() {
  console.log(Chartist.deserialize($(this).attr('ct:meta')));
});

http://jsbin.com/wopoya/3/edit?js,console,output

0reactions
martinsznapkacommented, Mar 4, 2015

Ok, good point. Lets keep it in mind in case of meta conflicts. Thx for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to print Y axis label horizontally in a matplotlib / pylab ...
It is very simple. After plotting the label, you can simply change the rotation: import matplotlib.pyplot as plt plt.ion() plt.plot([1, 2, ...
Read more >
Change axis labels in a chart - Microsoft Support
In the Horizontal (Category) Axis Labels box, click Edit. In the Axis label range box, enter the labels you want to use, separated...
Read more >
How to print the Y-axis label horizontally in a Matplotlib/Pylab ...
Just by using plt.ylabel(rotation='horizontal'), we can align a label according to our requirement. Steps. Plot the lines using [0, ...
Read more >
Why is the y axis label horizontal - Julia Discourse
Suddenly, the y axis label is horizontal instead of vertical. guidefontrotation changes both the x axis and y axis labels.
Read more >
How to set x axis label width for chart ? - PTC Community
I am using label chart with Horizontal chart orientation. X-axis field is string (length more than 100) field names are truncated as you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found