Time for action — a chart showing revenue versus units sold
- Create a copy of
ActualVsProjected.html
in the same folder and name itRevenueVsUnits.html
. - Change the reference of the chart SWF file in embedding code from
MSCombi2D.swf
toMSCombiDY2D.swf
, to use a chart with dual axes. - Change the XML URL to
RevenueVsUnits.xml
in the chart embedding code. - Create an XML file with the name
RevenueVsUnits.xml
in the same folder and write the following data in it:<chart caption='Harry's SuperMart' subcaption='Revenue and Units Sold by Year' xAxisName='Year' PYAxisName='Amount' SYAxisName='Units Sold' numberPrefix='$'> <categories> <category label='2009' /> <category label='2010' /> <category label='2011' /> </categories> <dataset seriesName='Revenue'> <set value='1487500' /> <set value='2100600' /> <set value='2445400' /> </dataset> <dataset seriesName='Units Sold' parentYAxis='S' renderAs='Line' showValues='0' color='666666'> <set value='24355' /> <set value='38998' /> <set value='43987' /> </dataset> </chart>
- Open
RevenueVsUnits.xml
in your browser. You should see a chart similar to the following screenshot:
What just happened?
We just enabled Harry to compare the revenues of Harry's SuperMart for the last three years, along with the units sold. This chart gives him a perspective on how the revenues are affected by the units sold. Note how this chart has two y-axes, one on the left called primary axis, and one on the right called secondary axis. Each axis has its title defined using two new attributes of the<chart>
element, PYAxisName
for the primary axis, and SYAxisName
for the secondary axis. The attribute YAxisName
is not applicable to this chart as there is no common y-axis.
<chart caption='Harry's SuperMart' subcaption='Revenue and Units Sold by Year' xAxisName='Year' PYAxisName='Amount' SYAxisName='Units Sold' numberPrefix='$'>
The numberPrefix
attribute gets applied to the primary axes. If we had to specify a number prefix for the secondary axes, we would use the attribute sNumberPrefix
.
There are two data series in the chart, the first representing the revenue, and the other containing data on the units sold. The second series, representing quantity, has a new attribute parentYAxis='S'
that lets you configure whether this data series is plotted against the primary axis (parentYAxis='P'
, by default) or the secondary axis (parentYAxis='S'
). In our example, as the units sold is to be plotted against the secondary axis, on the right, we have set parentYAxis='S'
, the other attributes remaining the same as before.
<dataset seriesName='Units Sold' parentYAxis='S' renderAs='Line' showValues='0' color='666666'>
If you were using a 3D chart such as MSColumn3DLineDY.swf
, the renderAs
attribute is not required, as the chart can only plot columns on the primary axis and lines on the secondary. Just setting parentYAxis='Y'
plots the data series as a line against the secondary y-axis.
- Learning LibGDX Game Development(Second Edition)
- Advanced Machine Learning with Python
- Node.js Design Patterns
- Python入門很簡單
- 動(dòng)手玩轉(zhuǎn)Scratch3.0編程:人工智能科創(chuàng)教育指南
- Java程序員面試算法寶典
- 機(jī)械工程師Python編程:入門、實(shí)戰(zhàn)與進(jìn)階
- JavaScript+Vue+React全程實(shí)例
- JSP開發(fā)案例教程
- SQL Server 2016數(shù)據(jù)庫應(yīng)用與開發(fā)習(xí)題解答與上機(jī)指導(dǎo)
- C#程序設(shè)計(jì)
- Gradle for Android
- Teaching with Google Classroom
- Flowable流程引擎實(shí)戰(zhàn)
- INSTANT Apache ServiceMix How-to