I am using asp chart (framework 4.0) in one of the web page.
Chart displays x and y points from database.
I want to fix the scaling of only Y-axis i.e., between 1 to -1
as y axis point will lie within 1 to -1, as below:
1
0.75
0.50
0.25
0 -----------------------------------------------
-0.25
-0.50
-0.75
-1
C# code:
Chart1.Visible = true;
string id = Request.QueryString[1].ToString();
string query = "SELECT x,y from Table where ID= '" + id + "' and DeletionDate is null";
DataTable dt = GetData(query);
string[] x = new string[dt.Rows.Count];
double[] y = new double[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
x[i] = dt.Rows[i][0].ToString();
y[i] = Convert.ToDouble(dt.Rows[i][1]);
}
Chart1.Series[0].Points.DataBindXY(x, y);
Chart1.Series[0].ChartType = SeriesChartType.Line;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
Chart1.Legends[0].Enabled = true;
Color col = ColorTranslator.FromHtml("#cc99cc");
Chart1.ChartAreas["ChartArea1"].AxisX.LineColor = col;
Chart1.ChartAreas["ChartArea1"].AxisX.LineWidth = 2;
Chart1.ChartAreas["ChartArea1"].AxisY.LineColor = col;
Chart1.ChartAreas["ChartArea1"].AxisY.LineWidth = 2;
HTML code:
<asp:Chart ID="Chart1" runat="server" Height="300px" Width="400px" Visible="false" BorderlineColor="#e5e4e2" BorderlineWidth="2" BorderlineDashStyle="Solid">
<Titles>
<asp:Title ShadowOffset="3" Name="Items"/>
</Titles>
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default" LegendStyle="Row" />
</Legends>
<Series>
<asp:Series Name="Line" ChartType="Line" BorderWidth="1" MarkerStyle="Circle" MarkerBorderWidth="3" MarkerBorderColor="Blue" Color="DarkBlue"/>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"/>
</ChartAreas>
</asp:Chart>
Please reply how to achieve that.