Solved

Using the ASP.NET 4.5 Chart Control

Posted on 2013-06-06
9
2,221 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
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.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net VB.net Object not set to an instance of an object 4 33
Icons and Colors for Terms 3 24
Not showing page correctly 3 29
Replace &lt; with < 14 53
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

10 Experts available now in Live!

Get 1:1 Help Now