I supposed to make this type of charts, is it posssible to make through Raphael or any good Plug-in for Raphael. ( i prefer raphael, because already i using this), I am attaching the image that what i need to produce?
thanks for advance..
I'd genuinely advise just drawing the thing manually using the Raphael library. When we had a requirement for an uncommon graph type, I attempted to get existing graphing libraries to draw it, but it was awful. I mocked up a prototype in an evening to demonstrate how much cleaner it is to draw it manually with raphael, and we ended up using it. Best thing you can try to do is prototype what you are looking for: create a dummy set of Json for the graph and try to plot from this data. You should find that it's relatively straight forward to divide the content area up:
numberOfMonths = 6;
barsPerMonth = 2;
marginLeft = 40;
marginRight = 40;
graphArea = canvasWidth - marginLeft - marginRight;
monthWidth = graphArea / numberOfMonths;
barWidth = monthWidth / barsPerMonth;
Just define all of the margins and widths that you want. Define the range of your axes and define a tick scale/count. That should get you started.
Related
I'm playing around with osgEarth and while it's crazy easy to add features in the .earth file, I'm struggling to do it at runtime via the API. I want to let the user draw polygons on the map/globe so I need to be able to dynamically define geometry and styles based on user input.
Right now I'm just going for a static implementation to figure out what I need to do, but for the life of me I can't get anything to show up. Here is my sample code. I've already loaded a .earth file that defines the MapNode which is what I'm using here.
// Style
osgEarth::Symbology::Style shapeStyle;
shapeStyle.getOrCreate<osgEarth::Symbology::PolygonSymbol>()->fill()->color() = osgEarth::Symbology::Color::Green;
// Geometry
osgEarth::Symbology::Polygon* polygon = new osgEarth::Symbology::Polygon();
polygon->push_back(0, 0);
polygon->push_back(0, 10);
polygon->push_back(10, 10);
// Feature
osgEarth::Features::Feature* feature = new osgEarth::Features::Feature(polygon, mapNode->getMapSRS(), shapeStyle);
// Node
osgEarth::Annotation::FeatureNode* featureNode = new osgEarth::Annotation::FeatureNode(mapNode, feature);
featureNode->setStyle(shapeStyle);
featureNode->init();
mapNode->addChild(featureNode);
This should draw a green triangle near the middle of the map, but I don't see anything. Am I wrong in assuming that my polygon points are geo coordinates (lon, lat)? Is it wrong to just create my Style and Geometry on the fly like this? What am I doing wrong?
Update: This seems to work fine on a 3D (geocentric) map, but not on a 2D (projected) map which is what I'm after.
After poking around a bit I stumbled upon the osgearth_features example that comes with the SDK which includes examples of creating features programatically. I followed the pattern from the sample and came up with something that works.
// Style
osgEarth::Symbology::Style shapeStyle;
osgEarth::Symbology::PolygonSymbol* fillStyle = shapeStyle.getOrCreate<osgEarth::Symbology::PolygonSymbol>();
fillStyle->fill()->color() = osgEarth::Symbology::Color::Green;
osgEarth::Symbology::LineSymbol* lineStyle = shapeStyle.getOrCreate<osgEarth::Symbology::LineSymbol>();
lineStyle->stroke()->color() = osgEarth::Symbology::Color::Black;
lineStyle->stroke()->width() = 2.0f;
// Geometry
osgEarth::Symbology::Polygon* polygon = new osgEarth::Symbology::Polygon();
polygon->push_back(0, 0, 10000);
polygon->push_back(0, 10, 10000);
polygon->push_back(10, 10, 10000);
// Feature Options (references the geometry)
osgEarth::Drivers::OGRFeatureOptions featureOptions;
featureOptions.geometry() = polygon;
// Model Options (references the feature options and style)
osgEarth::Drivers::FeatureGeomModelOptions geomOptions;
geomOptions.featureOptions() = featureOptions;
geomOptions.styles() = new osgEarth::StyleSheet();
geomOptions.styles()->addStyle( shapeStyle );
geomOptions.enableLighting() = false;
// Model Layer Options (created using the model options)
osgEarth::ModelLayerOptions layerOptions("test polygon", geomOptions);
mapNode->getMap()->addModelLayer(new osgEarth::ModelLayer(layerOptions));
Defining the style and geometry is more or less the same as what I was doing before (I added a line symbol this time), but in this case I'm adding a ModelLayer to the Map. That ModelLayer uses some model options that reference my style and geometry through the feature options.
I don't know if this is the best way to do it or how scalable it is (can I do this over and over thousands of times?), bit it's at least got me going,
I am using Wowza Media Streams for a live streaming in my project. I am using overlay on video. My question is, that I want to hide displaying overlay after an interval of time. Please guide me is there any way to do this. My code is for using overlay is
wowzaImage = new OverlayImage(basePath+"logo_14.png",100);
mainImage.addOverlayImage(wowzaImage,srcWidth-wowzaImage.GetWidth(1.0),0);
This is being used to display overlay. To Hide this overlay after fix time, I tried this
mainImage.addOverlayImage(null,srcWidth-wowzaImage.GetWidth(1.0),0);
But this didn't work. Also tried
wowzaImage = new OverlayImage(basePath+"logo_14.png",0);
mainImage.addOverlayImage(wowzaImage,srcWidth-wowzaImage.GetWidth(1.0),0);
But it still shows overlay there.
Please help, Thanks
If you are looking at the example here you can find a couple of ways to accomplish this (depending on how you've set it up). You can leverage the add fading step convenience function as follows:
mainImage.addFadingStep([start-value],[end-value],[number-of-frames]);
Otherwise you can fade the image itself away on each frame (see onBeforeScaleFrame event handler) similar to the way you were suggesting in your question:
OverlayImage img = new OverlayImage([resource], opacity);
mainImage.addOverlayImage(img,xpos, ypos);
For the latter you will want to be sure it is being referenced correctly and that the positioning holds true.
Thanks,
Matt
I'm confused with using QwtPlot class to draw a customized coordinate system.
My goal is to draw a coordinate system with customized scale, and draw grid line on these customized scales. Here are the values of the scales:
x-axis and y-axis scale:
x1=-0.642455
x2=0
x3=0.642455
y1=-0.642455
y2=0
y3=0.642455
I read the user's guide of QwtPlot class and QwtPlotGrid class. I found a function in QwtPlotGrid class called setxDiv and seemed that it could help, So I wrote the following code:
QList<double> doubleListmin;//min scale
QList<double> doubleListmed;//medium scale
QList<double> doubleListmaj;//major scale
doubleListmin.append(0.1);
doubleListmed.append(0.3);
doubleListmaj.append(0.642455);
QList<double> doubleList[3];
doubleList[0] = doubleListmin;
doubleList[1] = doubleListmed;
doubleList[2] = doubleListmaj;
QwtScaleDiv *xDiv = new QwtScaleDiv(-0.642455, 0.642455, doubleList);
//lowerbound is -0.642455, upperbound is 0.642455, doubleList customizes the scale
QwtPlotGrid *grid = new QwtPlotGrid();
grid->setXDiv(*xDiv);
//grid->updateScaleDiv(*xDiv, *xDiv);
grid->attach(this);
But it turned out to have no influence on the new QwtPlotGrid, it doesn't change its scale system.
I think there's another way: draw a several lines in the QwtPlot. But I don't know how to do it.
Somebody help me please!!!
Thank you in advance~
As you said "draw severalk lines" is not good approach because you can't do this lines infinity. To do this there is special class QwtPlotMarker which is more suitable here. Maybe not the best thing in the world, but works as you want:
QwtPlotMarker *m1=new QwtPlotMarker;
m1->setLinePen(QPen(Qt::gray));
m1->setLineStyle(QwtPlotMarker::VLine);
m1->setValue(0,0);
m1->attach(ui->qwtPlot);
QwtPlotMarker *m2=new QwtPlotMarker;
m2->setLinePen(QPen(Qt::gray));
m2->setLineStyle(QwtPlotMarker::HLine);
m2->setValue(0,0);
m2->attach(ui->qwtPlot);
QwtPlotMarker *m3=new QwtPlotMarker;
m3->setLinePen(QPen(Qt::gray));
m3->setLineStyle(QwtPlotMarker::HLine);
m3->setValue(0,-0.642455);
m3->attach(ui->qwtPlot);
QwtPlotMarker *m4=new QwtPlotMarker;
m4->setLinePen(QPen(Qt::gray));
m4->setLineStyle(QwtPlotMarker::HLine);
m4->setValue(0,0.642455);
m4->attach(ui->qwtPlot);
QwtPlotMarker *m5=new QwtPlotMarker;
m5->setLinePen(QPen(Qt::gray));
m5->setLineStyle(QwtPlotMarker::VLine);
m5->setValue(-0.642455,0);
m5->attach(ui->qwtPlot);
QwtPlotMarker *m6=new QwtPlotMarker;
m6->setLinePen(QPen(Qt::gray));
m6->setLineStyle(QwtPlotMarker::VLine);
m6->setValue(0.642455,0);
m6->attach(ui->qwtPlot);
Better create your own QwtScaleDiv object setting the ticks manually and assign them using QwtPlot::setAxisScaleDiv(). Update of the grid will happen automatically ( as long as you didn't decouple it explicitly ).
When you also need to manage the tick positions when zooming you have to derive your own scale engine instead - overloading the QwtScaleEngine::divideScale() method.
I am using Skia for one of my sample program. I have a canvas and inside this I am writing text with font_size 30, this is the code snippet.
string = "Test String";
SkString text(string);
SkPaint paint;
SkScalar textWidth;
paint.setTextSize(SkIntToScalar(font_size));
paint.getFontMetrics(&metrics);
textWidth = paint.measureText(text.c_str(), text.size());
textWidth will give the exact width of the text inside the canvas. My question is how can I get the height of the text ? Please help.
I once had to look into this myself in the past, this link here should help you, even though it is java, fonts all work on the same idea as far as I know.
I assume you will want from the ascender to the baseline, Which is just the ascent. Or you may want the whole thing from top to bottom which is the ascent and descent combined,
If you were writing on lined paper, the baseline is the same as the line you write on, anything above that is the ascent, anything below is the descent.
I dont know anything about skia, But A quick look into skia, at this link here, that there is a public member called fAscent in FontMetrics, and fDescent, Maybe you can use those.
the font size your have specified as "font_size" is the height of single line text
Is there a way to do gradients in css/html/javascript only that will work across all the major browsers? (MS IE 5+, Firefox, Opera, Safari)?
Edit: I would like to do this for backgrounds (header, main panel, side panels). Also, would like to have vertical line gradients as well.
Edit: after reading the responses, let's open this up to Javascript solutions as well, since HTML/CSS by itself makes it tougher to achieve.
I've done this before as a gimmick, using javascript like:
var parent = document.getElementByID('foo');
for(var i=0; i< count; i++) {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.width='100%';
div.style.height = 1/count+"%";
div.style.top = i/count+"%";
div.style.zIndex = -1;
parent.appendChild(div);
}
If your requirement is just to have a gradient, you really should use a gradient image set as background-image in css. In my case, I was animating the colors and position of the gradient as well. I can't vouch for now cross-browser it is (for starters, make sure the parent has some position applied, otherwise it won't be a position-container for the absolute positioning.
I'm unclear on the implementation details you are seeking (such as background, or just a border along the side of the window, etc); however, it's possible albeit a little tedious.
One example that comes to mind would be to have n-block level elements, such as divs, and then give them each a small height (a couple of pixels, for example) and then gradually change the background color of each subsequent element.
I use the gradient CSS code generator by colorzilla: http://www.colorzilla.com/gradient-editor/
It has polyfills for IE - but not sure how far back it goes.
I think the short answer is no.
You can create something that looks like a gradient using only css, but to then use it like an image background... I think that is pushing it a bit.
EDIT (feeling silly)
I found the solution: http://en.wikipedia.org/wiki/JPEG
There are lots of ways to create a gradient now.
1. You can create image for it.
2. Use CSS3 Gradient, it can be linear, radial and repeating.
Syntax for linear :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
Syntax for radial :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
For IE6 to IE 9 we can use the filter property or you can also use CSS3Pie.
Following are some referances that will help:
Mozilla MDN
CSS3File