0

I am using Chart.js with Blazor I have a simple line chart everything works but when i click on the chart I would like to mark the nearest point automatically.

I created the config as anonymous type, I have tried different interaction modes no success yet.

var config = new
        {
            Type = Type.ToString().ToLower(),
            Options = new
            {
                Legend = new
                {
                    Display = false,    
                },
                BezierCurve = false,
                Responsive = true,
                Interaction = new
                { 
                    Intersect = false,
                },
                Scales = new
                {
                    YAxes = new[]
                    {
                            new
                            {
                                Position = "left",
                                Ticks = new
                                {
                                    SuggestedMin = SuggestedMin
                                }
                            }
                    },
                    XAxes = new[]
                    {
                            new
                            {
                                Ticks = new
                                {
                                    BeginAtZero = true,
                                    AutoSkip = true,
                                    MaxTicksLimit = 4
                                }
                            }
                    }
                }
            },
            Data = new
            {
                Datasets = new[]
                {
                    new
                    {
                        Fill = false,
                        LineTension= 0,
                        Data = Data,
                        BackgroundColor = "#FFFFFF",
                    }
                },
                Labels = Labels
            }
        };
  • I think this answer can help you [Nearest point in canvas chart js ](https://stackoverflow.com/questions/56388421/chart-js-get-the-nearest-point-when-clicked-on-canvas) – Paviry Dev Jul 24 '23 at 20:47

0 Answers0