【问题标题】:ScatterPlot Point Click Event Not Working散点图点单击事件不起作用
【发布时间】:2020-02-04 23:08:57
【问题描述】:

尝试通过 Highcharts.net 包装器将点击事件分配给散点图点。该事件出现在 javascript 输出中,但在单击某个点时不会触发。图表呈现良好,它是交互式的、缩放、悬停等。除了点击事件外,一切正常。我在 PlotOptionsSeries 位置和 ScatterSeries 位置都尝试过点击事件。

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】:

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

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

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

    让我知道它是否适用于新版本。

    【讨论】:

      猜你喜欢
      • 2016-05-13
      • 2016-02-12
      • 2018-06-15
      • 2017-08-22
      • 2012-11-07
      • 2018-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多