I was drawing a diagram with XamDataChart which has fixed start time and end time on X axis and value on the Y axis.
In my purpose, one value point will be added into the diagram in every minute. So at beginning, there is a empty diagram, but after several minutes, the ColumnSeries diagram will fill with items.
However, when I was trying to do this, I wondered that the width of each item is so large on the ColumnSeries at the beginning. Only at the end, when the diagram is full of item, the width is as expected.
I attach a demo for you to take a look. You can drag the slider at the buttom of the window to change the number of value point. Once you drag, you will find the less the point is, the larger the width of item is.
Is there any solution to let the item keep it width no matter how many points on the diagram?
I have reproduced this behavior that you are referencing, and this behavior is expected. The width of the columns in the XamDataChart is mainly influenced by the amount of columns that exist in it, and that amount is directly influenced by the number of data items in the bound ItemsSource for your series and your axis.
Currently in the sample project you sent, you are clearing the items in your bound collection and repopulating it based on the number of items represented by your slider. This will change the column width. If you would like to fix the column width, I would recommend that instead of removing the columns from your data source, that you set their value path property to double.NaN. This will cause the column to essentially 'disappear,' but the item will still be there, and the other columns will not resize because of it.
This will likely require a modification of your data source as well, as you will need to know what data value to set the property back to when you slide it back into view. I would recommend defining a separate property that keeps track of this, so that you can set your value back when the slider returns that it should be brought into view.
I have attached a modified version of the sample project you sent to demonstrate the above. I hope it helps you.
Please let me know if you have any other questions or concerns on this matter.
Thank you. It is nice to receive your reply.
I appreciate your patience to explain the problem.
And yes, it is solved my problem. The key is just set the value to double.NaN.
Thank you for your response. I am glad that setting the value member path to double.NaN works for you.