Solved

Using the ASP.NET 4.5 Chart Control

Posted on 2013-06-06
9
2,200 Views
Last Modified: 2013-06-13
I have read the document that describes how to use the ASP.NET 4.5 Chart Control

http://msdn.microsoft.com/en-us/library/dd489237.aspx

The Chart control was in the tool box.  

If you cannot see the Chart control in the Toolbox, right click in the Toolbox, select Choose Items, and then select the following namespaces in the .NET Framekwork Components tab:

The following files are on my hard drive:
¿System.Web.UI.DataVisualization.Charting


¿System.Windows.Forms.DataVisualization.Charting

I added properties as follows:

         <asp:SqlDataSource ID="dscWatchListChart" runat="server"
         ConnectionString="<%$ ConnectionStrings:StockSelectSQLConnectionString %>"
         
         SelectCommand="SELECT QuoteDate, ClosePrice,
            CASE  
                    WHEN TradeVolume &lt; 200 THEN 1
                ELSE ROUND(Log10(TradeVolume/100)/Log10(2),1)
            END  
            AS TradeVolume, MovingPriceAvg,MovingVolAvg  
            FROM StockHist
              WHERE SymbolID=0 AND QuoteDate &gt;= '2009-01-02'
              AND QuoteDate &lt;= '2009-02-05'
            ORDER BY QuoteDate "  
         SelectCommandType="Text" >  
   
    </asp:SqlDataSource>
   
    <asp:chart id="ChtStock" runat="server" BackColor="#D3DFF0" Width="750px"
        Height="400px" ImageLocation="~/TempImages/ChartPic/"
        ImageType="Png" BorderDashStyle="Solid" Palette="BrightPastel"
        BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2"
        BorderColor="26, 59, 105" enableviewstate="True" viewstatecontent="All"
        DataSourceID="dscWatchListChart"  Visible= "false">
       
        <legends>
                  <asp:legend LegendStyle="Row" IsTextAutoFit="False" DockedToChartArea="Price"
                      Docking="Top" IsDockedInsideChartArea="True" Name="Default" BackColor="Transparent"
                      Font="Trebuchet MS, 8.25pt, style=Bold" Alignment="Center" MaximumAutoSize="80">
                  </asp:legend>
            </legends>
            
            <Titles>
            <asp:Title Name="Title1" BackColor="Yellow" BorderColor="Black"
                Font="Microsoft Sans Serif, 10pt, style=Bold" >
            </asp:Title>
        </Titles>
            
            <borderskin skinstyle="Emboss"></borderskin>
            
            <series>
          <asp:Series ChartArea="Price" ChartType="Point" Legend="Default" Name="Close"
                XValueMember="QuoteDate" YValueMembers="ClosePrice" Color="Blue" XValueType="Date">
            </asp:Series>
         
            <asp:Series ChartArea="Price" ChartType="Line" Legend="Default" Name="MovingAvg"
                XValueMember="QuoteDate" YValueMembers="MovingPriceAvg" Color="Black" XValueType="Date">
            </asp:Series>
           
            </series>
            
            <chartareas>
                  <asp:chartarea Name="Price" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
                      BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
                      BackGradientStyle="TopBottom" >
                        <position y="10" height="72" width="88" x="3"></position>
                        <axisy linecolor="64, 64, 64, 64" IsLabelAutoFit="False"
                            IsStartedFromZero="False"
                            Title = "Price" TitleFont ="Trebuchet MS, 8.25pt, style=Bold">
                              <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />
                              <majorgrid linecolor="64, 64, 64, 64" />
                        </axisy>
      
                        <axisx linecolor="64, 64, 64, 64" IsLabelAutoFit="True" LabelAutoFitStyle="StaggeredLabels" >
                              <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" IsEndLabelVisible="True" />
                              <majorgrid linecolor="64, 64, 64, 64" />
                        </axisx>
                  </asp:chartarea>
                  
             </chartareas>
      </asp:chart>
      

There is only one error:

Error      1      The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)      C:\Users\Dovberman\Documents\Visual Studio 2012\Projects\StockPro\WebApplication1\BestPicks.aspx.designer.cs      220      41      StockPro

Error Line:
protected global::System.Web.UI.DataVisualization.Charting.Chart ChtStock;

What do you suggest?

System.Web.UI.DataVisualization.Charting is not being recognized. Do I need a namespace declaration?

Thanks,
0
Comment
Question by:Dovberman
  • 6
  • 3
9 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39226100
uninstall and re-install
common problem
had a bad install
0
 

Author Comment

by:Dovberman
ID: 39226628
Do I need to uninstall and re-install VS 2012?

Will my projects be deleted?

Thanks,
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39226643
save your projects in a folder and you can return to them once you re-install :)
0
 

Author Comment

by:Dovberman
ID: 39226766
Thank you.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Expert Comment

by:plusone3055
ID: 39226948
no problem :)
Please award points if it fixed your issue :)
0
 

Author Comment

by:Dovberman
ID: 39227032
This did not help.

I started a new project which had only one page.  The one page contained only the chart control without any additional properties specified.

If this is a common problem, please give me a reference.

Thanks,
0
 

Author Comment

by:Dovberman
ID: 39229528
Has anyone else experienced this?
0
 

Accepted Solution

by:
Dovberman earned 0 total points
ID: 39231775
Several properties have been added to VS 2012.  If you open a VS2008 solution in VS 2012, the software will attempt to upgrade the project.  There may be errors due to compatibility between the two versions.

Some of the errors will be difficult to locate.
You will sometimes need to create a new page and add small sections of code from the old 2008 page until the error information is displayed. Then add additional code sections until all errors are revealed and corrected.
0
 

Author Closing Comment

by:Dovberman
ID: 39243849
This is the only solution that works.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ASP:DataGrid and how to bind to a BoundColumn 8 30
Exception in Log4Net 1 20
Expando 4 35
.Net application crashing 6 21
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now