Skip to content

Commit

Permalink
Merge pull request #27 from prithsharma/animation_support
Browse files Browse the repository at this point in the history
Support for animations while rendering,thanks
  • Loading branch information
hongyin163 authored Sep 1, 2016
2 parents e5057c0 + f71d38f commit e9724ca
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ public void setData(BarChart chart,ReadableMap rm){

}
chart.setData(barData);
chart.invalidate();

/**
* Graph animation configurations
* If no animation config provided, call chart.invalidate()
* animation configs are maps with the following keys
* - duration or durationX/durationY in case of animateXY
* - support for easeFunction yet to be given
*/
if (rm.hasKey("animateX")) {
chart.animateX(rm.getMap("animateX").getInt("duration"));
} else if (rm.hasKey("animateY")) {
chart.animateY(rm.getMap("animateY").getInt("duration"));
} else if (rm.hasKey("animateXY")) {
ReadableMap animationConfig = rm.getMap("animateXY");
chart.animateXY(
animationConfig.getInt("durationX"),
animationConfig.getInt("durationY")
);
} else {
chart.invalidate();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ public void setData(LineChart chart,ReadableMap rm){
chartData.addDataSet(dataSet);
}
chart.setData(chartData);
chart.invalidate();

/**
* Graph animation configurations
* If no animation config provided, call chart.invalidate()
* animation configs are maps with the following keys
* - duration or durationX/durationY in case of animateXY
* - support for easeFunction yet to be given
*/
if (rm.hasKey("animateX")) {
chart.animateX(rm.getMap("animateX").getInt("duration"));
} else if (rm.hasKey("animateY")) {
chart.animateY(rm.getMap("animateY").getInt("duration"));
} else if (rm.hasKey("animateXY")) {
ReadableMap animationConfig = rm.getMap("animateXY");
chart.animateXY(
animationConfig.getInt("durationX"),
animationConfig.getInt("durationY")
);
} else {
chart.invalidate();
}
}
}

0 comments on commit e9724ca

Please sign in to comment.