Print entire page with graph using CTRL+P - anychart

I'm trying to print the entire page with graph using CTRL + P, but the graph is always cropped.
I tried to limit the width of the graph using CSS media = "print", but it seems to have no effect on the graph.
print.css
figure{
width: 100% !important;
/* width: 300px !important; //also does not work */
}
If I try to change the size of the graph in CSS media = "screen", the graph will immediately shrink / enlarge.
I know there is a function chart.print(); But it only prints the graph. I need to print the entire page, including the graph. I tried it in Chrome 73. Anychart 8.5.1

Related

Tizen native wearable - how to add text label auto line break?

I want to show a full line of long text in a label. But when it is small in character numbers It can show it in full. But when the character number grows it shows some part of the texts. Even if I add size to it. It can show line break with html formats but I will perform character operation with network calls, so instead of checking individual characters or keeping track of numbers it will be better if it can add auto line break at the end of screen and show all the texts on screen.
Here's code for label:
ad->label = elm_label_add(ad->conform);
elm_object_text_set(ad->label, "<align=center>Hello Tizen , line is cut offfffffffffffff.</align>");
//elm_object_text_set(ad->label, "<align=center>Hello Tizen <br>testing br</align>");
evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//elm_object_content_set(ad->conform, ad->label);
evas_object_move(ad->label, 20, 100);
evas_object_resize(ad->label, 300, 300);
evas_object_show(ad->label);
How to add auto line break?
Try using elm_label_line_wrap_set API.
elm_label_line_wrap_set(ad->label, ELM_WRAP_MIXED);
See the API reference below.
void elm_label_line_wrap_set ( Elm_Label *obj,
Elm_Wrap_Type wrap
)
Control the wrapping behavior of the label.
By default no wrapping is done. Possible values for wrap are: ELM_WRAP_NONE - No wrapping ELM_WRAP_CHAR - wrap between characters ELM_WRAP_WORD - wrap between words ELM_WRAP_MIXED - Word wrap, and if that fails, char wrap
https://docs.tizen.org/iot/api/5.0/tizen-iot-headed/group__Elm__Label.html#ga60a1dad4d49a3aea31ced12e30d0b815

How to get unlimited height for stage in Konva and compability issue with IE / Firefox

For my project I need to generate a konva page with a lot of nodes. User have to able to add new node and remove it. So far our productive data has around 8000 nodes. I work with angularJS and Konva. The pages must be work in Chrome, IE and Firefox. The codes look like this (modified because of company policy):
angular.module('testModule').controller('compabilityTestCtrl', [
function () {
var compabilityTestCtrl = this;
compabilityTestCtrl.stage = new Konva.Stage({
container: angular.element('<div>')[0],
width: 800,
height: 0
});
var layer = new Konva.Layer({});
var rect = new Konva.Rect({
x: 50,
y: 25,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4
});
layer.add(rect);
compabilityTestCtrl.stage.height(rect.attrs.y + 50);
for (var i = 1; i < 436; i++) {
var newRect = rect.clone({
y: rect.attrs.y + (i * 75)
});
layer.add(newRect);
compabilityTestCtrl.stage.height(newRect.attrs.y + 75);
if (i == 435) {
console.log("Stage height is: " + compabilityTestCtrl.stage.getHeight());
}
}
compabilityTestCtrl.stage.add(layer);
angular.element('#compabilityTestKonva').append(compabilityTestCtrl.stage.content);
}]);
The problem is following:
1. As you can see, it can generate a node until a stage height of 32725px. If I add one more node (for-Loop to 437), the page will dissapeared (in Chrome). It can only generate until 436 nodes.
2. In Firefox, for 436 nodes the page is not totally generated. It just show 3/4 part of them. If I switched to safe-mode, it showed all of them. More than 436 nodes, it also dissapeared like in Chrome.
3. In IE, it just showed 1/4 of all nodes.
Questions:
Why I can not display all the pages in Firefox and IE?
Why the pages dissapeared if the stage getting bigger (in all browser), in this case.. more than 32725 px? Has Konva a limited height of stage?
I would be very happy for your suggestions.
I just wrote a fiddle, so you know what is actually the problem I have.
JSFiddle
In fiddle, it can generate up to 430 nodes (in Chrome), more than that I see only a blank page. In Firefox it ended on 353 nodes, and in IE it ended on 108 nodes.
The canvas element is like an image.
32725px height is super-duper huge. It will use a lot of resources.
Try to make a stage as small as possible. It will be better to make it not bigger than screen size. You can add some type of scrolling into the stage so users can see all objects.

best way in linux to display gif gif87a image from C

What would be the best way, in linux from gnu C and not C++, to display a gif87a file on screen and redisplay it in the same location on the screen so the user can observe changes that are made on the fly to the dataset? This is not an animated gif.
in some old code (fortran77) that has a C wrapper which takes an image that was displayed on the screen and writes it to a gif file, there is a comment about X Window Applications Programming, Ed. 2, Johnson & Reichard that was used as a reference to write the C code to display image data to the screen and write a gif87a file, and this code was written around 1995, the onscreen display of the image no longer works (just a black window) but the creation of the gif file still works. What i would like to do is from the existing C code, in SLES version 11.4 with the libraries that are available to open the gif file and display it on screen. The image, or contour plot, has a color bar that the user sets the min/max value for to display the image to their liking and it would be preferable to make it as easy & efficient for the user to adjust those min max values then redraw the image (re-write the gif then redisplay on screen in same location). There's also a handful of other knobs that the user can turn, such as windowing of the dat (hamming or han) and it would be best if the user can quickly/easily run though about 5+ ways of looking at the image before settling on what is considered correct then using that final gif that was created in powerpoint, excel, etc.
Writing an X11 application is non-trivial. You can display a GIF (or any one of around 200 image formats) using ImageMagick which is included in most Linux distros and is available for macOS. Windows doesn't count.
So, you can create images and manipulate images from the command line, or in C if you want. So, let's create a GIF that is 1024x768 and full of random colours:
convert -size 1024x768 xc:blue +noise random -pointsize 72 -gravity center -annotate 0 "10" image.gif
Now we can display it, using ImageMagick's display program:
display image.gif &
Now we can get its X11 "window-id" with:
xprop -root
...
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x600011
...
...
Now you can change the image, however you like with filters and blurs and morphology and thresholds and convolutions:
convert image.gif -threshold 80% -morphology erode diamond -blur 0x3 -convolve "3x3: -1,0,1, -2,0,2, -1,0,1" ... image.gif
And then tell the display program to redraw the window with:
display -window 0x600011 image.gif
Here is a little script that generates images with a new number in the middle of each frame and updates the screen:
for ((t=0;t<100;t++)) ; do
convert -size 640x480 xc:blue +noise random -pointsize 72 -fill white -gravity center -annotate 0 "$t" image.gif
display -window 0x600011 image.gif
done
Now all you need to do is find a little Python or Tcl/Tk library that draws some knobs and dials, reads their positions and changes the image accordingly and tells the screen to redraw.
As a result of the lack of enthusiasm for my other answer, I thought I'd have another attempt. I had a quick look and learn of Processing which is a very simple language, very similar to C but much easier to program.
Here is a screen shot of it loading a GIF and displaying a couple of twiddly knobs - one of which I attached to do a threshold on the image.
Here's the code - it is not the prettiest in the world because it is my first ever code in Processing but you should be able to see what it is doing and adapt to your needs:
import controlP5.*;
ControlP5 cp5;
int myColorBackground = color(0,0,0);
int knobValue = 100;
float threshold=128;
Knob myKnobA;
Knob myKnobB;
PImage src,dst; // Declare a variable of type PImage
void setup() {
size(800,900);
// Make a new instance of a PImage by loading an image file
src = loadImage("image.gif");
// The destination image is created as a blank image the same size as the source.
dst = createImage(src.width, src.height, RGB);
smooth();
noStroke();
cp5 = new ControlP5(this);
myKnobA = cp5.addKnob("some knob")
.setRange(0,255)
.setValue(50)
.setPosition(130,650)
.setRadius(100)
.setDragDirection(Knob.VERTICAL)
;
myKnobB = cp5.addKnob("threshold")
.setRange(0,255)
.setValue(220)
.setPosition(460,650)
.setRadius(100)
.setNumberOfTickMarks(10)
.setTickMarkLength(4)
.snapToTickMarks(true)
.setColorForeground(color(255))
.setColorBackground(color(0, 160, 100))
.setColorActive(color(255,255,0))
.setDragDirection(Knob.HORIZONTAL)
;
}
void draw() {
background(0);
src.loadPixels();
dst.loadPixels();
for (int x = 0; x < src.width; x++) {
for (int y = 0; y < src.height; y++ ) {
int loc = x + y*src.width;
// Test the brightness against the threshold
if (brightness(src.pixels[loc]) > threshold) {
dst.pixels[loc] = color(255); // White
} else {
dst.pixels[loc] = color(0); // Black
}
}
}
// We changed the pixels in destination
dst.updatePixels();
// Display the destination
image(dst,100,80);
}
void knob(int theValue) {
threshold = color(theValue);
println("a knob event. setting background to "+theValue);
}
void keyPressed() {
switch(key) {
case('1'):myKnobA.setValue(180);break;
case('2'):myKnobB.setConstrained(false).hideTickMarks().snapToTickMarks(false);break;
case('3'):myKnobA.shuffle();myKnobB.shuffle();break;
}
}
Here are some links I used - image processing, P5 library of widgets and knobs.

How to control/scale image size in Codename One?

I used the (new) GUI Builder and inserted an image (by way of adding a Label). However, it appears too big. Is there anyway I can scale and control the size? (I saw something which points to cloudinary but that seems too complicated. I just want to simply scale down the image.)
There are several ways to resize images in Codename One and I will mention few below:
1.
Use MultiImages in the GUI Builder. With this multiple sizes of images are generated from one image based on the sizes you specified. In your GUI Builder, Click Images -> Add Multi Images -> Select your image -> Check Preserve Aspect Ratio -> Increase the % that represents the percentage of the screen width you want the image to occupy. Set any DPI you don't require to 0.
2.
Use ScaledImageLabel or ScaledImageButton, it will resize the image the fill available space the component is occupying.
3.
Scale the image itself in code (This is not efficient, though):
public static Image getImageFromTheme(String name) {
try {
Resources resFile = Resources.openLayered("/theme");
Image image = resFile.getImage(name);
return image;
} catch (IOException ioe) {
//Log.p("Image " + name + " not found: " + ioe);
}
return null;
}
Image resizedImage = getImageFromTheme("myImage").scaledWidth(Math.round(Display.getInstance().getDisplayWidth() / 10)); //change value as necessary
4.
Mutate the image (Create an image from another image).

GAE images.resize with fixed proportional crop

I need to resize and crop to exactly 60x80px from various size and
aspect ratio. Just before i put into Datastore. Anyone already got
this issue resolved.
Currently i already succed to just transform it to exact height (80px)
with various width which nott look so good when i try to display it on
a list. e.g jcaroussel.
My db.put code is like bellow:
if users.get_current_user():
personal.personal_id = int(self.request.get('personal_id'))
personal.name = self.request.get('name')
personal.latitude = self.request.get('latitude')
personal.info = self.request.get('info')
photo = images.resize(self.request.get('img'), 0, 80)
personal.photo = db.Blob(photo)
personal.lc_id = int(self.request.get('lc_id'))
personal.put()
self.redirect('/admin/personal')
else:
self.response.out.write('I\'m sorry, you don\'t have permission to add this LP Personal Data.')
I just want to do similar result when we upload our avatar on google
talk/google chat.
Anyone solved this?
Thx
After your resize your image down to 80 pixels in height, you would have to use the crop function as defined here. For example:
img = images.Image(self.request.get('img'))
img.resize(0, 80)
resized_img = img.execute_transforms(output_encoding=images.JPEG)
left_x = (resized_img.width - 60) / 2
resized_img.crop(left_x, 0, left_x + 60, 80)
cropped_img = resized_image.execute_transforms(output_encoding=images.JPEG)
In my example it crops to the center of the image.
It assumes that the resized image is at least 60 pixels wide, but obviously you would have to add some checks to confirm this, because a user might not upload an image in the right size.
I used something else:
Resize the original image to your max height (80)
Store the resized (but complete/not cropped) image
Display it inside a <div> that has the following CSS: width: 60px; height: 80px; overflow: hidden;
That way it will show nicely in your list, but you can still display the complete resized picture on your user's profile page (looking at you code I imagine that's what you are trying to do, right?)

Resources