Codename one Bar Chart - codenameone

XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.HORIZONTAL);
setChartSettings(renderer, "Monthly sales in the last 1 years", "Cars", "sold", 0, 5, 0, 100, ColorUtil.GRAY, ColorUtil.LTGRAY);
renderer.setXLabels(1);
renderer.setYLabels(5);
renderer.setBarWidth(40);
renderer.setLabelsTextSize(8.0f);
Label text size is not rendering in Bar Charts?

You are setting the text size to 8 pixels which will make it pretty small and might not work if your fonts aren't native fonts. Try something like this.
renderer.setLabelsTextFont(Font.createTrueTypeFont("native:MainThin", "native:MainThin"));
renderer.setLabelsTextSize(convertToPixels(5));

Related

anychart stock x-axis tick configuration. Change color and interval.

I've been scratching my head and reading the documentation a lot, trying to understand when using anychart stock how i can get control over the tick ( major/minor) display ? i.e i'd like to change the tick stroke color, the interval and make it rotate so text is vertical.
this is example data i'm playing with.
https://playground.anychart.com/sTrncP0D
Nothing special, i just want the major tick per minute and minor every 10 seconds if possible. I tried many variations but fail to get working combination and i think it's because the Stock axis differences.
Can you someone help how this is done ? Or if this is even possible.
thanks.
You can set ticks and minor ticks interval with the following lines:
var scale = chart.xScale();
scale.ticks([{major: {unit: 'minute', count: 1}, minor : {unit:'second', count: 10}}]);
You can rotate axis labels like this:
var labels = chart.plot().xAxis().labels();
minorLabels = chart.scroller().xAxis().minorLabels();
labels.rotation(90);
minorLabels.rotation(90);
You can adjust ticks appearance with the following lines:
var ticks = chart.plot().xAxis().ticks();
var minorTicks = chart.plot().xAxis().minorTicks();
ticks.stroke("red", 0.9);
minorTicks.stroke("blue", 0.9);

Leaflet - get a map that covers the full screen

In leaflet and mapbox I would like to get rid of the two gray bars above and under the map as seen on the picture below. My #map DOM element takes the full screen and the gray bars disappear when I zoom in (e.g., zoomLevel = 3). So the gray bars seem to be caused by the fact that a zoomLevel has a given height (in px) of the tiles which is smaller than my screen.
I want to keep the tiles of the same zoom level but make sure the height of the tiles cover at least the full screen.
Here is my map setup code:
vm.map = L.map('map', {
center: [35, 15],
zoom: 2,
maxZoom: 21,
scrollWheelZoom: true,
maxBounds: [
[89.9, 160.9],
[-89.9, -160.9]
],
zoomControl: false,
noWrap: true,
zoomAnimation: true,
markerZoomAnimation: true,
});
I am using angular and my screen dimensions are 1920 x 1080
Sounds like you need to calculate the minimum zoom level at which the map only shows the area between 85°N and 85°S.
The getBoundsZoom() method of L.Map helps with this, e.g.:
var bounds = L.latLngBounds([[85, 180],[-85, -180]]);
var wantedZoom = map.getBoundsZoom(bounds, true);
var center = bounds.getCenter();
map.setView(center, wantedZoom);
Note that this is a generic solution, and works for any size of the map container.
You could also set the minZoom of the map to that value, and experiment with fractional zoom (see the zoomSnap option). If you want the user to be unable to drag outside the painted area, use the map's maxBounds option with something like [[85, Infinity],[-85, -Infinity]].
(And if you are wondering why 85°N and 85°S, do read https://en.wikipedia.org/wiki/Web_Mercator )

iPhone 6: InteractionDiaog appears too far down; content hidden

I am trying to implement a chat function in a Codename One app, basically using the tutorial example "Building a Chat App with Codename One". Part of this is an InteractionDialog popping up when someone is trying to contact you. This looks fine in the simulator and on my Android unit, but on iPhone 6 the dialog seems to be drawn too far down, resulting in only the title being visible.
This is the program code:
int h = toast.getPreferredH();
int dh = Display.getInstance().getDisplayHeight(); // just for debugging
toast.show(Display.getInstance().getDisplayHeight() - h - 10, 10, 10, 10);
UITimer uit = new UITimer(() -> {
toast.dispose();
});
Toast height, display height:
Simulator: h=221, dh=480
Android: h=359, dh=1674
iPhone 6: h=304, dh=1334 (This one comes too near the bottom)
Is there something wrong with the screen metrics, and what can I do to solve this? I have had some other, similar problems with InteractionDialog placement previously.
I would be happy to show some screenshots, but I can't post that many links yet.
I think the code for the chat app might have been a bit wrong here change this:
int h = toast.getPreferredH();
int dh = Display.getInstance().getDisplayHeight(); // just for debugging
toast.show(Display.getInstance().getDisplayHeight() - h - 10, 10, 10, 10);
To this:
int h = toast.getPreferredH();
int dh = Display.getCurrent().getContentPane().getHeight();
toast.show(dh - h - 10, 10, 10, 10);
The layered pane (where the InteractionDialog resides) is on top of the content pane area only not the entire display height so the title area/statusbar area aren't taken into account.
FYI in the upcoming version we will have the new ToastBar component.

Draw Image to form? (size related issue)

I'm trying to draw a 400x400 px image to a 400x400 form that I made. What I'm doing is:
Graphics.DrawImage Method (Image, 0, 0, 400, 400) 0, 0, 400, 400, ...
But when I run the form, the image seems to stretch slightly upon the y-axis, the x-axis seems to be working correctly.
This was what I was doing before (stretching the old smaller images to fit the size)
... (Image, 0, 0, 264, 231) 0, 0, 400, 400, ...
or something like that. Now that I'm trying to do it the correct way, I can't seem to get it to work properly.
Edit: I wonder if using a simpler verson of Graphics.DrawImage would work? Although I still need to figure out what is wrong with what I'm doing.
Thanks in advance.
If you have a borderless form at 400 x 400, then it should be ok.
If not, then you have to account for the non-client dimensions of the form to reach the size you want.
You can just do this for drawing:
e.Graphics.DrawImage(image, 0, 0)
To set your form size, you can try this:
Me.ClientSize = New Size(400, 400)

How to take screenshot from Panel in mono C#?

How to take all screenshot from Panel in mono C# ?
I need not used winAPI.
My panel can not be fully visible.
Your question is not exactly clear but in case you meant taking a screenshot of the desktop: below is a small example of how you could do this using gtk:
using Gtk;
...
Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (window!=null)
{
Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8,
window.Screen.Width, window.Screen.Height);
pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0,
window.Screen.Width, window.Screen.Height);
pixBuf.ScaleSimple(400, 300, Gdk.InterpType.Bilinear);
pixBuf.Save("screenshot0.jpeg", "jpeg");
}
hope this helps, regards

Resources