0

我目前有一个使用 asp.net 图表工具包的点图,但想在同一张图表上放置一条最佳拟合线。假设我知道如何计算直线 (y=mx+b) 的方程,我将如何在同一张图中将其覆盖?

4

2 回答 2

0

需要在 ChartArea 中创建不同的系列并设置 ChartType = "Line"

于 2010-08-24T17:38:54.093 回答
0

我希望这段代码可以帮助你:

<asp:Chart ID="Chart1" runat="server" Width="1000" BorderlineColor="Black" DataSourceID="SqlDataSource1">                    
                       <series>
                <asp:Series Name="Achieved %" XValueMember="date" YValueMembers="actual_value" Color="Plum" IsValueShownAsLabel="true" Palette="Pastel" ShadowColor="Bisque" > </asp:Series>             
             <asp:Series BorderWidth="2" Name="Target" ChartType="Line" Color="#00ff00" YValueMembers="target_value" BorderDashStyle="Dash"></asp:Series>
             <asp:Series BorderWidth="2" Name="Average %" ChartType="Line" Color="Brown" YValueMembers="average" BorderDashStyle="Dash"></asp:Series>
            </series>
         <Legends>
            <asp:Legend Name="DefaultLegend" Enabled="True" Docking="Bottom" />
         </Legends>
                     <chartareas>
                        <asp:ChartArea Name="ChartArea1">
                             <axisy Title="Achieved %">
                              <MajorGrid Enabled ="False" />
                    </axisy>
                    <axisy2 Title="Objective">
                                    <MajorGrid Enabled ="False" />
                    </axisy2>
                                <axisx Title="Date" Interval="1">
                                    <MajorGrid Enabled="false"/>
                                </axisx>

                        <asp:Chart ID="Chart1" runat="server" Width="1000" BorderlineColor="Black" DataSourceID="SqlDataSource1">                    
                       <series>
                <asp:Series Name="Achieved %" XValueMember="date" YValueMembers="actual_value" Color="Plum" IsValueShownAsLabel="true" Palette="Pastel" ShadowColor="Bisque" > </asp:Series>             
             <asp:Series BorderWidth="2" Name="Target" ChartType="Line" Color="#00ff00" YValueMembers="target_value" BorderDashStyle="Dash"></asp:Series>
             <asp:Series BorderWidth="2" Name="Average %" ChartType="Line" Color="Brown" YValueMembers="average" BorderDashStyle="Dash"></asp:Series>
            </series>
         <Legends>
            <asp:Legend Name="DefaultLegend" Enabled="True" Docking="Bottom" />
         </Legends>
                     <chartareas>
                        <asp:ChartArea Name="ChartArea1">
                             <axisy Title="Achieved %">
                              <MajorGrid Enabled ="False" />
                    </axisy>
                    <axisy2 Title="Objective">
                                    <MajorGrid Enabled ="False" />
                    </axisy2>
                                <axisx Title="Date" Interval="1">
                                    <MajorGrid Enabled="false"/>
                                </axisx>

                        </asp:ChartArea>
                    </chartareas>
                </asp:Chart>

示例图表

于 2018-07-04T12:25:29.953 回答