Reordering Y-Axis not updating on redraw, only on reloaddata


#1

Hi,

I have several Y-Axis on a chart, and I use a custom legend to add/remove them, as well as reorder.  The issue I’ve run into is that it doesnt seem to be very simple, or designed to do this, so I’ve been experiementing with differnt methods.

The most reliable way I can seem to do the reordering is by the yAxisForSeriesAtIndex method, and keeping an array of the actual position, and returning the corresponding array:

- (SChartAxis *)sChart:(ShinobiChart *)chart yAxisForSeriesAtIndex:(NSInteger)index
{
    //Get the real index, as it may have moved
    NSInteger realIndex = [m_axisLookupTable[index] integerValue];
    SChartAxis* axis = [chart.allYAxes objectAtIndex:realIndex];
    
    return axis;
}

Should be a fairly simple method, it works great if my graph continuously updates (which calls reloadData, and redrawChart), but not so great if I have it paused (such that the data is not reloaded from its provider), in which case I simply call “redrawChart”.

I use the same technique to do other manipulations, such as turning off shading, changing colors, however I cannot seem to change the Y-Axis order without updaing the data.

Any help?


#2

Hi,

Currently I’m afraid the chart doesn’t support switching out axes without a reload of the data, the reason being that the data on the chart is linked to the axes, so if the axes are taken away, the chart would not know what to do with the data, whether it should be panned when certain axes pan, how to report back its position to the user, etc. A reload of the data is the only way currently I’m afraid.

Kind regards