3

Core Plot で CPTXYGraph を使用して円グラフを描画しています。デリゲートメソッドを使用しました

-(void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index

パイの特定のスライスがクリックされたときにいくつかのアクションを実行します。しかし、円グラフに触れると、特定のスライスがボタンイベントのように触れられたことを示すために、フィードバックまたは何らかの種類の画像の変化が表示される必要があります。

同じことを達成するためのデリゲートメソッドはありますか?

4

2 に答える 2

2

やるべきことがいくつかあります。

まず、これを円グラフデリゲート関数に実装します。

-(void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index
{
    indexOfPieGraphPlot = index; //gives index of pie which is selected.
    isPieGraphPlot = YES;     //boolean. if set to yes, will call rootcontroller function which will add pop up.
}

次に、CPTPlotSpaceDelegateを .h ファイルに追加します。

次に、この関数を使用します

- (BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(id)event atPoint:(CGPoint)point
{
    if(isPieGraphPlot) //if yes call showpopup of rootcontroller
    {
    isPieGraphPlot = NO;
    [rootController showPopUpView:point indexForPlot:indexOfPieGraphPlot];
    // point gives the x,y of the pie over which you want a pop up.
    }
    else    // if no then call remove popup from rootcontroller. this, incase user clicks anywhere else in graph.
    {
        [rootController removePopUp];
    }
    return  YES;
}
于 2012-07-06T07:09:20.700 に答える
0

-sliceFillForPieChart:recordIndex:メソッドをデータソースに実装します。選択したスライス (存在する場合) を追跡し、それを使用して各スライスに適用する塗りつぶしを決定します。-reloadData選択が変更されるたびにプロットを呼び出して、新しいスライス フィルを強制的にロードします。

于 2012-07-07T22:02:35.083 に答える