Solved

asp.net chart control how to create to y axis

Posted on 2015-01-21
2
635 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

632 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