Closed jcubic closed 4 years ago
@jcubic I think you should add whitespace(' ') to single character when you want to render pie chart. Check the demo code: https://github.com/chunqiuyiyu/ervy/blob/master/demo/index.js#L23
The first is working but the second is still broken:
Because the ASCII characters are "rough", sometimes the size of each area cannot be calculated correctly. You must manually add a property: gapChar, for example:
const pieData = [
{ key: 'A', value: 10, style: bg('green', 2) },
{ key: 'B', value: 20, style: '$$' },
{ key: 'C', value: 30, style: bg('red', 2) },
{ key: 'D', value: 10, style: bg('blue', 2) }
]
console.log(pie(pieData, { gapChar: bg('blue', 2) }))
Result:
For automatic processing programs, pie charts sometimes do not display correctly if there are too many blocks inside( your example above).
How do you know that gap need to be blue without looking the output?
No way to know that before the output. My suggestion is not to deal with this situation.
So you say, that it randomly create wrong results and to fix the issue, just don't create data that will create this random results?
This is definitely a bug in the library, that should handle edge cased and produce valid results, or if not it's of no use. You never know if pie chart will be correct.
You are right, I have fixed it in version 1.0.5. Now, gapChar would be the style of last value in renderer data.
But which entry need this, I can add option, it's no difference if I need to guess which item need this gap. This is just not consistent API. it give random values.
You don't need to guess it, now Ervy will auto generate the gapChar.
I've updated to 1.0.5 and it still, broken, no auto generate:
How do you update the Ervy? My test for this error is passed.
I think I did, I've updated the npm package generated the file using browserfiy but it's hard to tell because you don't provide UMD so you can't use https://unpkg.com/ and you don't have version string in your code. So the file can be any version.
How to create pie correct chart with this data, can you provide the code? Do you need to pun anywhere gapChar
? To be sure I've just installed gain the library and generated new file, it's the same. Are you sure that you've commited the changes it look like the diff commit is almost no different the previous code, it only get gapChar from options, there are no any auto generation.
Check this newest commit:https://github.com/chunqiuyiyu/ervy/commit/b7d1bfd197d8ae419051111accf676ebf0131ce1, I remove gapChar from options, and generate it from styles.
Sorry, I've build the file in wrong way, the pie chart is working also my demo show correct piechart.
You should update demo file since it's only documentation right now, it still have gapChar as option.
Check my demo: https://codepen.io/jcubic/pen/gObPBdP?editors=0010
commands:
it renders half of the circle
and this one is komplety broken:
The code just pass the data to
ervy.pie
.