polar.js 809 B

123456789101112131415161718192021222324
  1. export const getPolarOptions = (options = {}) => {
  2. const defaultOptions = {
  3. startAngle: -Math.PI / 2,
  4. endAngle: (Math.PI * 3) / 2,
  5. innerRadius: 0,
  6. outerRadius: 1,
  7. };
  8. return Object.assign(Object.assign({}, defaultOptions), options);
  9. };
  10. /**
  11. * Polar transformation for circular charts using center of canvas as origin.
  12. * @todo Adjust size of canvas by startAngle and endAngle to make chart as big as possible.
  13. */
  14. export const Polar = (options) => {
  15. const { startAngle, endAngle, innerRadius, outerRadius } = getPolarOptions(options);
  16. return [
  17. ['translate', 0, 0.5],
  18. ['reflect.y'],
  19. ['translate', 0, -0.5],
  20. ['polar', startAngle, endAngle, innerRadius, outerRadius],
  21. ];
  22. };
  23. Polar.props = {};
  24. //# sourceMappingURL=polar.js.map