Question

I have two line series and how do I make points on both series selected at the same time? Basically, my chart has 2 y values sharing the same x value and I'm representing them as two series. I want to display both points as selected for a given X Value.

Hi there,Thanks for the reply.
I'm doing that in

- (void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint

    SChartDataPoint* point1Series1 = [chart.datasource sChart:chart dataPointAtIndex:dataPoint.index forSeriesAtIndex:0];
    point1Series1.selected = YES;

    SChartDataPoint* point1Series2 = [chart.datasource sChart:chart dataPointAtIndex:dataPoint.index forSeriesAtIndex:1];
    point1Series2.selected = YES;

When I print the selected state of both points after this line of code, they return 1(selected) but they don't seem to appear as selected on the chart only the one I selected on the chart on device seem to appear as selected though I'm calling redrawChart after that. Any help would be appreciated

Was it helpful?

Solution

I think that it's likely (and I'm guessing because I can't see your code) that your chart data source isn't returning a reference to a datapoint which is part of the chart, but instead generating a new datapoint object each time you request one.

In order to cope with this you can request the data points from the chart itself, via the dataSeries property on SChartSeries objects.

The following delegate method should perform the selection you require.

- (void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint
{
    // Selection details
    NSInteger dataPointIndex = dataPoint.index;
    BOOL selected = dataPoint.selected;

    for (SChartSeries *chartSeries in chart.series) {
        // If only one data point in the series can be selected at once, then deselect the rest
        if(!series.togglePointSelection && selected) {
            for(SChartDataPoint *dp in chartSeries.dataSeries.dataPoints) {
                dp.selected = NO;
            }
        }
        // Find the data point and perform the selection
        SChartDataPoint *dp = chartSeries.dataSeries.dataPoints[dataPointIndex];
        dp.selected = selected;
    }
}

Hope that helps.

OTHER TIPS

You should be able to set .selected on the datapoints and customise the series.style.selectedPointStyle properties to display points how you wish :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top