Solved

Using the ASP.NET 4.5 Chart Control

Posted on 2013-06-06
9
2,312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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