To display map scale

Not familiar with licensing? Need help in installing LightningChart Ultimate SDK? User's manual is missing? Post general questions here.

Moderator: Arction_LasseP

Post Reply
hwjeong
Posts: 3
Joined: Thu Nov 14, 2019 12:16 am

To display map scale

Post by hwjeong » Fri Nov 15, 2019 12:12 am

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.

ArctionKestutis
Posts: 369
Joined: Mon Mar 14, 2016 9:22 am

Re: To display map scale

Post by ArctionKestutis » Mon Nov 18, 2019 2:08 pm

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.

hwjeong
Posts: 3
Joined: Thu Nov 14, 2019 12:16 am

Re: To display map scale

Post by hwjeong » Tue Nov 19, 2019 9:05 am

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.
* The attached image shows a different scale when at the same level. The red symbol and the yellow line measure the distance on the chart for comparison. The lower right white bar is a calculation of width using the chart's current latitude, longitude size, the actual size of the chart (in pixels), and zoom level.
Thank you.
Attachments
mapscale.png
mapscale.png (8.44 KiB) Viewed 730 times

Arction_LasseP
Posts: 58
Joined: Wed Mar 27, 2019 1:05 pm

Re: To display map scale

Post by Arction_LasseP » Wed Nov 20, 2019 7:52 am

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 722 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

hwjeong
Posts: 3
Joined: Thu Nov 14, 2019 12:16 am

Re: To display map scale

Post by hwjeong » Mon Nov 25, 2019 4:40 am

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?

Arction_LasseP
Posts: 58
Joined: Wed Mar 27, 2019 1:05 pm

Re: To display map scale

Post by Arction_LasseP » Tue Nov 26, 2019 9:52 am

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

Post Reply