You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I am doing it by running an algorithm over my data, which is fine but given it is already determined when the graph is rendered, it would be good if that information is provided to you.
I am using this information to calculate the appropriate UnitWidth.
Is there a way to find out the displayed/Chart pixels as well. My unit width calculation is currently using the following code that I would like to improve, as it estimates the chart pixel width.
`
private void UpdateUnitWidth()
{
double? min = XAxis.MinLimit;
if (min == null)
{
List<double> mins = VM.GetXMin();
if (mins.Count > 0) min = mins.Min();
}
double? max = XAxis.MaxLimit;
if (max == null)
{
List<double> maxs = VM.GetXMax();
if (maxs.Count > 0) max = maxs.Max();
}
if (min != null && max != null && min != max) {
var pixelWidth = this.ActualWidth;
if (pixelWidth > 0)
{
double dataWidth = (double)max - (double)min;
double approxUnitsPerPixel = dataWidth / (pixelWidth - 70); // 70 approximate account for padding, axisy etc
if (approxUnitsPerPixel < 1) XAxis.UnitWidth = 1;
else XAxis.UnitWidth = approxUnitsPerPixel * 8;
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently I am doing it by running an algorithm over my data, which is fine but given it is already determined when the graph is rendered, it would be good if that information is provided to you.
I am using this information to calculate the appropriate UnitWidth.
Is there a way to find out the displayed/Chart pixels as well. My unit width calculation is currently using the following code that I would like to improve, as it estimates the chart pixel width.
`
`
Beta Was this translation helpful? Give feedback.
All reactions