I’ve got a problem with a chart I’m developing. I’m adding just four points to an XY scatter series – the X values are 0, 1, 5, 10, and the Y values range from approx 3000 up to approx 60000.
We measure chemical elements, and in my app I can change the unit of measure from “parts-per-billion” (ppb) to “parts-per-quadrillion” (ppq), resulting in the X-values changing to 0, 1000000, 5000000, 10000000 (note that the Y-values remain unchanged). Even though there are still only four points, the chart now takes several seconds to render. Any ideas why this might be, and what I can do to improve things?
I have attached my chart XAML in case it is relevant. Note the MajorDelta is being calculated as “largest_X_value / 5” (I would always like to see 5 ticks/labels on the X-axis). The VisibleRange is simply being bound to 0 and the maximum X-value. I’m having a bit of a hard time getting the axis labels/ticks “just so”, hence why I’m resorting to some of these bindings and GrowBy values.
Regards
Andrew
- andyste1 asked 11 years ago
- You must login to post comments
Hi Andy,
We’ve seen a few rare cases where the tick generator gets stuck, outputting thousands of gridlines. We’ve put tests in to catch this but that’s my hunch over what it might be. Can you tell me, what is MajorDelta and MinorDelta in this case? Are you using auto-generation of these properties or manual?
If you don’t spot it, feel free to send over a code sample by email that reproduces the problem.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 11 years ago
-
Hi Thanks for getting back to me. The x-axis MajorDelta is bound to a property in the VM, and is calculated as the largest X-axis value divided by 5, effectively always giving me 5 ticks/labels (or is there a better way to do this?). The MinorDelta is hardcoded as "1" in the XAML. I suspect this is where the problem lies - perhaps it's creating thousands of minor ticks? However I've tried both removing the attribute completely, and binding it to the same property as MajorDelta but I get exceptions in both cases. I originally had DrawMinorTicks="True", and was seeing thousands of minor ticks (there were so many packed together it resulted in a solid block along the x-axis!). I thought the performance problem was caused by their rendering so I set it to "False" but it made no difference. Here's the X-axis XAML in case it didn't come out very well in the forum post:- I've since put AutoTicks back to true and it seems to be producing satisfactory results. I'll see how things go with this. Regards Andrew
-
Hello Andrew, I think what's going on here is - when you set MajorDelta to 1,000,000 and MinorDelta is set to 1, regardless of rendering the chart needs to calculate increments to chart ticks in steps of 1 (these are stored as floating point coordinates in a List
, so you end up calculating and storing millions of floats per re-draw. Likewise if you set MajorDelta to 1,000,000 and MinorDelta to 1,000,000, you will get a divide by zero exception, or the operation will never complete because for each MajorDelta it adds MinorDelta incrementally. Try setting MajorDelta = N and MinorDelta = N/2. This should give you the desired result, without the memory problems! Best regards, Andrew
- You must login to post comments
Please login first to submit.