wxy新人小白
2019-09-27 18:29
采纳率: 71.4%
浏览 366

C#中点击不同的label,在同一位置上chart图数据发生变化,图表题为什么只出最后一个

一共有五个可点击的label(电缆护套,电缆线芯,芯片焊点,环氧密封胶,导热胶)
想要的效果:点击不同的电缆护套,应该出现标题为材料特性退化概况-电缆护套的chart曲线图,点击电缆线芯,应该出现标题为材料特性退化概况-电缆线芯的chart曲线图,其他类似。部分程序如下

 public void Creatchart8(string wax, string s)//材料特性退化概况-电缆线芯-柱形图
        {
            chart2.Series.Clear();
            if (flag5 == true)
            {
                chart2.Visible = true;
            }
            SQLiteDataAdapter mAdapter = new SQLiteDataAdapter("select " + wax + ",para from 电缆参数 union select " + s + ",para from 电缆参数1 ", m);
            string dbPath = @"D:\历年高考分数.db";
            string sq = @"Data Source=" + dbPath;
            m = new SQLiteConnection(sq);
            m.Open();
            DataSet ds = new DataSet();
            mAdapter.Fill(ds);
            DataTable dt = ds.Tables[0];
            chart2.DataSource = dt;
            Series s1 = new Series();
            s1.LegendText = "特性退化率";
            s1.IsValueShownAsLabel = true;
            chart2.Series.Add(s1);
            Series s2 = new Series();
            s2.LegendText = "剩余寿命";
            s2.IsValueShownAsLabel = true;
            chart2.Series.Add(s2);
            chart2.ChartAreas[0].AxisX.Title = "材料关键特性";
            chart2.ChartAreas[0].AxisY.Title = "特性退化率(%)";
            chart2.Titles[0].Text = "材料特性退化概况-电缆线芯";//索引
            chart2.Series[0].YValueMembers = wax;
            chart2.Series[1].YValueMembers = s;
            chart2.Series[0].XValueMember = "para";
            chart2.DataBind();
            m.Close();
        }
                public void Creatchart14(string wax, string s)//材料特性退化概况-导热胶-柱形图
        {
            chart2.Series.Clear();
            if (flag8 == true)
            {
                chart2.Visible = true;
            }
            SQLiteDataAdapter mAdapter = new SQLiteDataAdapter("select " + wax + ",para from 电缆参数 union select " + s + ",para from 电缆参数1 ", m);
            string dbPath = @"D:\历年高考分数.db";
            string sq = @"Data Source=" + dbPath;
            m = new SQLiteConnection(sq);
            m.Open();
            DataSet ds = new DataSet();
            mAdapter.Fill(ds);
            DataTable dt = ds.Tables[0];
            chart2.DataSource = dt;
            Series s1 = new Series();
            s1.LegendText = "特性退化率";
            s1.IsValueShownAsLabel = true;
            chart2.Series.Add(s1);
            Series s2 = new Series();
            s2.LegendText = "剩余寿命";
            s2.IsValueShownAsLabel = true;
            chart2.Series.Add(s2);
            chart2.ChartAreas[0].AxisX.Title = "材料关键特性";
            chart2.ChartAreas[0].AxisY.Title = "特性退化率(%)";
            chart2.Titles[0].Text = "材料特性退化概况-导热胶";//索引
            chart2.Series[0].YValueMembers = wax;
            chart2.Series[1].YValueMembers = s;
            chart2.Series[0].XValueMember = "para";
            chart2.DataBind();
            m.Close();
        }

这是其中的2个的程序。
问题:不管点击那个label,chart图的标题都为材料特性退化概况-导热胶?
另外SQLiteDataAdapter mAdapter = new SQLiteDataAdapter("select " + wax + ",para from 电缆参数 union select " + s + ",para from 电缆参数1 ", m);这句有问题,不知道如何改?
图片说明图片说明

1条回答 默认 最新

相关推荐 更多相似问题