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.

There is a way to get the x axis value of a point with line chart ?

See original GitHub issue

Hi,

First, thanks a lot for your beautiful project !

I’m wondering if there is a way to get the x axis label where a ct:point is located in ? I’m using the line chart with tooltips for each point. The documentation shows how to get the y axis value and the serie name but I’m looking for the x axis value.

Here an example of what I’m looking for. I don’t know what to write in '???'

$chart.on('mouseenter', '.ct-point', function() {
    var point = $(this),
        value = point.attr('ct:value'),
        seriesName = point.parent().attr('ct:series-name')
        x_axis_value = '???';
    $toolTip.html(seriesName + '<br>' + x_axis_value + ' = ' + value).show();
});

Thanks for the help !

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
gionkunzcommented, Jan 18, 2015

@Raphy you can now use the meta data feature included in 0.6.0 for this.

var data = {
    labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
    series: [
        {
            name: 'Views the last week',
            data: [
              {value: 123, meta: 'Monday'},
              {value: 100, meta: 'Tuesday'},
              {value: 150, meta: 'Wednesday'},
              {value: 123, meta: 'Thursday'},
              {value: 123, meta: 'Friday'},
              {value: 123, meta: 'Saturday'},
              {value: 123, meta: 'Sunday'}
            ]
        }
};

There will be an additional ct:meta attribute on the points of line charts or on the bars of bar charts. You can also add the whole tooltip text to the meta property. It also accepts objects / complex types. Objects will be serialized and need to be deserialized when you read them from the attributes with http://gionkunz.github.io/chartist-js/api-documentation.html#chartistcore-method-deserialize

Hope this helps. Cheers Gion

0reactions
kirkbrosscommented, Jan 19, 2018

I know this is closed, but is there a way to do this if you are unable to add meta to the data series? I’m handling an object that I can’t alter and it’s coming to me where key/value = x lables/point values.

const chart{{ $id }} = new Chartist.Line('#{{ $id }}', { labels: {!! json_encode($hours) !!}, series: [ { name: 'audience by time', data: {!! json_encode($values) !!} } ] }

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to Line Charts | Tutorial by Chartio
Line charts are a fundamental chart type generally used to show change in values across time. Learn how to best use this chart...
Read more >
Change the display of chart axes - Microsoft Support
Display or hide axes, or change other aspects of a chart axes in Excel, Word, Outlook, or PowerPoint.
Read more >
Is there a way to show only specific values in x-axis of an ...
You can either: 1) Use a line chart, which treats the horizontal axis as categories (rather than quantities). 2) Use an XY/Scatter plot, ......
Read more >
Do we have a way to know the X Axis value of first point in line ...
You can use the following code to get the min and max value. var dg = (XYDiagram)chartControl1.Diagram; var minXValue = dg.AxisX.WholeRange.
Read more >
How to Make a Graph on Excel With X & Y Coordinates
1. Select your data, and click Insert - Scatter or Bubble Chart - Scatter with Straight Lines. · 2. You can see that...
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