roughViz icon indicating copy to clipboard operation
roughViz copied to clipboard

piechart not drawn correctly

Open valendinosaurus opened this issue 6 years ago • 5 comments

When drawing a pie chart, somehow there are areas which are drawn two times, as visible in the screenshot. also, the message popup box on hover is displaced underneath the graph.

b1

valendinosaurus avatar Nov 18 '19 19:11 valendinosaurus

Hi @valendinosaurus, could you provide your code?

jolo-dev avatar Feb 09 '20 22:02 jolo-dev

Hi @jolo-dev

In my service, I create the chart like this

new roughViz.Pie({
	element: element,
	data: data,
	width: width,
	height: height,
	roughness: roughness,
	fillStyle: 'hachure',
	fillWeight: 4,
	innerStrokeWidth: 1,
	simplification: 0.5,
	axisFontSize: '1rem',
	tooltipFontSize: '1rem',
	labelFontSize: '1rem',
	titleFontSize: '1rem',
	axisRoughness: 0.5
});

and my data gets created like following

mapAccountsForRoughViz(accounts: AccountNormalized[]): {} {
	let labels = [];
	let values = [];
	accounts.forEach(a => {
		labels.push(a.name);
		values.push(a.saldo);
	});
	return {labels, values};
}

resulting in this effective data

{
    "labels":
        ["Hauptkonto","Sparkonto"],
    "values":
        [1064.5899999999701,3497.4500000000007]
}

I also tried to round the numbers with Math.round() resulting in

{
    "labels":
        ["Hauptkonto","Sparkonto"],
    "values":
        [1065,3497]
} 

but the result is the same. I have another chart at a different place with more than two elements, there I never saw this behaviour. Funny enough, from time to time the chart with only two elements gets drawin correctly, but I couldn't reproduce the behaviour.

I suspect it has something to do with having only two elements, if I alter my function mapAccountsForRoughViz that it pushes everything twice (resulting in 4 elements), the chart gets drawn correctly.

valendinosaurus avatar Feb 12 '20 19:02 valendinosaurus

Oh yes, you're right. With two elements there is "weird" behavior. I have tested that in the example: https://blockbuilder.org/jwilber/d117e0b0864a161bec2d914013ed69da

Let me check what I can do.

jolo-dev avatar Feb 12 '20 22:02 jolo-dev

Hi @jolo-dev, just wondering if you have any updates on this or any suggestions/direction for me to try and resolve it if I can?

vcheeze avatar Jul 04 '21 16:07 vcheeze

Hi @vcheeze,

Sorry, totally forgot about this. I would love your contribution :)

jolo-dev avatar Jul 04 '21 18:07 jolo-dev