在 ASP.NET 中创建 XY 散点图

发布于 2024-09-15 17:10:21 字数 1316 浏览 1 评论 0原文

我有两个数据数组,想以 XY 散点图显示。我已经下载了 ASP.NET 库,并且想知道如何显示数据。这是我在前端得到的信息,想知道是否有人对下一步的建议有什么建议(即如何将数组数据绑定到 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>

你也知道如何当用户将鼠标悬停在数据点上时允许数据点显示其值?

I have two arrays of data that I would like to display in an XY scatter. I've downloaded the ASP.NET libraries and am wondering how to display the data. This is as far as I've gotten on the front end and was wondering if anyone has suggestions on what the next steps would be (i.e. how do I bind the array data to the x and y axes?)

thanks

<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>

Also do you know how to allow the datapoints to show their values when the user hovers over them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一向肩并 2024-09-22 17:10:22

一个数组包含 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);

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

Does one array contain X values and the other Y, or do both contain Y values?

If the former, you could use the DataBindXY method.

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);

If the latter, you could create a second series (just duplicate the part you have labeled as Series1 and call it Series2) and then use the DataBindY on each.

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);

This is a great resource explaining many different ways to databind all with examples: http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx

纸伞微斜 2024-09-22 17:10:22

我在使用 MS Chart 绘制图表方面从未取得过太大成功。非常适合图表!对于图表来说不太好。

您可以考虑查看 ZedGraph:

http://zedgraph.sourceforge.net/linesamples.html

I never had much success using MS Chart for graphs. Great for charts! Less great for graphs.

You might consider looking at ZedGraph:

http://zedgraph.sourceforge.net/linesamples.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文