【发布时间】: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