End x-axis on last data point (scatter plot) for x,y numeric values

33
January 09, 2019, at 05:00 AM

When I plot a dataset of (x,y) floats on a scatter plot using ChartJS, I end up with extra space on my x-axis due to the step size. Can I force it to end right on the last data point?

I have not set any nice labels or a legend, so sorry for the basic plot. I first tried to do a line plot, which I think would not have this problem, but I was not able to pass a dataset of (x,y) values in the format:

elevation = [
    {
        x: 1,
        y: 2
    },
    {
        x: 2,
        y: 5
    }
]

For this reason, I chose to use a scatter plot.

Currently I'm rendering my scatter chart like this:

var ctx = document.getElementById("elevationProfile");
myLineChart = new Chart(ctx, {
    type: 'scatter',
    data: {
        datasets: [{
            label: "Elevation Profile",
            data: elevation,
            showLine: true
        }]
    }
});

But I was unable to find anything in the docs or Github that would indicate how to achieve this.

I would like the graph to look like this with no space at the end:

Thanks!

READ ALSO
What do we actually import from Express in a Node.js program

What do we actually import from Express in a Node.js program

Usually when we import something in Node, we do something like:

50
Python: How do I pass variables between class instances or get the caller?

Python: How do I pass variables between class instances or get the caller?

In foo, I am doing something that produces "var1" being set to 1 In bar, I would like to access the contents of var1

34
Pull data from Active Directory with Python, Golang or Ruby on rails

Pull data from Active Directory with Python, Golang or Ruby on rails

I would like to make a web application which can pull data from Active DirectoryAt my work many developers recommend me to learn C# or Java mostly because they are using it

19
How to fix incorrect jQuery sortable container sizing after zooming in with panzoom

How to fix incorrect jQuery sortable container sizing after zooming in with panzoom

I'm looking to use a drag and drop interface that allows for the parent container of the destination sortable to be zoomed in on using jQuery Panzoom

23