简体   繁体   English

突出显示图表控件中的数据点

[英]Highlight data point in chart control

I am building my first own graph and im getting to what i need step by step. 我正在构建我自己的第一张图,并且我正在逐步获得我需要的东西。 But i have a small problem that i can not figure out. 但我有一个小问题,我无法弄清楚。 My Line Chart shows data and when i hover with my mouse over the data points it shows the value. 我的折线图显示数据,当我用鼠标悬停在数据点上时,它显示数值。 But there are no real points or circles on the data points in my chart and i can not seem to get them in the chart. 但是我的图表中的数据点上没有真正的点或圆圈,我似乎无法将它们放入图表中。

Here is my chart: 这是我的图表:

我的图表

As you can see, it is not clear where the datapoints are. 如您所见,目前尚不清楚数据点的位置。 Can anybode please help me figure out how to get circles on those points. anybode请帮我弄清楚如何圈出这些点。

Here is my c# code: 这是我的c#代码:

protected void Button1_Click(object sender, EventArgs e)
    {
        con = new SqlConnection(@"Data Source=LP12;Initial Catalog=SmmsData;Integrated Security=True");
        cmd = new SqlCommand("Select DrukSensor,DateTime from SysteemSensorInfo2", con);
        da = new SqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds);
        DataView source = new DataView(ds.Tables[0]);
        Chart1.DataSource = source;
        Chart1.Series[0].XValueMember = "DateTime";
        Chart1.Series[0].YValueMembers = "DrukSensor";
        Chart1.Series[0].BorderWidth = 3;
        Chart1.DataBind();
    }

And here is my html code: 这是我的HTML代码:

          <asp:Chart ID="Chart1" runat="server" BackSecondaryColor="0, 0, 192" Palette="Pastel" Width="1026px">
        <series>
            <asp:Series ChartType="Line" Name="Series0" ToolTip="#VALY">
            </asp:Series>
        </series>
        <chartareas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </chartareas>
    </asp:Chart>

Thanks in advance! 提前致谢!

In addition to the normal way of displaying the DataPoints for a given ChartType , in your case as Lines , you often can also ask to display Markers : 除了显示给定ChartTypeDataPoints的常规方式之外 ,在您的情况下为Lines ,您通常还可以要求显示Markers

在此输入图像描述

 Chart1.Series[0].XValueMember = "DateTime";
 Chart1.Series[0].YValueMembers = "DrukSensor";
 Chart1.Series[0].BorderWidth = 3;
 Chart1.DataBind();

 Chart1.Series[0].MarkerColor = Color.Red;
 Chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
 Chart1.Series[0].MarkerSize = 4;

You have a choice of several MarkerStyles including custom images; 您可以选择多种MarkerStyles包括自定义图像; you can even create custom images dynamically . 你甚至可以动态创建自定义图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM