gpt4 book ai didi

c# - 在 ASP.NET 中创建 XY 散点图

转载 作者:太空宇宙 更新时间:2023-11-03 11:45:29 26 4
gpt4 key购买 nike

我有两个数据数组,我想在 XY 散点图中显示。我已经下载了 ASP.NET 库,想知道如何显示数据。这是我在前端所做的一切,想知道是否有人对接下来的步骤有什么建议(即如何将数组数据绑定(bind)到 x 和 y 轴?)

谢谢

<asp:Chart runat="server" ID="scatter" Width="500px" Height="500px">
<Series>
<asp:Series Name="Series1" MarkerSize="10" ChartType="Point">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
BackSecondaryColor="White" BackColor="Gainsboro" ShadowColor="Transparent" BackGradientStyle="TopBottom">
<Area3DStyle Rotation="10" Perspective="10" Inclination="15" IsRightAngleAxes="False"
WallWidth="0" IsClustered="False" />
<AxisY LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>

您还知道如何让数据点在用户将鼠标悬停在它们上方时显示它们的值吗?

最佳答案

是一个数组包含 X 值而另一个数组包含 Y 值,还是两者都包含 Y 值?

如果是前者,您可以使用 DataBindXY 方法。

double [] xArray= { 2.8, 4.4, 6.5, 8.3, 3.6, 5.6, 7.3, 9.2, 1.0};
double [] yArray = { 3.1, 2.7, 4.6, 3.5, 3.3, 1.5, 4.5, 2.5, 2.1};
Chart1.Series["Series1"].Points.DataBindXY(xArray, yArray);

如果是后者,您可以创建第二个系列(只需复制您标记为 Series1 的部分并将其命名为 Series2),然后在每个系列上使用 DataBindY。

double [] yArray1= { 2.8, 4.4, 6.5, 8.3, 3.6, 5.6, 7.3, 9.2, 1.0};
double [] yArray2 = { 3.1, 2.7, 4.6, 3.5, 3.3, 1.5, 4.5, 2.5, 2.1};
Chart1.Series["Series1"].Points.DataBindY(yArray1);
Chart1.Series["Series2"].Points.DataBindY(yArray2);

这是一个很好的资源,通过示例解释了许多不同的数据绑定(bind)方法:http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx

关于c# - 在 ASP.NET 中创建 XY 散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3535388/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com