/// <summary> /// Constructs a new instance of <see cref="T:Wisej.Web.Ext.ChartJS.ChartClickEventArgs"/>. /// </summary> /// <param name="chart"></param> /// <param name="e"></param> internal ChartClickEventArgs(Wisej.Web.Ext.ChartJS.ChartJS chart, WidgetEventArgs e) { dynamic[] points = e.Data; List <int> dataPoints = new List <int>(); List <object> values = new List <object>(); List <DataSet> dataSets = new List <DataSet>(); if (points != null) { // collect the points, values and datasets in the click range. foreach (dynamic point in points) { int pointIndex = point.pointIndex; int dataSetIndex = point.dataSetIndex; dataPoints.Add(pointIndex); dataSets.Add(chart.DataSets[dataSetIndex]); values.Add(chart.DataSets[dataSetIndex].Data[pointIndex]); } } this.DataSets = dataSets.ToArray(); this.DataPoints = dataPoints.ToArray(); this.Values = new object[this.DataPoints.Length]; for (int i = 0; i < this.Values.Length; i++) { this.Values[i] = this.DataSets[i].Data[this.DataPoints[i]]; } }
/// <summary> /// Constructs a new instance of <see cref="T:Wisej.Web.Ext.ChartJS.ChartClickEventArgs"/>. /// </summary> /// <param name="chart"></param> /// <param name="e"></param> internal ChartClickEventArgs(Wisej.Web.Ext.ChartJS.ChartJS chart, WidgetEventArgs e) { dynamic[] points = e.Data.data; dynamic selection = e.Data.selected; List <int> dataPoints = new List <int>(); List <object> values = new List <object>(); List <DataSet> dataSets = new List <DataSet>(); if (points != null) { // collect the points, values and datasets in the click range. foreach (dynamic point in points) { int pointIndex = point.pointIndex; int dataSetIndex = point.dataSetIndex; dataPoints.Add(pointIndex); dataSets.Add(chart.DataSets[dataSetIndex]); values.Add(chart.DataSets[dataSetIndex].Data[pointIndex]); } // add information about the value directly underneath the click. var selPointIndex = selection.pointIndex; var selDataSetIndex = selection.dataSetIndex; this.SelectedDataSet = chart.DataSets[selDataSetIndex]; this.SelectedValue = chart.DataSets[selDataSetIndex].Data[selPointIndex]; } this.DataSets = dataSets.ToArray(); this.DataPoints = dataPoints.ToArray(); this.Values = new object[this.DataPoints.Length]; for (int i = 0; i < this.Values.Length; i++) { this.Values[i] = this.DataSets[i].Data[this.DataPoints[i]]; } }