chart type won change automatically? (Pivot Chart binds to pivot Table)

T

tcs

Hello, here got a question regarding using pivot chart and pivot table
as the data source...since the chart will change according the pivot
table data i assumed when i add measure to the data field it will
change the chart dynamically, but my assumption is wrong!

For example, initially i got total sale in data field of the pivot
table but when i add profit to data field, the chart still showing
total sale only. So does it means that i need to use event handler to
dynamically change the chart type? wat event to used? can i disallow
user to drag any measure from fieldlist to data field?

Thx for reading my post!
 
P

PierreDechaine

Just an idea you could try to use something like the following:
Call a sub routine on you page like initializeChart() I have two buttons
that a user clicks when switching between chart and pivot views. When
clicking the chart button I call initializeChart.

Partial code example assuming that you are using web page (have a form with
id = Form1, pivot table object with id=ptable, and chart object with id =
chart) :

<script language="vbscript">
Sub initializeChart()

Dim cht
Dim pview

' Bind the Chart control to the PivotTable control
Form1.chart.DataSource = Form1.ptable

' Get the chart or create one if needed
if Form1.chart.Charts.Count = 0 then
set cht = Form1.chart.Charts.Add()
else
set cht = Form1.chart.Charts(0)
end if


' Make sure the chart has a legend
cht.HasLegend = True

' Get the active view
set pview = Form1.ptable.ActiveView

Form1.chart.plotallaggregates = 1 'new piece of code 2 stacks on top, 1
is beside ** this should do the trick **

' Set the title to the PivotTable title
cht.HasTitle = True
cht.Title.Caption = pview.TitleBar.Caption

Form1.chart.AllowPropertyToolbox = true
Form1.chart.HasSelectionMarks = true
Form1.chart.DisplayToolbar = true

end sub
</script>
 
H

Hans Riis

Hi Thao.

I have another problem. I have a chart bound to a pivottable. For some
reason changing the chart also changes the pivottable but that's
another concern.

I'd like the measures on the chart and pivottable to be independant of
each other. That is, I'd like to show 6 measures in the pivottable but
only 3 in the chart. However, when I change filter values they should
apply to both chart and pivottable.

I've tried setting PlotAllAggregates to different values but nothing
seems to do the trick. Can you help?

Regards, Hans Riis
 
T

Thao Moua [ms]

First here some info on the PlotAllAggregates.

-chPlotAggregatesNone (0) - plot the first active total aggregate
-chPlotAggregatesSeries (1)- plot all the total aggregates (put all the
total aggregate on the data zone)
-chPlotAggregatesCategories (2) - plot all the aggregates (put all the total
aggregate on the row axis)
-chPlotAggregatesCharts (3) - show all the all the aggregates names, but
only plot the first aggregate

Second, when the Chartspace is bound to a datasource, whatever happens in
one control will affect the other. However, to achieve what you want and
since you know which series you want/don want, you can set the series
interior & border color to none.

set c=webchart.constants
webchart.charts(0).seriescollection(0).interior.color=c.chcolornone
webchart.charts(0).seriescollection(0).border.color=c.chcolornone

----------------------------------------------------------------------
Thao Moua
OWC Chartspace Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top