I'm using the Chart component to make a scatter plot and allowing it to auto-size.
I need to find the pixel value of the Chart's height and width for use in an annotation.
However, the publicly available Height and Width parameters are not useful as they just show the percentage.
I found that the Chart has the values within it, but they are not publicly accessible.
Would it be possible to make the "Available Size" parameters as publicly available read-only?
It would save time from having to use JSinterop to get size of the parent div.
Thank you,
Sorin
public void RangeCalculated(AxisRangeCalculatedEventArgs Args)
{
if(!Double.IsNaN(Args.Bounds.X) && !Double.IsNaN(Args.Bounds.Y) && !Double.IsNaN(Args.Bounds.Height) && !Double.IsNaN(Args.Bounds.Width))
{
if(Args.AxisName == "PrimaryYAxis" && Count < 1)
{
Count++;
var Y = Args.Bounds.Y;
var Height = Args.Bounds.Height;
Console.WriteLine(Y);
Console.WriteLine(Height);
}
else if(Args.AxisName == "PrimaryXAxis" && Count < 3)
{
Count++;
var X = Args.Bounds.X;
var Width = Args.Bounds.Width;
Console.WriteLine(X);
Console.WriteLine(Width);
}
}
} |
Hello Durga,
Thank you for your reply.
I tried out the sample code, however I'm facing a problem.
First, the syncfusion package referenced is 19.2.0.56 which seems to not be released yet.
When I changed the version to the current latest version 19.2.0.51, I get the following error:
I assume maybe it will work once 19.2.0.56 is released.
In doing some more investigation I'm running in to some strange behavior.
I tried removing the code within RangeCalculated function to see if it's even trigger at all or not
When I run this I don't see anything in the Console.
But when I set a breakpoint at the Console.WriteLine statement, it catches with no problem, meaning that the even is triggered.
I'm starting to wonder if the event is triggering too early for the application to be loaded.
Hello Durga,
Thank you for the reply.
When I implemented OnAxisRangeCalculated event in my regular code today it seems to work OK, so the problem must have been only with the sample project originally sent.
By the way, there is a minor gap between the two solutions:
(a) Use JSinterop to get chart pixel size
(b) Use OnAxisRangeCalculated
The difference is that (a) provides the pixel size of the chart area plus the axes
while (b) provides the pixel size of the interior only
Actually both information from (a) and (b) is valuable.
But when positioning an annotation by X and Y coordinates, the origin is the larger exterior div, so (b) alone is not enough.
Currently I noticed that the Y-Axis area is constantly 51.5 px and X-Axis area is 47.36 px
So to position correctly, I must take the size received from (b) and add the manually calculated axis area values and hope they stay fixed.
If I had access to the values below, call it (c), then I could calculate the axis size by (c) - (b) and that would be safer
Can syncfusion consider making the "Available Size" object publicly available as GET only?
Thank you!
public void RangeCalculated(AxisRangeCalculatedEventArgs Args)
{
if (Args.AxisName == "PrimaryYAxis" && Count < 1)
{
//…
var Y = Args.Bounds.Y;
var Height = Args.Bounds.Height;
var AvailableHeight = Y + Height;
Console.WriteLine(AvailableHeight);
}
else if (Args.AxisName == "PrimaryXAxis" && Count < 3)
{
//…
var X = Args.Bounds.X;
var Width = Args.Bounds.Width;
var AvailableWidth = X + Width;
Console.WriteLine(AvailableWidth);
}
} |