Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Chart.js : sparser clickable data points

I've got a chart.js line chart, with 128 datapoints.

Currently, it uses the solution here for drag and drop verticals.

But it's a hassle. I'd like to limit the clickable / editable points to 30 or so.

(Then ideally it would do some smart interpolation of the surrounding values.)

Any ideas how to achieve this?

    function move_handler(event)
{
    // locate grabbed point in chart data
    if (activePoint != null) {
        var data = activePoint._chart.data;
        var datasetIndex = activePoint._datasetIndex;

        // read mouse position
        const helpers = Chart.helpers;
        var position = helpers.getRelativePosition(event, myChart);

        // convert mouse position to chart y axis value
        var chartArea = window.myChart.chartArea;
        var yAxis = window.myChart.scales["y-axis-0"];
        var yValue = map(position.y, chartArea.bottom, chartArea.top, yAxis.min, yAxis.max);

        // update y value of active data point
        data.datasets[datasetIndex].data[activePoint._index] = yValue;


//        try {
//            for (let i = -5;i < 5;i++){
//                data.datasets[datasetIndex].data[activePoint._index + i] = yValue;
//            }
//        }
//        catch (err) {}

        window.myChart.update();
    };
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found Smooth.js which did the trick

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!