Change color of datapoint


How can I change the color of any datapoint in my Shinobichart.

Eg of the sample code : 

//Obtaining the datapoint

for (i -0 ; i < 5; i++)


SChartDataPoint* datapoint = [self dataPointForValue:[NSNumber numberWithInt:i] andValue: [NSNumber numberWithInt:i]];
[_arr_weight addObject:datapoint];
//Plotting the x-axis point
 Now when I draw my graph using ShinobiChart , I would like to change color on my individual datapoints. What would be the function to do that ?


Hi sim777,

In order to provide per-point styling, you need to create a custom subclass of the appropriate series type and override the styleForPoint: method.

For example, if you’re creating a scatter series:

@interface MyScatterSeries : SChartScatterSeries

and implementation:

@implemetation MyScatterSeries
    - (SChartPointStyle*)styleForPoint:(id<SChartData>)point {
         SChartPointStyle *newStyle = [super styleForPoint:point];
         float yValue = [[point sChartYValue] floatValue];
         if (yValue > 90) {
             newStyle.color = [UIColor redColor];
         } else if(yValue > 50) {
             newStyle.color = [UIColor yellowColor];
         } else {
             newStyle.color = [UIColor greenColor];
         return newStyle;

Hope that helps



Hi , Thank you for your response

I am not looking at a per point styling , rather just a change of color of  the given datapoints (all of them ) . My current code is as follows :

Using the below code when I add datapoints and plot the graph I get the default color for the datapoint. How do I change the color of these datapoints (all of them will show a single color)

_shinobiChart.autoresizingMask =  ~UIViewAutoresizingNone;

    _shinobiChart.datasource = self;

    _shinobiChart.delegate = self;

    _shinobiChart.licenseKey = ShinobiLicenceKey;

    _shinobiChart.canvasInset = UIEdgeInsetsMake(2, 0, 0, 5);

    _shinobiChart.gesturePanType = SChartGesturePanTypeNone; //PAN CHANGE CESAR-SIM


    _shinobiChart.crosshair.hidden = NO;

    SChartLightTheme *theme = [SChartLightThemenew];


   SChartCategoryAxis *xAxis = [[SChartCategoryAxisalloc] init];

     xAxis.rangePaddingHigh = @(0.5);

     xAxis.rangePaddingLow = @(0.5);

    _shinobiChart.xAxis = xAxis;

    //Explaining the properties of the y-axis

    SChartNumberAxis *yAxis = [[SChartNumberAxisalloc] init];

    yAxis.rangePaddingLow = @(0.1);

    yAxis.rangePaddingHigh = @(0.1);

    _shinobiChart.yAxis = yAxis;



Hi sim777,

In this case, you could setup the selected style of your series as you wish, then toggle series.selected and redraw the chart, which will toggle the datapoints’ colours to their “selected” counterpart.

Hope this does the trick!

Regards, Rob


Hi Rob,

I could change the datapoint color of my graph as follows :

//Override the following function 

-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(NSInteger)index { = [UIColor redColor];


The next part to my question is , for a shinobichart where I am plotting two line charts (i.e single common x-axis , but 2 values of the y-axis for each value of the x-axis). In this case how to customize to get 2 different colors for these 2 y-axis data points ?