Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-engineering the core abstract-chart code. #355

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
58f9f9a
Fix linear gradient issue due to `react-native-svg` lib update
aboveyunhai Jun 9, 2020
82b71a3
reimplement core chart, support bar-chart for full dynamic sizes
aboveyunhai Jun 15, 2020
162e676
Merge pull request #1 from aboveyunhai/dynamic-chart-size
aboveyunhai Jun 15, 2020
a82b7b8
Update README.ME for chartStyle
aboveyunhai Jun 15, 2020
7fad3a7
re-invent heatmap to fully dynamy and layout-control
aboveyunhai Jun 16, 2020
780a7f8
Merge pull request #2 from aboveyunhai/dynamic-chart-size
aboveyunhai Jun 16, 2020
ecd718d
Update README.md
aboveyunhai Jun 16, 2020
1e2c5b5
fully responsive support for line-chart, All padding includes.
aboveyunhai Jun 23, 2020
9be8679
Add tooltip to contribution chart onPressIn and onPressOut
aboveyunhai Jun 23, 2020
17001b0
Merge and fix conflicts
aboveyunhai Jun 23, 2020
d32fa5a
Merge pull request #3 from aboveyunhai/dynamic-chart-size
aboveyunhai Jun 23, 2020
1be57b2
Update abstract-chart compatibility for line-chart, shift default GRA…
aboveyunhai Jun 23, 2020
f093150
Merge pull request #4 from aboveyunhai/dynamic-chart-size
aboveyunhai Jun 23, 2020
49ed337
Fix: correct midpoint for BarChart labels
aboveyunhai Jun 23, 2020
5ce937b
Merge pull request #5 from aboveyunhai/dynamic-chart-size
aboveyunhai Jun 23, 2020
5910ef6
Fix: did not update when data changes
aboveyunhai Jul 6, 2020
5c70620
Merge pull request #6 from aboveyunhai/dynamic-chart-size
aboveyunhai Jul 6, 2020
bfb53c8
correct data display on scrollableInfo
aboveyunhai Jul 7, 2020
5c4fd0f
Merge pull request #7 from aboveyunhai/dynamic-chart-size
aboveyunhai Jul 7, 2020
6caba94
seperate hideLabel from hidePointsArIndex. correct vertical line hieg…
aboveyunhai Jul 23, 2020
8e540f4
Merge pull request #8 from aboveyunhai/dynamic-chart-size
aboveyunhai Jul 23, 2020
3cd41b8
Update index.d.ts
aboveyunhai Jul 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@ const chartConfig = {
color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,
strokeWidth: 2, // optional, default 3
barPercentage: 0.5,
useShadowColorFromDataset: false // optional
useShadowColorFromDataset: false, // optional
gutterTop: 10, // optional, default dynamic size: 10% * innerHeight after paddingTop and paddingBottom
horizontalLabelWidth: 30, // optional, default dynamic size:20% * innerHeight after paddingTop and paddingBottom
verticalLabelHeight: 30, // optional, default dynamic size: 15% * innerWidth after paddingLeft and paddingRight
chartStyle: { //optional
borderRadius: 10, //default 0
paddingTop: 10, //default 0
paddingBottom: 10,
paddingLeft: 10,
paddingRight: 10,
},
};
```

Expand All @@ -108,6 +118,9 @@ const chartConfig = {
| barRadius | Number | Defines the radius of each bar |
| propsForBackgroundLines | props | Override styles of the background lines, refer to react-native-svg's Line documentation |
| propsForLabels | props | Override styles of the labels, refer to react-native-svg's Text documentation |
| gutterTop | number | Define the gap between highest coordinate and padding |
| horizontalLabelWidth | number | Define the width of horizontal labels |
| verticalLabelHeight | number | Define the height of vertical labels |

## Responsive charts

Expand Down Expand Up @@ -415,14 +428,23 @@ const commitsData = [
chartConfig={chartConfig}
/>
```
Extra chartStyle for heatmap
```js
const chartConfig = {
chartStyle: {
justifyContent: 'start' || 'center' || 'end', //optional, defualt is 'start';
alignItems: 'start' || 'center' || 'end', //optional, default is 'start';
},
};
```

| Property | Type | Description |
| ------------------ | -------- | ------------------------------------------------------------------------------------------- |
| data | Object | Data for the chart - see example above |
| width | Number | Width of the chart, use 'Dimensions' library to get the width of your screen for responsive |
| height | Number | Height of the chart |
| gutterSize | Number | Size of the gutters between the squares in the chart |
| squareSize | Number | Size of the squares in the chart |
| squareSize | Number | Optional, Size of the squares in the chart, dynamic size will be auto applied if prop is not provided |
| horizontal | boolean | Should graph be laid out horizontally? Defaults to `true` |
| showMonthLabels | boolean | Should graph include labels for the months? Defaults to `true` |
| showOutOfRangeDays | boolean | Should graph be filled with squares, including days outside the range? Defaults to `false` |
Expand Down
14 changes: 13 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface LineChartProps {
* Show inner dashed lines - default: True.
*/

defMax?: number;
defMin?: number;
withScrollableDot?: boolean;
withInnerLines?: boolean;
/**
Expand Down Expand Up @@ -230,20 +232,26 @@ export interface BarChartProps {
data: ChartData;
width: number;
height: number;
fromZero?: boolean;
defMax?: number;
defMin?: number;
withInnerLines?: boolean;
yAxisLabel: string;
yAxisSuffix: string;
chartConfig: ChartConfig;
style?: ViewStyle;
horizontalLabelRotation?: number;
verticalLabelRotation?: number;
hideLabelsAtIndex?: (number | null)[];
barWidth?: number;
decorator?: ({}:any) => JSX.Element;
/**
* The number of horizontal lines
*/
segments?: number;
showBarTops?: boolean;
showValuesOnTopOfBars?: boolean;
withHorizontalLabels?: boolean;
withVerticalLabels?: boolean;
}

export class BarChart extends React.Component<BarChartProps> {}
Expand Down Expand Up @@ -306,6 +314,7 @@ export class PieChart extends React.Component<PieChartProps> {}

// ContributionGraph
export interface ContributionGraphProps {
style?: ViewStyle;
values: Array<any>;
endDate: Date;
numDays: number;
Expand All @@ -320,6 +329,9 @@ export interface ContributionGraphProps {
accessor?: string;
getMonthLabel?: (monthIndex: number) => string;
onDayPress?: ({ count: number, date: Date }) => void;
toggleTooltip?: boolean;
tooltipContent?: (dateInfo: { date: string, [accessor: string]: string},
args: {x:number, y:number, index:number}) => JSX.Element;
}

export class ContributionGraph extends React.Component<
Expand Down
Loading