Is there a way to limit the max size of a chart in chartjs whilst still maintaining responsiveness? - chart.js

I made a responsive doughnut in chartjs. On mobile devices the size fills out the screen nicely and is as I'd like it but when I switch to desktop it also fills out the entire screen and is too big for my liking. Is there a way to set the relative size to for example, half screen when viewing on desktop and then reverting to full-screen if being viewed on mobile?
I tried the different settings on the chartjs site but can't find anything helpful.

Related

Windows GUI in C++ x,y-plot for Air Traffic Control

I've created a C++ program that gathers data airplane data (ID,x,y,z,heading,velocity) every 5s for about 250 airplanes. Now i want to plot these in a Windows app to create a x,y top view, eventually a bit similar to the attached picture.ATC Pciture
Basic features should be:
plot multiple items (eg small squares) at different x,y-coordinates
a label at each item with eg z, ID
Resize window without scaling the view
Ability to zoom in/out with mousewheel
Eventually i wanna add x,y-coordinates of the position of the current mouse tip, show a trail with history of selected planes, heading vectors, distance between planes, menus for various config options etc. But as I'm totally fresh to Windows GUI programming, i'm just able to create my "hello world" windows app. But now I am stuck at even creating a simple window with an area to plot a single small circle at a given x,y-coordinate. I've been looking into Direct2D but also read about MFC, Qt, gnuplot, etcetc.
So is there a Direct2D set of commands/library to do the above? An example or tutorial of an x,y-scatterplot could be a great starter as well.

Mobile Embedded PowerBI not resizing (height) as expected when switching between landscape and portrait

When embedding a PowerBI report into a mobile app, switching the view from portrait to landscape results in an excess of grey space appearing below the report that wasn't there when the report initially loaded in portrait view. Switching back and forth between landscape and portrait does not restore the original/appropriate height inside the iframe it seems.
The report is loaded with the following configuration:
{
type: 'report',
embedUrl: 'https://app.powerbi.com/reportEmbed',
layoutType: models.LayoutType.Custom,
customLayout: {
displayOption: models.DisplayOption.FitToPage
}
...
}
I would have expected the report to maintain the amount of space in the iframe needed to display report content and not have excess grey space remain/present. This seems like something that is being handled inside reportEmbed.*.js. Any assistance would be greatly appreciated.
The scrollbar in the image gives a relative idea of how far down we are in the iframe.
UPDATE (19/07/18): This was tested on an iPhone running iOS 9.3.
FitToPage option maintains the proportions of the page, and might still have gray shoulders remaining for iframes that don't hold the same ratio for height & width.
however, recent feature allows you to make the gray shoulders disappear:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Transparent-Background

How to make google chart API responsive?

I am creating two charts Line Chart and Donut Chart on same HTML Page using Google JS API. But these charts are not responsive. How can I make those charts as responsive?
The Google Charts API was probably not designed with responsiveness in mind, specifically. The default size of the chart is to fill the element it's being rendered into, so you can just use CSS and Media Queries like you would normally do to make a responsive design.
The only real problem is that once the chart is drawn, it doesn't change it's size in a desktop window resize-type scenario. In Angular Google Chart we listen for the window's resize event and redraw the chart.
I've seen some of the resize strategy paired with a bit of JavaScript to keep the chart the same aspect ratio no matter how wide it is.
Anything more specific will need a more detailed question. I am intentionally not including any code for this answer, because whatever I write will probably be wrong for your situation.

What size of ImageList icons do I need to make & load for my app (considering higher DPI)?

I have a CListCtrl control (or a ListView in Win32) that is created with LVS_REPORT style.
I am intending to display icons in its items as such:
But the question is what size of icons do I need to make and load?
Let me explain. From the old Win32 samples, I can see that everyone creates image lists with 15x15 pixel icons. But the issue with those is that it looks horribly pixelated on any modern PC with higher DPI settings. Thus I was looking for a dynamic way to determine the appropriate size of image lists for the CListCtrl.
And also the first part of the question, what icon size should I make originally?
EDIT
PS: Since DPI scaling came up, how do you find it out? I'm currently using the following approach:
//No error handling for brevity
HDC hDC = ::GetDC(hAppsMainWindowHandle);
int nCx = ::GetDeviceCaps(hDC, LOGPIXELSX);
int nCy = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hAppsMainWindowHandle, hDC);
//I technically get horizontal & vertical scaling --
//can those be different?
double scalingCx = (double)nCx / 96.0; //1.0 = 100%
double scalingCy = (double)nCy / 96.0;
Is font scaling something different?
A list view uses a "small" or "large" image list depending on its mode. In report mode, it uses the "small" image list. You can use GetSystemMetrics() to get the dimensions of "small" images using the SM_CXSMICON and SM_CYSMICON metrics (use SM_CXICON and SM_CYICON for "large" images).
Note that the returned values will be virtual/scaled if your app is not DPI-aware, so to get accurate values, make sure it is DPI-aware via SetProcessDPIAware(), SetProcessDpiAwareness(), or a DPI manifest.
Update: I just ran across this function, might be useful for you when writing a DPI-aware app:
LoadIconWithScaleDown()
Make larger images and let the API scale them down to smaller sizes.
The report style list view wants small icons, that is icons with SM_CXSMICON by SM_CYSMICON metrics. Assuming your app is high DPI aware, then the actual value of these metrics depends on the user's chosen font scaling or DPI setting. So up front you cannot know what size icons should be used. You have to query the system metrics at runtime, and use appropriately sized icons.
Now, what size icons you include in your executable depend on what DPI settings you wish to support. Back in XP days you could reasonably expect to encounter 100% and 125% font scaling. These days, high density display panels are common and you really need to support larger ratios. At least 150% and 200%, and quite probably 175%.
The closest I can find to guidelines is in this MSDN article: http://msdn.microsoft.com/en-US/library/windows/desktop/dn742485.aspx
This article was written around the Vista time frame and already shows its age. I think you have to use these articles as a guide and adapt to the hardware of the day.
You will also find that people run their machines at font scaling values in between the round numbers listed above, and in the article I link to. One of my colleagues runs at 120%. Interestingly this has highlighted various bugs in our code so it's always useful to have someone dog-fooding your program.
When you build your image lists at runtime, size them according to system metrics. And try to avoid scaling icons. For instance, if system metrics suggest an 18px icons, and you only have 16px and 20px icons, then make a new 18px icons. Fill the image with transparent pixels, and blit the 16px icon into the middle of this 18px image. Make the icon out of that. This approach will avoid aliasing problems.

2 actionbar tabs don't fill a screen width on FULLHD (xxhdpi) Android device

I have required styles (from designer) applied on my TABs used in Actionbar for navigation and I use Actionbar Sherlock. They look perfectly from ldpi to xhdpi devices, but situation changes on xxhdpi devices.
I have only 2tabs and except mentioned styling, I have the same code as Sherlock DEMO app in "Tab Navigation". I found 2 older simmilar questions not answered yet.
Stacked ActionBar tab bar not filling parent
(I've got a simmilar problem, centered tabs. Sorry for inconvenience, I can't attach images because of rep points.)
and
action bar tabs not fill screen in android
Since the time of their posts, this is not only the issue of tablets, but now, there are many FULLHD (flagship) smartphones and this is becomming the big "design" issue.
I want my 2tabs to fill/match the full width of ANY device size, so in my case to fill 50% width each. Default Holo styled tabs doesn't look that bad (as shown in previous link), but my styled tabs on this big screen look much worse.
PS: Situation doesn't change if I make a text in tabs bigger or longer. Tabs don't adujst their width, instead they change their height and text takes 2 lines.
Unfortunatelly, this is a another JB changes:
https://android.googlesource.com/platform/frameworks/base/+/b8139af3dcae80c0030afd0354dc424a7c72c3d9
One of solution: set target SDK 15 or lower.