Solved

Using the ASP.NET 4.5 Chart Control

Posted on 2013-06-06
9
2,241 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Dovberman
ID: 39226766
Thank you.
0
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What namespace do I need to import? 2 25
Search an image for an image 3 27
Error handling in asp.net site 5 22
asp.net mvc5 6 11
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

816 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

11 Experts available now in Live!

Get 1:1 Help Now