VB6のMSCHARTをご存じの方。データが4個で円グラフを書き、各4個の色を自由に設定する。円グラフの中又は近くにデータと項目を表示する。例えば:国語/50点とか・・(凡例ではなくて)すぐに実践できるコーディング例を教えてください!!

回答の条件
  • URL必須
  • 1人2回まで
  • 登録:
  • 終了:--
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

回答5件)

id:actual No.1

回答回数610ベストアンサー獲得回数1

ポイント10pt

http://www.bcap.co.jp/hanafusa/VBHLP/mscsono2.htm

グラフのタイプを変更・データポイントラベル・凡例・マーカの表示設定(その2)

これでいかがでしょうか

id:Sweet

実は今、このHPを参照して実験しています。

この例では円グラフの円の中に文字は書けないようでした。

2004/07/15 18:19:27
id:LED No.2

回答回数23ベストアンサー獲得回数0

ポイント10pt

URLはダミーです。

興味があったのでやってみました。

これで試してみてください。(^^

Dim arrValues(1 To 6)

Dim i As Integer

Me.MSChart1.chartType = 14

Me.MSChart1.Row = 1

Me.MSChart1.Column = 1

Me.MSChart1.RowLabel = ”test”

lowerbound = 30

upperbound = 50

Me.MSChart1.Plot.Backdrop.Fill.Brush.FillColor.Automatic = False

Me.MSChart1.Plot.Backdrop.Fill.Brush.FillColor.Set 255, 255, 255

Me.MSChart1.Plot.Backdrop.Fill.Brush.Style = VtFillStyleBrush

arrValues(1) = ”test” ’ ラベル指定

arrValues(2) = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) ’ 系列 1 の値

arrValues(3) = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) ’ 系列 2 の値

arrValues(4) = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) ’ 系列 3 の値

arrValues(5) = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) ’ 系列 4 の値

arrValues(6) = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) ’ 系列 5 の値

For i = 1 To 5

Me.MSChart1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint

Me.MSChart1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.Component = VtChLabelComponentSeriesName

Me.MSChart1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.VtFont.VtColor.Set 1, 1, 1

Next

Me.MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set 255, 0, 0

Me.MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set 255, 255, 0

Me.MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set 0, 255, 64

Me.MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set 0, 255, 255

Me.MSChart1.Plot.SeriesCollection(5).DataPoints(-1).Brush.FillColor.Set 0, 128, 192

Me.MSChart1.Plot.SeriesCollection(1).LegendText = ”商品1”

Me.MSChart1.Plot.SeriesCollection(2).LegendText = ”商品2”

Me.MSChart1.Plot.SeriesCollection(3).LegendText = ”商品3”

Me.MSChart1.Plot.SeriesCollection(4).LegendText = ”商品4”

Me.MSChart1.Plot.SeriesCollection(5).LegendText = ”商品5”

Me.MSChart1.ShowLegend = True

MSChart1.Plot.Axis(VtChAxisIdX).Labels(1).Auto = False

MSChart1.Plot.Axis(VtChAxisIdX).Labels(1).TextLayout.VertAlignment = VtVerticalAlignmentCenter

MSChart1.Plot.Axis(VtChAxisIdX).Labels(1).TextLayout.HorzAlignment = VtHorizontalAlignmentCenter

MSChart1.ChartData = arrValues

id:Sweet

Me.MSChart1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint

データ範囲を超えたエラーが出ますが・・

2004/07/15 19:12:37
id:LED No.3

回答回数23ベストアンサー獲得回数0

ポイント20pt

http://auctions.yahoo.co.jp/

Yahoo!オークション

あ、すみません。

最後の一行消してください。

このままだとCドライブ直下に画像吐き出します…。

あれ質問よく見ると「凡例ではなくて」ですか、もしかしてちょっとずれてますか?

id:cx20 No.4

回答回数607ベストアンサー獲得回数108

ポイント40pt

試しにコードを書いてみました。

残念ながら「国語/50点」という書式がうまくいかなかった為、

「国語 50」としています。

ご希望の動作になっていないようでしたら、ポイントは結構です。

Private Sub Command1_Click()

With MSChart1

’ 円グラフを指定

.chartType = VtChChartType2dPie

’ テストデータ

For i = 1 To 4

.Row = 1

.Column = i

.Data = i * 100

Next

With .DataGrid

.RowLabelCount = 1

.ColumnCount = 4

.RowCount = 1

For i = 1 To .ColumnCount

.ColumnLabel(i, 1) = ”Column ” & i

Next i

.RowLabel(1, 1) = ”成績グラフ”

End With

’ 項目の表示内容のカスタマイズ

For i = 1 To .Plot.SeriesCollection.Count

With .Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel

’ ラベルはパイのスライスの内部に表示されます。

.LocationType = VtChLabelLocationTypeInside

’ データ ポイントの値がラベルに表示されます。

.Component = VtChLabelComponentValue

Select Case i

Case 1

.ValueFormat = ”国語 0”

Case 2

.ValueFormat = ”算数 0”

Case 3

.ValueFormat = ”理科 0”

Case 4

.ValueFormat = ”社会 0”

End Select

End With

Next i

End With

End Sub

http://support.microsoft.com/?kbid=230484

How To Label Pie Slices as Percentages in MSChart Pie Chart

参考情報です。

参考情報です。

id:Sweet

お世話になりました。ほぼ、網羅されています。

もう少しいろいろやって見ます。

2004/07/16 10:30:24
id:TMPTMP No.5

回答回数1ベストアンサー獲得回数0

ポイント10pt

LEDです。

2回書いてしまったので同一IDで回答できないため、こちらで補足させて頂きます。

最初の方に以下を入れてください。

Me.MSChart1.ColumnCount = 5

id:Sweet

有り難うございました。OKです。

2004/07/16 10:33:35

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません