This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I got a problem when using histogram chart. In my project, the x axis’s value is logarithmic. When I change the x value range from ‘0.1-1000’ to ‘0.1-10000’, each histogram changed so wide that multiple histograms overlap. Please see the attachment, if you click the button’ Change coordinates’, you can reproduce the problem. How to set parameters to fix the width of the histogram or change it in a suitable range? That is, the width of histogram can’t be too wide, either too narrow. |
|
|
Hi Jianya, Thanks for sending the repro project. By default, the BarSeries will try to automatically calculate an appropriate width for the bars. This is partly done by finding the smallest distance between adjacent X plot positions. In your second set of data, two of your data points are exactly the same (125.995270117737). This causes the minimum distance between adjacent bars to be 0. When this happens, the bars are given a default width that generally won't be good when using a logarithmic axis. If this double up of the X value is changed, then the resulting chart will look better - a lot like the first set of data. Is this double up of X values intentional? (I ask this because bar charts usually don't have multiple bars plot against the same X value). If this is what you need, please let me know and I'll see if we can adjust our logic to support this scenario. -Jason Fauchelle |
|
|
Hi Jason Fauchelle, In the sample “TestLogarithmicAxis.zip”, the _listxNew array has an error data "125.995270117737", this causes the bars are given a default width. Now we update the data, and have not the same data points in the _listxNew array. However, The width of the bars are very fine, as our project as appears the same problem. You can click the button "Change coordinates" in sample “TestLogarithmicAxis2.zip”. How to set parameters to fix the width of the histogram or change it in a suitable range? |
|
|
Hello, Thanks for sending the updated repro project. As mentioned previously, the width of the bars will be calculated by default based on the smallest distance between adjacent data points. Your new data set now has a couple of data points that are very close together, and so that small distance is selected as the bar width which then causes all bars to appear as a thin line. Fortunately, you can override this default automatic width logic by setting the LogicalBarSize property of the BarSeries. The best way to describe the use of this property for a logarithmic axis is that the width of the bars will be the logicalBarSize value multiplied by the distance between major tick marks on the axis. So for your demo, if you set the LogicalBarSize of the BarSeries to 0.1, then the width of the bars will be one tenth of the distance between the major tick marks. (Feel free to play around with this value to find the best width for your app). If your data is expected to change a lot, you may need to write a function that analyses the data to calculate an appropriate bar width. (That is what the BarSeries tries to do, but it is tricky when very close data points exist, so you may need to include logic to filter this out specific to your app). Note that by setting the LogicalBarSize (and thus overriding the default width calculation) in your scenario will cause a couple of the bars to overlap. As mentioned above, a couple of your data points are very close together which is why the default calculation causes thin bars. By specifying a larger width, the very close bars will overlap each other due to the increased width. Hope that helps! Please let me know if you have further questions about this. -Jason Fauchelle |
|