You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2022/06/29 02:26:23 UTC

[GitHub] [echarts] pissang commented on a diff in pull request #17275: 优化饼图性能

pissang commented on code in PR #17275:
URL: https://github.com/apache/echarts/pull/17275#discussion_r909141890


##########
src/util/number.ts:
##########
@@ -279,6 +279,63 @@ export function getPercentWithPrecision(valueList: number[], idx: number, precis
     return seats[idx] / digits;
 }
 
+/**
+ * Get a data of given precision, assuring the sum of percentages
+ * in valueList is 1.
+ * The largest remainer method is used.
+ * https://en.wikipedia.org/wiki/Largest_remainder_method
+ *
+ * @param valueList a list of all data
+ * @param precision integer number showing digits of precision
+ * @return {Array<number>} percent ranging from 0 to 100
+ */
+export function getPercentSeats(valueList: number[], precision: number): number[] {

Review Comment:
   Seems getPercentSeats shares lots of logic with getPercentWithPrecision. Could we reuse these code?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org