react-native-chart-kit icon indicating copy to clipboard operation
react-native-chart-kit copied to clipboard

How to center ContributionGraph?

Open ji-1 opened this issue 5 years ago • 4 comments

Hi. I tried using style prop to center the graph but didn't work.

const graphStyle ={
    justifyContent: 'center', 
    alignItems: 'center', 
    flex:1, 
  };

Then, I found out paddingLeft value was hardcoded. Can I add a pull request to change this value customizable via props? Or do let me know if I made any mistake in the above code.

src/contribution-graph/index.js line 8: const paddingLeft = 32;

inside the renderSquare function

<Rect
        key={index}
        width={squareSize}
        height={squareSize}
        x={x + paddingLeft}
				...
/>

inside the renderMonth function

<Text
          key={weekIndex}
          x={x + paddingLeft}
          y={y + 8}
          {....getPropsForLabels()}
 >
          {this.props.getMonthLabel
            ? this.props.getMonthLabel(endOfWeek.getMonth())
            : MONTH_LABELS[endOfWeek.getMonth()]}
</Text>

and also, I think it would be nice to make padding between month label and graph customizable. IMG_5609 IMG_5610

ji-1 avatar May 23 '20 04:05 ji-1

+1 Found the same issue, it'd be an easy way great to make the graph center

metrue avatar Jul 03 '20 03:07 metrue

The same issue image

joket1999 avatar Sep 08 '20 02:09 joket1999

@ji-1 How did you set the colors of the text (Jan, Feb, Mar, ...?)

Stophface avatar Nov 04 '22 14:11 Stophface

Even I want the ContributionGraph to be centered, instead of the bottom

@ji-1 any solution for this?

devcoderbuzz avatar Feb 28 '25 15:02 devcoderbuzz