Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net chart control how to create to y axis

Posted on 2015-01-21
2
Medium Priority
?
670 Views
Last Modified: 2015-01-26
I have  a chart control that shows like this which is rents for a particular period.  See Image 1,  What I need to do is add another series, this on being occupancy and this follows the numbers that I would like to see on the right.  This range is from 75% to 100%, So on the right I would like to the pct's on the right the chart with another line in chart area following those pcts.

Sample html code would be great

thanks
existing chart

Open in new window

0
Comment
Question by:mgmhicks
[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
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 40565730
Try something like this:
        <asp:XmlDataSource ID="XmlDataSource1" runat="server">
            <Data>
                <root>
                    <record id="1" name="Peter" amount="310000" perc="80" />
                    <record id="2" name="Paul" amount="318000" perc="95" />
                    <record id="3" name="Mary" amount="340000" perc="85" />
                </root>
            </Data>
        </asp:XmlDataSource>
        <asp:Chart ID="Chart1" runat="server" DataSourceID="XmlDataSource1" ImageStorageMode="UseImageLocation" Width="1100" Height="450">
            <Series>
                <asp:Series Name="Series1" ChartType="Line" LegendText="Net Rents" XValueMember="name" YValueMembers="amount">
                </asp:Series>
                <asp:Series Name="Series2" ChartType="Line" LegendText="Occupancy %" XValueMember="name" YValueMembers="perc" YAxisType="Secondary">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                    <AxisY Interval="10000" Minimum="300000" Maximum="350000">
                        <MajorGrid LineColor="Gray" />
                    </AxisY>
                    <AxisY2 Interval="5" Minimum="75" Maximum="100">
                        <MajorGrid LineColor="Silver" />
                        <LabelStyle ForeColor="Orange" />
                    </AxisY2>
                </asp:ChartArea>
            </ChartAreas>
            <Legends>
                <asp:Legend LegendStyle="Row" Docking="Top"></asp:Legend>
            </Legends>
        </asp:Chart>

Open in new window


So key parts are: YAxisType="Secondary" in the second Series and <AxisY2 Interval="5" Minimum="75" Maximum="100"> in the ChartArea.

Note that I 'manually' made sure both y axes have the same number of lines otherwise it can get ugly, but you can also play with color (as shown in the code) or disable one of them.

example pic
0
 

Author Closing Comment

by:mgmhicks
ID: 40570521
Awesome example thank you!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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