图表显示的问题(100分)

  • 主题发起人 shijiesun
  • 开始时间
S

shijiesun

Unregistered / Unconfirmed
GUEST, unregistred user!
写了一段代码使用comboBox和chart组件显示各种金属粉末的销量:
var i:integer;
begin

if combobox1.Items[combobox1.ItemIndex]='铁粉' then
i:=1
else
if combobox1.Items[combobox1.ItemIndex]='铜和铜基粉末' then
i:=2
else
if combobox1.Items[combobox1.ItemIndex]='不锈钢粉' then
i:=3
else
if combobox1.Items[combobox1.ItemIndex]='钨粉' then
i:=4
else
i:=100;
case i of
1:begin

with Series1do

begin

add(1000,'一季度',clRed);
add(1200,'二季度',clRed);
add(1100,'三季度',clRed);
add(1300,'四季度',clRed);
end;

end;

2:begin

with Series1do

begin

add(2000,'一季度',clRed);
add(1000,'二季度',clRed);
add(1600,'三季度',clRed);
add(1000,'四季度',clRed);
end;

end;

3:begin

with Series1do

begin

add(6000,'一季度',clRed);
add(2200,'二季度',clRed);
add(4000,'三季度',clRed);
add(1800,'四季度',clRed);
end;

end;

4:begin

with Series1do

begin

add(4000,'一季度',clRed);
add(5200,'二季度',clRed);
add(8100,'三季度',clRed);
add(6300,'四季度',clRed);
end;

end;


end
end;

编译后第一次使用comboBox组件选择一种金属粉末后,chart组件中会显示出这种金属粉末的销量,接着选择其他金属粉末时,本以为在chart组件中会出现对应金属粉末的销量图表,可是在chart组件中却将第一次和第二次选择的金属粉末的数据共同显示在同一个图表中。
可以通过创建两个或多个Series来解决这个问题?每建一个Series,要加一个chart组件?
在combobox中选择新的Item后,是否可以通过增加一条语句,清除Series中原有内容。
 
你在选新的Item时,不能先删除久的Series吗。
 
Series1.clear?
 
在combobox1OnChange里面写
曲调if combobox1.Items[combobox1.ItemIndex]='铁粉' then
i:=1
else
if combobox1.Items[combobox1.ItemIndex]='铜和铜基粉末' then
i:=2
else
if combobox1.Items[combobox1.ItemIndex]='不锈钢粉' then
i:=3
else
if combobox1.Items[combobox1.ItemIndex]='钨粉' then
i:=4
改为
if trim(combobox1.text)='钨粉' then
i:= ......
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
568
import
I
顶部