Jump to content
Software FX Community

Can't get a stacked bar chart to work at all


User (Legacy)

Recommended Posts

I'm a new user of Chartfx. I can not get a stacked bar chart following the

samples and instructions.

I need five series on each bar and a bar per "wave". A wave is a season

I have a database table containing the information and the data looks like

this

Very satisfied Quite satisfied etc

etc etc

Winter 30 40 10

20 10

Autumn 30 40 10

20 10

Spring 30 40 10

20 10

Spring 30 40 10

20 10

the following code does not work, how should it be done?

'build the legend array from waves

strLegendsql = "select distinct wave from tblFigures"

set rsl =getdata(strLegendSql) arrLegend =rsl.getrows

'Build the chart

set chart = server.CreateObject("chartfx.webserver")

set cfxarray = server.CreateObject("cfxdata.array")

cfxarray.AddArray arrLegend

strsql = " SELECT Wave, [Very satisfied], [Quite satisfied],[Neither

nor],[Quite dissatisfied], [Very dissatisfied]FROM tblFigures WHERE question

='Overall'GROUP BY Wave, [Very satisfied], [Quite satisfied],[Neither

nor],[Quite dissatisfied], [Very dissatisfied];"

set rs = getdata(strSql)

'get the count rs.MoveLast

n =rs.recordcount

rs.movefirst

while not rs.eof

for i =0 to n-2

arrValues =rs.getrows(1,i)

cfxarray.AddArray arrValues

next

rs.movenext

wend

with chart

.ToolBar = true

.SerLegBox = true

.Title(0) = m_strYDesc

.Stacked = 1

.Chart3D = false

.Axis(0).TickMark = -32767

.Axis(0).GridColor = &H1000012&

.Axis(0).Decimals = 1

.Axis(0).Format = 1

.Axis(2).LabelAngle = 45

.Title(3) = m_strXDesc

.TopFont.Weight = 700

.AllowEdit = false

.AllowDrag = false

.DataEditor = true

.GetExternalData cfxarray

.RecalcScale

end with

Any advice gratefully accepted.

Ed

Link to comment
Share on other sites

"news" <edwardt@bostock.co.uk> wrote in message

news:$7iXbGFfDHA.1484@WEBSERVER1...

> I'm a new user of Chartfx. I can not get a stacked bar chart following the

> samples and instructions.

>

> I need five series on each bar and a bar per "wave". A wave is a season

>

> I have a database table containing the information and the data looks like

> this

> Very satisfied Quite satisfied etc

> etc etc

>

> Winter 30 40 10

> 20 10

> Autumn 30 40 10

> 20 10

> Spring 30 40 10

> 20 10

> Spring 30 40 10

> 20 10

>

> the following code does not work, how should it be done?

>

>

> 'build the legend array from waves

> strLegendsql = "select distinct wave from tblFigures"

> set rsl =getdata(strLegendSql) arrLegend =rsl.getrows

> 'Build the chart

> set chart = server.CreateObject("chartfx.webserver")

> set cfxarray = server.CreateObject("cfxdata.array")

> cfxarray.AddArray arrLegend

> strsql = " SELECT Wave, [Very satisfied], [Quite satisfied],[Neither

> nor],[Quite dissatisfied], [Very dissatisfied]FROM tblFigures WHERE

question

> ='Overall'GROUP BY Wave, [Very satisfied], [Quite satisfied],[Neither

> nor],[Quite dissatisfied], [Very dissatisfied];"

> set rs = getdata(strSql)

> 'get the count rs.MoveLast

> n =rs.recordcount

> rs.movefirst

>

>

> while not rs.eof

> for i =0 to n-2

> arrValues =rs.getrows(1,i)

> cfxarray.AddArray arrValues

> next

>

> rs.movenext

> wend

>

> with chart

> .ToolBar = true

> .SerLegBox = true

> .Title(0) = m_strYDesc

> .Stacked = 1

> .Chart3D = false

> .Axis(0).TickMark = -32767

> .Axis(0).GridColor = &H1000012&

> .Axis(0).Decimals = 1

> .Axis(0).Format = 1

> .Axis(2).LabelAngle = 45

> .Title(3) = m_strXDesc

> .TopFont.Weight = 700

> .AllowEdit = false

> .AllowDrag = false

> .DataEditor = true

> .GetExternalData cfxarray

> .RecalcScale

>

> end with

>

>

> Any advice gratefully accepted.

>

>

>

> Ed

>

>

Attempt number two using xML

This is the xml file

<DATA>

<COLUMNS

><COLUMN>Total</COLUMN>

<COLUMN>White British</COLUMN>

<COLUMN>Indian</COLUMN>

<COLUMN>Pakistani</COLUMN>

<COLUMN>Bangladeshi</COLUMN>

<COLUMN>Afrocaribbean</COLUMN>

<COLUMN>sixteen to nineteen</COLUMN>

<COLUMN>Twenty to thirty four</COLUMN>

<COLUMN>Thirty five plus</COLUMN>

</COLUMNS>

<ROWS>

<ROW Total="1561" White-British="249" Indian="465" Pakistani="365"

Bangladeshi="224" Afrocaribbean="258" sixteen-to-nineteen="498"

Twenty-to-thirty-four="655" Thirty-five-plus="408"/>

<ROW Total="2455823" White-British="1979281" Indian="164705"

Pakistani="142782" Bangladeshi="67541" Afrocaribbean="101514"

sixteen-to-nineteen="219053" Twenty-to-thirty-four="754027"

Thirty-five-plus="1482743"/>

<ROW Total="1232092" White-British="967576" Indian="84445" Pakistani="86044"

Bangladeshi="42869" Afrocaribbean="51158" sixteen-to-nineteen="85107"

Twenty-to-thirty-four="345757" Thirty-five-plus="801229"/>

<ROW Total="0.502" White-British="0.489" Indian="0.513" Pakistani="0.603"

Bangladeshi="0.635" Afrocaribbean="0.504" sixteen-to-nineteen="0.389"

Twenty-to-thirty-four="0.459" Thirty-five-plus="0.54"/>

<ROW Total="107174" White-British="66062" Indian="16600" Pakistani="9766"

Bangladeshi="7076" Afrocaribbean="7670" sixteen-to-nineteen="19454"

Twenty-to-thirty-four="10049" Thirty-five-plus="77672"/>

<ROW Total="0.044" White-British="0.033" Indian="0.101" Pakistani="0.068"

Bangladeshi="0.105" Afrocaribbean="0.076" sixteen-to-nineteen="0.089"

Twenty-to-thirty-four="0.013" Thirty-five-plus="0.052"/>

<ROW Total="1070230" White-British="901271" Indian="63561" Pakistani="46971"

Bangladeshi="16627" Afrocaribbean="41800" sixteen-to-nineteen="114394"

Twenty-to-thirty-four="390190" Thirty-five-plus="565646"/>

<ROW Total="0.436" White-British="0.455" Indian="0.386" Pakistani="0.329"

Bangladeshi="0.246" Afrocaribbean="0.412" sixteen-to-nineteen="0.522"

Twenty-to-thirty-four="0.517" Thirty-five-plus="0.381"/>

<ROW Total="46326" White-British="44372" Indian="99" Pakistani="0"

Bangladeshi="970" Afrocaribbean="886" sixteen-to-nineteen="99"

Twenty-to-thirty-four="8032" Thirty-five-plus="38196"/>

<ROW Total="0.019" White-British="0.022" Indian="0.001" Pakistani="0"

Bangladeshi="0.014" Afrocaribbean="0.009" sixteen-to-nineteen="0.011"

Twenty-to-thirty-four="0.026"/>

</ROWS>

</DATA>

cfxml.LoadFromString strXML

with chart

.ToolBar = true

.Grid = true

.Chart3D = true

.Gallery = bar

.CylSides=32

.Scrollable = True

.GetExternalData

cfxml .Stacked = CHART_STACKED100

.RecalcScale

end with

Response.write chart.GetHtmlTag("100%","100%")

The latter gives me 5 3d bars with two series on each containing

unrecognizable data

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...