Highcharts——这一点.类别返回未定义

Highcharts- this.category returns undefined

本文关键字:返回 未定义 这一点 Highcharts      更新时间:2023-09-26

在highcharts中单击任何点或条,我想要一个警告给出X轴值…我用的是。net。Visual Studio中的highcharts我尝试了以下命令

public partial class regression
{
    DataSet dsSeries = new DataSet();
    ArrayList totalCount , failCount,passCount ,Week = new ArrayList();
    object[] totalValues, passValues, failValues;
    protected void Page_Load(object sender, EventArgs e)
    {
        Report();
    }
    public DataSet BindData()
    {
        String conString = ConfigurationManager.ConnectionStrings["xxxxxxxxConnectionString"].ConnectionString;
        MySqlConnection connection = new MySqlConnection(conString);
        connection.Open();
        MySqlCommand command = new MySqlCommand();
        command.CommandText = "SELECT `Week`,`total`,`PassCount`,`FailCount` FROM Regression";
        command.Connection = connection;
        MySqlDataAdapter da = new MySqlDataAdapter(command);
        try
        {
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    private void Report()
    {
        dsSeries = BindData();
        if (dsSeries == null) return;
        foreach (DataRow ww in dsSeries.Tables[0].Rows)
        {
            Week.Add(ww["Week"]);
        }
        foreach (DataRow tot in dsSeries.Tables[0].Rows)
        {
            totalCount.Add(Convert.ToInt32(tot["total"]));
            totalValues = totalCount.ToArray(typeof(object)) as object[];
        }
        foreach (DataRow pass in dsSeries.Tables[0].Rows)
        {
            passCount.Add(Convert.ToInt32(pass["PassCount"]));
            passValues = passCount.ToArray(typeof(object)) as object[];
        }
        foreach (DataRow fail in dsSeries.Tables[0].Rows)
        {
            failCount.Add(Convert.ToInt32(fail["FailCount"]));
            failValues = failCount.ToArray(typeof(object)) as object[];
        }
        hcline.Title = new Title ("Report");            
        hcline.YAxis.Add(new YAxisItem { title = new Title("Number of Tests") });
        hcline.XAxis.Add(new XAxisItem { title= new Title("Week"), categories = Week.ToArray(typeof(string)) as string[] });
        var series = new Collection<Serie>();
        series.Add(new Serie { name = "Pass", data = passValues });
        series.Add(new Serie { name = "Fail", data = failValues });
        hcline.PlotOptions = new PlotOptionsLine { dataLabels = new DataLabels { enabled = true } };
        hcline.PlotOptions.events = new Highchart.Core.Events.PlotOptionEvents { click = "alert('hi :'+ this.category)" };
        //customize tooltip
        hcline.Tooltip = new ToolTip("'WW'+this.x +': '+ this.y");
        //bind to controls
        hcline.DataSource = series;
        hcline.DataBind();

    }
}

返回值undefined我也试过

this.x
event.point.x

。x返回undefined, event.point.x返回类别的索引。但是这个。

如何实现品类的价值?

请帮助! !

您可以使用event.point.category来获取类别的值