绘制气泡图以获取数据绑定值,包括气泡大小

时间:2018-09-10 13:26:43

标签: c# sql-server data-binding mschart bubble-chart

i tried the Points.AddXY method as well but it gave the chart as shown in image.

我在sql server中有一个表(表名是ex1,它有3列:x,y和size)。

我已从C#连接到此表,并希望在应用程序中将其内容显示为气泡图。我能够绘制x和y轴的值,但无法正确获取y值的气泡大小。

我分享了以下代码。该代码正确地在x轴上绘制x值,但是使用“大小”列的值绘制y值。

    private void button1_Click(object sender, EventArgs e)
    {
        chart4.Series["Series2"].ChartType = SeriesChartType.Bubble;
        chart4.Series["Series2"].MarkerStyle = MarkerStyle.Circle;
        SqlConnection con0 = new SqlConnection(
         "Data Source=4L861280\\sqlexpress;Initial Catalog=vis1;Integrated Security=True;");
        SqlDataAdapter ad0 = new SqlDataAdapter("select * from ex1", con0);
        DataTable dt0 = new DataTable();
        ad0.Fill(dt0);
        chart4.DataSource = dt0;
        chart4.Series["Series2"].XValueMember = "x";
        chart4.Series["Series2"].YValueMembers = "y";
        chart4.Series["Series2"].YValueMembers = "size";
       }

0 个答案:

没有答案