Obtains a reference to a client-side function that, when invoked, initiates a client call back to a server-side event that is handled by the Chart.
Obtains a reference to a client-side function that, when invoked, initiates a client call back to a server-side event which is handled by the Chart. The browser event bubbling will be canceled.
Syntax
Visual Basic (Usage) |
Copy Code |
Dim instance As ChartCallbackManager
Dim command As String
Dim arguments As String
Dim value As String
value = instance.GetCallbackEventReference(command, arguments)
|
Parameters
- command
- The control that handles the arguments.
The control which handles the arguments
- arguments
- String which is passed to the target control.
String which is passed to the targetControl
Return Value
String that represents a javascript function.
String which represents javascript function.
Example
This example demonstrates how to use the
Callback event to explode a pie slice when that slice is clicked. We assume a chart has been added at design-time.
Visual Basic |
Copy Code |
Imports Dundas.Charting.WebControl ...
Protected Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then Chart1.Series(0).Points.Clear() Chart1.Series(0).Points.AddXY(1, 4) Chart1.Series(0).Points.AddXY(2, 5) Chart1.Series(0).Points.AddXY(3, 2) Chart1.Series(0).Points.AddXY(4, 1) End If
Chart1.Series(0).MapAreaAttributes = "onclick=""" + Chart1.CallbackManager.GetCallbackEventReference("PieClick", "#INDEX") + """" End Sub
Protected Sub Chart1_Callback(sender As Object, e As CommandEventArgs)
If e.CommandName = "PieClick" Then Dim point As DataPoint For Each point In Chart1.Series(0).Points point("Exploded") = "False" Next point Dim index As Integer = Integer.Parse(e.CommandArgument.ToString()) Chart1.Series(0).Points(index)("Exploded") = "True" End If End Sub
|
C# |
Copy Code |
using Dundas.Charting.WebControl ...
// Page Load event handler. protected void Page_Load(object sender, EventArgs e) { // We add points to the chart only when the page is first rendered. if (!IsPostBack) { Chart1.Series[0].Points.Clear(); Chart1.Series[0].Points.AddXY(1, 4); Chart1.Series[0].Points.AddXY(2, 5); Chart1.Series[0].Points.AddXY(3, 2); Chart1.Series[0].Points.AddXY(4, 1); }
// Use GetCallbackEventReference method to create Javascript. // We use chart keyword #INDEX as a parameter for the Callback event. Chart1.Series[0].MapAreaAttributes = "onclick=\"" + Chart1.CallbackManager.GetCallbackEventReference("PieClick", "#INDEX") + "\""; }
// Chart Callback event handler. protected void Chart1_Callback(object sender, CommandEventArgs e) {
if (e.CommandName == "PieClick") { // Reset pie chart so that no pie slices are exploded. foreach (DataPoint point in Chart1.Series[0].Points) point["Exploded"] = "False"; // Explode the correct pie slice. int index = int.Parse(e.CommandArgument.ToString()); Chart1.Series[0].Points[index]["Exploded"] = "True"; } }
|
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also