Page 1 of 1

To display map scale

Posted: Fri Nov 15, 2019 12:12 am
by hwjeong
Hi.
I'm using a map using ViewXY.Maps. The file uses WorldHigh.md I want to
mark the scale. I'm using my own calculations to scale but sometimes I'm
not accurate. There are two possible causes. One is that the value obtained
by GetZoomLevel() ranges from 5 to 11 and the level is no longer lowered as
it continues to expand. The second is that even the same ZoomLevel has
different distance calculations for each magnification. Please let me know
if there is a scale API provided by your company. Thank you.

Re: To display map scale

Posted: Mon Nov 18, 2019 2:08 pm
by ArctionKestutis
Sorry for the delayed answer.
Could you give visual representation of your question.
My current understanding is based on assumption that want some scale-bar on the map. Is it true? There is some problem with 'scale' on the Earth's map. See for example this Wiki article.

Re: To display map scale

Posted: Tue Nov 19, 2019 9:05 am
by hwjeong
There are already calculations, but sometimes they are not valid. So I wonder if there is any map scale function supported by Lightning Chart. If you don't have it I'll try to change the calculation again.
Thank you.

Re: To display map scale

Posted: Wed Nov 20, 2019 7:52 am
by Arction_LasseP
Hello,

We do have MiniScale -feature, which shows a kind of miniature X -and Y-axis, giving a quick visual overview of data magnitude. MiniScale is fully configurable (color, size, position) and it automatically resizes when the chart is zoomed. You could check if that is suitable for your application.

Here is an example of setting a MiniScale. The result of the code is also seen below.

Code: Select all

// Configuring a MiniScale
chart.ViewXY.YAxes[0].MiniScale.Visible = true;
chart.ViewXY.YAxes[0].MiniScale.VerticalAlign = AlignmentVertical.Bottom;
chart.ViewXY.YAxes[0].MiniScale.Offset.SetValues(-10, -30);
chart.ViewXY.YAxes[0].MiniScale.PreferredSize = new Size(10, 30);
chart.ViewXY.XAxes[0].Units.Text = "s";
chart.ViewXY.YAxes[0].Units.Text = "µV";

MiniScale.PNG
MiniScale.PNG (15.61 KiB) Viewed 18741 times
Note that you don't have to show both X- and Y-axis in the MiniScale. Use ShowX and ShowY -properties for this.

Code: Select all

_chart.ViewXY.YAxes[0].MiniScale.ShowY = false;
Hope this is helpful.
Best regards,
Lasse

Re: To display map scale

Posted: Mon Nov 25, 2019 4:40 am
by hwjeong
Oh, this is exactly what I was looking for. Thank you very much. :D I just tested it and it works very well. But I have one more question. It's an X-axis longitude, so MiniScale is showing the longitude. I want to display distance converts to the value that this value. Is it possible?

Re: To display map scale

Posted: Tue Nov 26, 2019 9:52 am
by Arction_LasseP
Hello,

We are not quite sure what exactly you mean here by converting to the value. If you want the MiniScale labels to show different (converted) values, it will be somewhat tricky as the numbers cannot be modified, only the unit texts. Of course, you can display the converted values in these texts inside parenthesis for example.

_chart.ViewXY.YAxes[0].Units.Text = "(" + value + ")";

An alternative would be to hide the actual labels and use annotations instead. In this case the annotations have to be positioned near the MiniScale based on screen coordinates.

Code: Select all

_chart.ViewXY.YAxes[0].MiniScale.LabelX.Visible = false;

AnnotationXY anno = new AnnotationXY(_chart.ViewXY, _chart.ViewXY.XAxes[0], axisY);
anno.Style = AnnotationStyle.Rectangle;
anno.Shadow.Visible = false; // Disable all fills so only the text is shown
anno.Fill.Style = RectFillStyle.None;
anno.BorderVisible = false;
anno.ClipInsideGraph = false;
anno.TextStyle.Color = Colors.White;
anno.TextStyle.Font.Size = 16;
anno.Text = convertedValue;

anno.LocationCoordinateSystem = CoordinateSystem.ScreenCoordinates;
anno.LocationScreenCoords.SetValues(xCoordinate, yCoordinate);

_chart.ViewXY.Annotations.Add(anno);
Best regards,
Lasse