Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const data = {
| withShadow | boolean | Show shadow for line - default: True |
| withInnerLines | boolean | Show inner dashed lines - default: True |
| withOuterLines | boolean | Show outer dashed lines - default: True |
| withVerticalLabels | boolean | Show vertical labels - default: True |
| withHorizontalLabels | boolean | Show horizontal labels - default: True |
| fromZero | boolean | Render charts from 0 not from the minimum value. - default: False |
| yAxisLabel | string | Prepend text to horizontal labels -- default: '' |
| chartConfig | Object | Configuration object for the chart, see example config object above |
Expand Down Expand Up @@ -198,6 +200,8 @@ const data = {
| 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 |
| withVerticalLabels | boolean | Show vertical labels - default: True |
| withHorizontalLabels | boolean | Show horizontal labels - default: True |
| fromZero | boolean | Render charts from 0 not from the minimum value. - default: False |
| yAxisLabel | string | Prepend text to horizontal labels -- default: '' |
| chartConfig | Object | Configuration object for the chart, see example config in the beginning of this file |
Expand Down Expand Up @@ -232,6 +236,8 @@ const data ={
| 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 |
| withVerticalLabels | boolean | Show vertical labels - default: True |
| withHorizontalLabels | boolean | Show horizontal labels - default: True |
| chartConfig | Object | Configuration object for the chart, see example config in the beginning of this file |

## Pie chart
Expand Down
21 changes: 16 additions & 5 deletions src/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ class BarChart extends AbstractChart {
render() {
const paddingTop = 16
const paddingRight = 64
const {width, height, data, style = {}} = this.props
const {
width,
height,
data,
style = {},
withHorizontalLabels = true,
withVerticalLabels = true,
} = this.props
const {borderRadius = 0} = style
const config = {
width,
Expand Down Expand Up @@ -85,22 +92,26 @@ class BarChart extends AbstractChart {
})}
</G>
<G>
{this.renderHorizontalLabels({
{withHorizontalLabels
? this.renderHorizontalLabels({
...config,
count: 4,
data: data.datasets[0].data,
paddingTop,
paddingRight
})}
})
: null}
</G>
<G>
{this.renderVerticalLabels({
{withVerticalLabels
? this.renderVerticalLabels({
...config,
labels: data.labels,
paddingRight,
paddingTop,
horizontalOffset: barWidth
})}
})
: null}
</G>
<G>
{this.renderBars({
Expand Down
14 changes: 10 additions & 4 deletions src/line-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class LineChart extends AbstractChart {
withDots = true,
withInnerLines = true,
withOuterLines = true,
withHorizontalLabels = true,
withVerticalLabels = true,
style = {},
decorator,
onDataPointClick
Expand Down Expand Up @@ -265,13 +267,15 @@ class LineChart extends AbstractChart {
: null}
</G>
<G>
{this.renderHorizontalLabels({
{withHorizontalLabels
? this.renderHorizontalLabels({
...config,
count: Math.min(...datas) === Math.max(...datas) ? 1 : 4,
data: datas,
paddingTop,
paddingRight
})}
})
: null}
</G>
<G>
{withInnerLines
Expand All @@ -290,12 +294,14 @@ class LineChart extends AbstractChart {
: null}
</G>
<G>
{this.renderVerticalLabels({
{withVerticalLabels
? this.renderVerticalLabels({
...config,
labels,
paddingRight,
paddingTop
})}
})
: null}
</G>
<G>
{this.renderLine({
Expand Down
21 changes: 16 additions & 5 deletions src/stackedbar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ class StackedBarChart extends AbstractChart {
render() {
const paddingTop = 15
const paddingRight = 50
const {width, height, style = {}, data} = this.props
const {
width,
height,
style = {},
data,
withHorizontalLabels = true,
withVerticalLabels = true,
} = this.props
const {borderRadius = 0} = style
const config = {
width,
Expand Down Expand Up @@ -125,23 +132,27 @@ class StackedBarChart extends AbstractChart {
})}
</G>
<G>
{this.renderHorizontalLabels({
{withHorizontalLabels
? this.renderHorizontalLabels({
...config,
count: 4,
data: [0, border],
paddingTop,
paddingRight
})}
})
: null}
</G>
<G>
{this.renderVerticalLabels({
{withVerticalLabels
? this.renderVerticalLabels({
...config,
labels: data.labels,
paddingRight: paddingRight + 28,
stackedBar: true,
paddingTop,
horizontalOffset: barWidth
})}
})
: null}
</G>
<G>
{this.renderBars({
Expand Down