Can I calculating UV index from this infos?
"precipIntensity": 0.0028,
"precipProbability": 0.08,
"precipType": "rain",
"temperature": 96.72,
"apparentTemperature": 112.71,
"dewPoint": 77.22,
"humidity": 0.54,
"windSpeed": 1.7,
"windBearing": 173,
"visibility": 6.21,
"cloudCover": 0.43,
"pressure": 1001.25,
"ozone": 275.78
I use forecast.io api to make an application, but I can't found uv index values! Can I calculating UV index from this infos?
Thanks,
Look at that document with UV Index calculation explanations based on current weather and geo data: Calculation of UVI for Smartphone Apps.
You could also check OpenUV - Global UV Index Forecast API.
Related
I have time series data in a database that looks like this:
[
{
min: 100,
max: 200,
avg: 150,
time: 12345678.. (unix timestamp)
},
{
min: ..
...
}, ...
]
I am able to draw a line chart using the avg value by pulling it from the database as data points such as:
[
{
t: 12345678... (unix timestamp)
y: 150 (avg value)
},...
]
What I am trying to achieve is drawing three lines for min, max and avg respectively with the same dataset as:
[
{
t: 12345678... (unix timestamp),
y1: 150 (avg value),
y2: 100 (min value),
y3: 200 (max value)
},...
]
I have tried looking at documentation and many questions here but did not find a lead.
I can separate the datasets but normally I am processing a lot of data on the backend and wanted to see if this can be done without any further processing.
Want to know if this is achievable or it's chart.js' limitation?
You can't use multiple key values with Chart.JS because it is not meant to accept that data format however you can format incoming data to create a chart based on the two-line sample.
Here is the working demo: https://jsfiddle.net/adelriosantiago/esn2wjxv/27/
This is how data is prepared:
Raw data in the wrong format is called rawData.
The function getSingleProp transforms data (the second argument) so that only the property prop (the first argument) is extracted. This happens at the line:
data.map((i) => {
return { y: i[prop], x: i.time }
})
When calling Chart.JS we simply use getSingleProp("[the property we want]", rawData) as data resulting in the chart you are looking for.
Is there a way to dynamically build an SVG using sprites in amcharts 4?
Example: screenhot
There are 20 different types which are represented by colors.
Each pin can contain a multitude of types.
So an example can be that a pin has 3 types and will consist out of 3 colors.
I have an SVG path which is a circle.
With regular JS and SVG i can create a path for each type and change the stroke color, strokedasharray and strokedashoffset.
This results in the nice circle with 3 colors.
However this seems to be impossible to do with amcharts 4.
For starters, strokedashoffset is not even a supported property for a sprite. Why would you bother supporting strokedasharray and then ignore strokedashoffet?!
The second problem is finding out how to pass data to the sprite.
This is an example of a data object I pass to the mapImageSeries class.
[{
amount: 3,
client: undefined,
colorsArr: {0: "#FFB783", 1: "#FD9797", 2: "#77A538"},
dashArray: "500,1000",
dashOffset: 1500,
divided: 500,
global: true,
groupId: "minZoom-1",
hcenter: "middle",
id: "250",
latitude: 50.53398,
legendNr: 8,
longitude: 9.68581,
name: "Fulda",
offsetsArr: {0: 0, 1: 500, 2: 1000},
scale: 0.5,
title: "Fulda",
typeIds: (3) ["4", "18", "21"],
typeMarker: " type-21 type-18 type-4",
vcenter: "bottom",
zoomLevel: 5
}]
It seems impossible to pass the colors down to the sprite.
var svgPath = 'M291,530C159,530,52,423,52,291S159,52,291,52s239,107,239,239c0,131.5-106.3,238.3-237.7,239'
var mainPin1 = single.createChild(am4core.Sprite)
mainPin1.strokeWidth = 100
mainPin1.fill = am4core.color('#fff')
mainPin1.stroke = am4core.color('#ff0000')
mainPin1.propertyFields.strokeDasharray = 'dashArray'
mainPin1.propertyFields.strokeDashoffset = 'dashOffset'
mainPin1.path = svgPath
mainPin1.scale = 0.04
mainPin1.propertyFields.horizontalCenter = 'hcenter'
mainPin1.propertyFields.verticalCenter = 'vbottom'
With what you've provided, simulating your custom SVGs is beyond the scope of what can be answered, so I'll try tackling:
applying stroke-dashoffset despite lack of innate library support. (I see you've added a feature request on GitHub for it, so why the library doesn't include it, when/if it will, can be left for discussion there.)
passing data/colors to the Sprite
For both we're going to have to wait until the instances of Sprites are ready along with their data. Presuming your single variable is a reference to a MapImageSeries.mapImages.template, we can set up an "inited" event like so:
single.events.once("inited", function(event){
// ...
});
Our data and data placeholders don't really support nested arrays/objects in general, since your colors are nested within a field, we can find them via:
event.target.dataItem.dataContext.colorsArr
You can then set the fill and stroke on the Sprite or event.target.children.getIndex(0) manually from there (in my demo below, the index will be 1 because mainPin1 is not the first/only child created on the MapImage template).
As for stroke-dashoffset, you can access the actual rendered SVGElement via sprite.group.node and just use setAttribute.
I forked our map image demo from our map image data guide and added all the above to it here:
https://codepen.io/team/amcharts/pen/6a3d87ff3bdee7b85000fe775af9e583
Given an array like:
[
{ final_amount: 20.0, shipping_amount: 5 },
{ final_amount: 30.0, shipping_amount: 5.5 },
{ final_amount: 25.0, shipping_amount: 105.5 },
{ final_amount: 325.0, shipping_amount: 125.5 }
]
How could I detect that
{ final_amount: 25.0, shipping_amount: 105.5 }
is an outlier?
Bigger final_amount means bigger shipping_amount, however we have some bad entries in our data set.
If I take into consideration only shipping_amount (with median and standard deviation) it removes some valid entries because it's not taking the final_amount into consideration.
The right way to go about any problem like this is to have a model of "normal" data and one or more models of "abnormal" data. Each of these is a p(data|category) for some category. Apply Bayes' rule to compute p(category|data) and make some choice among the categories, e.g. pick category with largest p(category|data). This a pretty wide-open field so good luck and have fun. Also you might get more interest on stats.stackexchange.com.
being new to Flot i am struggling a bit. My goal is the present a bar with different data elements in it that must have a different color per element. I want to provide the color per data element.
Any hints on how this can be done?
Example:
[0,100][0,200][0,100][0,200]
All elements with value 100 should be blue and all elements with 200 should be green.
A nice one would be,
[0,100,blue][0,200,green][0,100,blue][0,200,green]
But this off course does not work, it is just an explanation what i want to achieve!
Doing this with multiple data series seems does not work in my case.
Any hints on how this can be done?
You can do it with multiple series, as this is how I have done something like this :)
So in your plot method you would have something like this:
$.plot($('#placeholder'), []); // The array would hold your data
You can also further extend this to provide some options to flot to tell it what to make your chart look like. To do that you pass an object of options after the array.
However, im not quite sure what you need in terms of the Graph, your example gave some numbers but the x coordinate was all 0, im not sure if you just want a bar graph?
Anyway, heres the code of how you would get it to display a bar graph, with one green line and one blue line:
var flotOptions = {
series: {
lines: { show: true, fill: false, lineWidth: 15 }
}
},
var data = [{
color: '#001EFF',
data: [[0, 0], [0, 100]]
}, {
color: '#00FF0E',
data: [[5, 0], [5, 200]]
}];
$.plot($('#placeholder'), data, flotOptions);
I would recommend making it so that the data is automatically generated on a server side, then you can check in javascript, and add the color depending on the y value in the data array of each series.
I have also created a jsFiddle of this for you, so you can go take a look and play around with it. As I have said im not quite sure what you want but this is a good start for you. Good luck!!
I'm looking for a way to access each point's on the graph actual svg object in order to change some of its properties on-the fly.
Say I have 100 objects, of those around 50% need to be drawn in a different color (though they belong to the same data series, no way round). Thus, by using:
chart.series[0].points
I'm able to modify object properties (like fill) but no way to redraw the chart afterwards. Using chart.redraw() gives nothing, well actually it changes the points color but only after I mouse over them, the chart itself is not redrawn properly.
Any help appreciated.
Regards!
There are at least two ways that you can use here.
On Load
You can define a color for each of the points explicitly while adding them to the data array. The following is what the documentation states
A list of object with named values. In this case the objects are point configuration objects as seen below.
Range series values are given by low and high.
Example:
data: [{
name: 'Point 1',
color: '#00FF00',
y: 0
}, {
name: 'Point 2',
color: '#FF00FF',
y: 5
}]
Reference: http://api.highcharts.com/highcharts#series.data
jsFiddle # http://jsfiddle.net/jugal/mXPPH/
Dynamically
You can add the color/markers to individual points using the point.update() method as follows,
var p = chart.series[0].points[l - 1];
p.update({
marker: {
symbol: 'square',
fillColor: "#A0F",
lineColor: "A0F0",
radius: 5
}
});
Reference : http://api.highcharts.com/highcharts#Point.update%28%29
You may also want to look a similar answer I had provided for this question # Dynamically draw marker on last point in highcharts and its jsFiddle # http://jsfiddle.net/jugal/zJZSx/