techtween

Scatter Plot Category Value Not Plotting Correctly

Recommended Posts

Hi All,

 

I am using FusionCharts XT with Rails 3.2. In one scenario, i'm using scatter(XY Plot) chart to present my data. The category value i need is 140 to 180 and y axis value is 2.0 to 4.4 with decimal value interval of .2. I dont get the requisite output, could anyone help me on this(My chart data gets aligned to the end of chart).

 

My xml builder file is as follows(i've also attached a screenshot of my chart for yours understanding),

 

xml = Builder::XmlMarkup.new

xml.chart(:palette=>'2', :caption=>'', :subcaption=>'', :showLegend=>'1', :showNames=>'1', :xAxisMinValue=>'140', :xAxisMaxValue=>'180', :adjustDiv=>'0', :numDivLines=>'22', :divLineColor=>'b2dde3', :divLineThickness=>'2', :alternateHGridColor=>'edfdff', :yAxisMinValue=>'2.0', :yAxisMaxValue=>'4.4', :yAxisValueDecimals=>'1', :decimals=>'1', :forcedecimals=>'1', :bgColor=>"196bdb,b2dde3", :bgAlpha=>"10,40", :showValues=>'140', :labelStep=>'2') do

# Run a loop to create the <category> tags within <categories>

xml.categories(:verticalLineColor=>'b2dde3', :verticalLineThickness=>'1') do

xml.category(:label=>'140', :x=>'140', :showVerticalLine=>'1')

xml.category(:label=>'142', :x=>'142', :showVerticalLine=>'1')

xml.category(:label=>'144', :x=>'144', :showVerticalLine=>'1')

xml.category(:label=>'146', :x=>'146', :showVerticalLine=>'1')

xml.category(:label=>'148', :x=>'148', :showVerticalLine=>'1')

xml.category(:label=>'150', :x=>'150', :showVerticalLine=>'1')

xml.category(:label=>'152', :x=>'152', :showVerticalLine=>'1')

xml.category(:label=>'154', :x=>'154', :showVerticalLine=>'1')

xml.category(:label=>'156', :x=>'156', :showVerticalLine=>'1')

xml.category(:label=>'158', :x=>'158', :showVerticalLine=>'1')

xml.category(:label=>'160', :x=>'160', :showVerticalLine=>'1')

xml.category(:label=>'162', :x=>'162', :showVerticalLine=>'1')

xml.category(:label=>'164', :x=>'164', :showVerticalLine=>'1')

xml.category(:label=>'166', :x=>'166', :showVerticalLine=>'1')

xml.category(:label=>'168', :x=>'168', :showVerticalLine=>'1')

xml.category(:label=>'170', :x=>'170', :showVerticalLine=>'1')

xml.category(:label=>'172', :x=>'172', :showVerticalLine=>'1')

xml.category(:label=>'174', :x=>'174', :showVerticalLine=>'1')

xml.category(:label=>'176', :x=>'176', :showVerticalLine=>'1')

xml.category(:label=>'178', :x=>'178', :showVerticalLine=>'1')

xml.category(:label=>'180', :x=>'180', :showVerticalLine=>'1')

end

 

 

# Run a loop to create the <set> tags within dataset for series 'Accepted'

xml.dataset(:seriesName=>'Accepted', :color=>'008000', :showPlotBorder=>'1', :anchorRadius=>'4', :anchorBgColor=>'008000') do

accepted.each do |accepted|

xml.set(:y=>accepted.gpa_lsdas, :x=>accepted.lsat)

end

end

# Run a loop to create the <set> tags within dataset for series 'Waitlisted'

xml.dataset(:seriesName=>'Waitlisted', :color=>'ffd700', :showPlotBorder=>'1', :anchorRadius=>'4', :anchorBgColor=>'ffd700') do

waitlisted.each do |waitlisted|

xml.set(:y=>waitlisted.gpa_lsdas, :x=>waitlisted.lsat)

end

end

# Run a loop to create the <set> tags within dataset for series 'Rejected'

xml.dataset(:seriesName=>'Rejected', :color=>'FF0000', :showPlotBorder=>'1', :anchorRadius=>'4', :anchorBgColor=>'FF0000') do

rejected.each do |rejected|

xml.set(:y=>rejected.gpa_lsdas, :x=>rejected.lsat)

end

end

end

post-28583-0-69391000-1344867305_thumb.jpg

Edited by techtween

Share this post


Link to post
Share on other sites

Alas, i got it out sorted. Problem was that the loop in my xml builder code fetched all data from db. I just modified my query by adding constraint in data that i passed and got the required output.:)

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

We are glad to know that you have managed to resolve the issue.

 

Happy FusionCharting :D

Share this post


Link to post
Share on other sites

I've stuck again in this. Kindly see the attachment, there is a huge gap(marked as red box) in x axis and the max value(180) doesnt occupy the full chart. What possible reason could that be?. Xml Builder file is the same as mentioned above in this thread. Also how to display the X axis names(140 to 180) horizontally.

post-28583-0-18963900-1344941316_thumb.jpg

Edited by techtween

Share this post


Link to post
Share on other sites

The generated XML data is as follows(pl note i haven't added all dataset values in it, as it would be too lengthy).

 

<chart palette="0" caption="" subcaption="" yAxisName="limits" xAxisName="scores" showLegend="1" showNames="1" labelPadding="4" xAxisMinValue="140" xAxisMaxValue="180" adjustDiv="0" numDivLines="22" divLineColor="b2dde3" divLineThickness="2" alternateHGridColor="edfdff" yAxisMinValue="2.0" yAxisMaxValue="4.4" yAxisValueDecimals="1" decimals="1" forcedecimals="1" bgColor="196bdb,b2dde3" bgAlpha="10,40" showValues="140" labelStep="1">
<categories verticalLineColor="b2dde3" verticalLineThickness="1" labelDisplay="ROTATE">
<category name="140" x="140" showVerticalLine="1" />
<category name="142" x="142" showVerticalLine="1" />
<category name="144" x="144" showVerticalLine="1" />
<category name="146" x="146" showVerticalLine="1" />
<category name="148" x="148" showVerticalLine="1" />
<category name="150" x="150" showVerticalLine="1" />
<category name="152" x="152" showVerticalLine="1" />
<category name="154" x="154" showVerticalLine="1" />
<category name="156" x="156" showVerticalLine="1" />
<category name="158" x="158" showVerticalLine="1" />
<category name="160" x="160" showVerticalLine="1" />
<category name="162" x="162" showVerticalLine="1" />
<category name="164" x="164" showVerticalLine="1" />
<category name="166" x="166" showVerticalLine="1" />
<category name="168" x="168" showVerticalLine="1" />
<category name="170" x="170" showVerticalLine="1" />
<category name="172" x="172" showVerticalLine="1" />
<category name="174" x="174" showVerticalLine="1" />
<category name="176" x="176" showVerticalLine="1" />
<category name="178" x="178" showVerticalLine="1" />
<category name="180" x="180" showVerticalLine="1" />
</categories>
<dataset id="DS1" seriesName="Accepted" color="008000" anchorSides="3" showPlotBorder="1" anchorRadius="4" anchorBgColor="008000">
<set x="178" y="4.1" link="P-detailsPopUp,toolbar=yes,scrollbars=yes,menubar=yes,directories=yes,status=yes,resizable=yes-http://google.com" tooltext="qwertie:  178 scores, 4.1 GPA" />
<set x="177" y="3.86" link="P-detailsPopUp,toolbar=yes,scrollbars=yes,menubar=yes,directories=yes,status=yes,resizable=yes-http://google.com" tooltext="LChicken:  177 scores, 3.86 GPA" />
<set x="177" y="3.83" link="P-detailsPopUp,toolbar=yes,scrollbars=yes,menubar=yes,directories=yes,status=yes,resizable=yes-http://google.com" tooltext="Maopa:  177 scores, 3.83 GPA" />
</dataset>
<dataset id="DS2" seriesName="Waitlisted" color="ffd700" anchorSides="8" showPlotBorder="1" anchorRadius="4" anchorBgColor="ffd700">
<set x="167" y="3.79" tooltext="brookedonphonics:  167 scores, 3.79 GPA" />
<set x="173" y="3.81" tooltext="freestallion:  173 scores, 3.81 GPA" />
<set x="170" y="4.06" tooltext="LaCumparsita:  170 scores, 4.06 GPA" />
</dataset>
<dataset id="DS3" seriesName="Rejected" color="FF0000" anchorSides="4" showPlotBorder="1" anchorRadius="4" anchorBgColor="FF0000">
<set x="167" y="3.96" tooltext="matveib:  167 scores, 3.96 GPA" /><set x="173" y="3.93" tooltext="tamereth:  173 scores, 3.93 GPA" />
<set x="169" y="3.87" tooltext="iphone7:  169 scores, 3.87 GPA" /><set x="161" y="3.4" tooltext="Elric:  161 scores, 3.4 GPA" />
<set x="173" y="3.64" tooltext="ariake890:  173 scores, 3.64 GPA" /><set x="166" y="3.82" tooltext="gatorapplicant:  166 scores, 3.82 GPA" />
</dataset>
<vtrendlines>
<line startValue="0" endValue="3" displayValue="Short Term" isTrendZone="1" color="FF0000" alpha="5" />
<line startValue="3" endValue="6" displayValue="Mid Term" isTrendZone="1" color="5B5B00" alpha="5" />
<line startValue="6" endValue="10" displayValue="Long Term" isTrendZone="1" color="009900" alpha="5" />
</vtrendlines>
</chart>

Edited by techtween

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

I am afraid, I am unable to replicate the issue.

 

Please find attached screen shot of the chart rendered.

 

Hope this helps!

post-23884-0-34139800-1345108979_thumb.png

Share this post


Link to post
Share on other sites

Many Thanks for yours time and reply.

 

Yes the data xml i've provided you works fine when the chart takes static data(eg: passing the data xml file to the chart as parameter; to plot). The same data when fetched from Database works as specified in the screen shot i've attached in above reply. Just now found one fix for it by increasing the width and height of the chart which resulted in the exact same result as you've specified. But doing so makes the legend non interactive. Digging into this issue now.

 

BTW, is Zoom in, Zoom out possible in this scatter XY Plot. If yes could you provide me an example of it.

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

I am afraid, Zoom feature is not supported by Scatter charts.

 

Zoom-in and Zoom-out features are supported only by the Zoom Line charts.

 

For more details on 'Zoom Line Chart Specification Sheet', please refer to the link below,

http://docs.fusionch...S/ZoomLine.html

 

Hope this helps!

Edited by Bindhu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now