Hi @Sprutus Benton,
You need to follow the steps below to use ASP.Net 4.0 Chart Controls.
Make sure to add the reference (System.Web.DataVisualization.dll): (right click on the project->Add->Reference->Assemblies->Check System.Web.DataVisualization.dll)
Add the following to your Web.Config file:
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
</appSettings>
<system.webServer>
<handlers>
<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.7.2">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
****
</system.web>
***
</configuration>
Add this at the top of your aspx page:
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
Specify the X and Y values:XValueMember
,YValueMembers
.
Here's a complete example I wrote using test data:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<main>
<section class="row" aria-labelledby="aspnetTitle">
<h1 id="aspnetTitle">Metrics Dashboard</h1>
<p class="lead">The Metrics Dashboard provides detailed metrics about our Retail, Distribution, Sales & Service, and TMS areas. This information is a snapshot of transaction counts or AR data specific to EDI partners. Refresh the data to see updated statistics </p>
</section>
<div class="row">
<section class="col-md-4" aria-labelledby="TransactionTotalsTitle">
<asp:Chart ID="Chart1" runat="server" DataSourceID="sqldsTotalsByRegion">
<Series>
<asp:Series Name="Series1" IsValueShownAsLabel="True" XValueMember="Month" YValueMembers="Quantity"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisY>
<MajorGrid Enabled="true" />
</AxisY>
<AxisX>
<MajorGrid Enabled="true" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
<br />
<asp:SqlDataSource ID="sqldsTotalsByRegion" runat="server" ConnectionString="<%$ ConnectionStrings:BISWORKConnectionString %>" SelectCommand="select * from Table2"></asp:SqlDataSource>
</section>
<asp:GridView runat="server" DataSourceID="sqldsTotalsByRegion" ID="ctl00" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Month" HeaderText="Count by Transaction" ReadOnly="True" SortExpression="Count by Transaction"></asp:BoundField>
<asp:BoundField DataField="Quantity" HeaderText="Region" SortExpression="Region"></asp:BoundField>
</Columns>
</asp:GridView>
</div>
</main>
</asp:Content>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread