ScatterPlot点单击事件不起作用

问题描述 投票:0回答:1

尝试通过Highcharts.net包装器将click事件分配给散布图点。该事件显示在javascript输出中,但单击某个点时不会触发。该图表可以很好地呈现,它是交互式的,缩放,悬停等。除单击事件外,其他所有功能均正常。我已经在PlotOptionsSeries位置和ScatterSeries位置中都尝试了click事件。

var chartOptions = new Highsoft.Web.Mvc.Charts.Highcharts
 {
   Chart = new Highsoft.Web.Mvc.Charts.Chart
      {
         SpacingTop = 20,
         SpacingBottom = 20,
         SpacingLeft = 20,
         SpacingRight = 20,
         ZoomType = Highsoft.Web.Mvc.Charts.ChartZoomType.Xy
      },
      XAxis = new List<Highsoft.Web.Mvc.Charts.XAxis>
      {
         new Highsoft.Web.Mvc.Charts.XAxis
         { Max = 150, Min = -150,GridLineWidth = 1, TickInterval = 50,
           PlotLines = new List<Highsoft.Web.Mvc.Charts.XAxisPlotLines> { new Highsoft.Web.Mvc.Charts.XAxisPlotLines { Value = 0, Width = 2, ZIndex = 5 } }
         }
      },
      YAxis = new List<Highsoft.Web.Mvc.Charts.YAxis>
      {
        new Highsoft.Web.Mvc.Charts.YAxis
        {
          Title = new Highsoft.Web.Mvc.Charts.YAxisTitle { Text = "" },
             Max = 150, Min = -150, GridLineWidth = 1, TickInterval = 50,
                        PlotLines = new List<Highsoft.Web.Mvc.Charts.YAxisPlotLines> { new Highsoft.Web.Mvc.Charts.YAxisPlotLines { Value = 0, Width = 2, ZIndex = 5 } }
        }
      },
      PlotOptions = new Highsoft.Web.Mvc.Charts.PlotOptions
      {
          Series = new Highsoft.Web.Mvc.Charts.PlotOptionsSeries
          {
           AllowPointSelect = true,
          },
          Scatter = new Highsoft.Web.Mvc.Charts.PlotOptionsScatter
          {
             Marker = new Highsoft.Web.Mvc.Charts.PlotOptionsScatterMarker
             {
                Radius = 5,
                States = new Highsoft.Web.Mvc.Charts.PlotOptionsScatterMarkerStates
                {
                  Hover = new Highsoft.Web.Mvc.Charts.PlotOptionsScatterMarkerStatesHover
                  {
                     Enabled = true,
                     LineColor = "rgb(100,100,100)"
                  }
                }                               
              },
              States = new Highsoft.Web.Mvc.Charts.PlotOptionsScatterStates
              {
                 Hover = new Highsoft.Web.Mvc.Charts.PlotOptionsScatterStatesHover
                 {   }
              }                      
            }
          },

          Series = new List<Highsoft.Web.Mvc.Charts.Series>
          {
            new Highsoft.Web.Mvc.Charts.ScatterSeries
            {
                Name = "Dots",
                Color = "rgba(223, 83, 83, .5)",
                Data = pts3,  // Here we put the dbase data into the chart  
                ZIndex = 6,
                Events = new Highsoft.Web.Mvc.Charts.ScatterSeriesEvents
                { 
                    Click = "function () {alert('Clicked');console.log('Clicked');}"      
                },
                Tooltip = new Highsoft.Web.Mvc.Charts.ScatterSeriesTooltip
                {
                        HeaderFormat = "",
                        PointFormat = "<h5>{point.name}<br /></h5>"+"<b>Love It:</b>{point.x} " +
                   "<b>Challenge:</b>{point.y}",
                        FooterFormat = "",
                        FollowPointer = true
                }
            }
          }
          };

        chartOptions.ID = "teachaggchart";
        var renderer = new Highsoft.Web.Mvc.Charts.Rendering.HighchartsRenderer(chartOptions);
highcharts dotnethighcharts
1个回答
0
投票

似乎您在包装器中发现了一个错误。

我已经报告了它,并且它已经在新版本(8.0.0.2)中修复,现在应该可以使用。

如何获得最新版本,您可以在这里找到:http://dotnet.highcharts.com/Highcharts/Demo/Docs?section=UpgradeToStandard

让我知道它是否在新版本中有效。

© www.soinside.com 2019 - 2024. All rights reserved.