In my Firebug, it is showing me:
TypeError: this[r]._ticks[0] is undefined
But in my JS Array, the items are well constructed. Should not be the data problem.
So, as i said it should not be the data problem. The mystery is:
The problem is not consistent, just that SOMETIME JUST GOT WHOLE BLANK.
I have multiple log ranges (e.g, Show 1 week, Show 1 day, Show 1 hour), then sometime some got BLANK like now and at the same time, graphs are OK in some time ranges. And next time, this range got OK and next range got problem. (With this same code, same data)
I am super sure all my Array Rooms are filled with respective data inside. (I got no blank or corrupted array rooms)
I'm outta idea already :S
Please help.
I have the same problem this day, and resoled this by hard coding the second array value is number but not string type. You can do this simply in php code: $output["1"]=(double)$var, then try to use json_encode to output the data.
Here is the difference example:
valid array format:
var data=[[['2014-01', 2],['2014-02',5.12],['2014-03',13.1],['2014-04',33.6],['2014-05',85.9],['2014-06',219.9],['2014-07',39.9],['2014-08',99.9]]];
invalid array format:
var data=[[["2014-02","1920.97"],["2014-03","2040.92"],["2014-04","1704.52"],["2014-05","1630.88"],["2014-06","207.43"]]]
Use parseFloat(var) or parseInt(var) before passing data to the graph.
Where var is your variable or value which you are passing to graph.
Related
I'm using charts.js, where I want to add one datarow per minute. Hence to avoid a complete redraw, Im using some ajax and just pushing a new element to the chart.
Pushing VALUES works fine, however, pushing to the label-array shows very strange behaviour. I'v now tried everything from a simple push upto iteratively cloning the whole array, copy all values, replacing the whole array... The result is still the same.
The added element seems to be always end up with index 0, therefore ending up left in the chart, rather than on the right side.
Upon initial pageload, the data that is existing is loaded as a json-array, which works as expected, for example:
var labels = ["16:00", "16:01", "16:02"]
Now, using some ajax, I retrieve a new Dataset for 16:03. Pushing that label to the array like this:
...
labels.push("16:03");
console.log(labels);
...
and inspecting it in the browser afterwards leads to the following strange view:
The stringified representation looks as expected:
(4) ["16:00", "16:01", "16:02", "16:03"]
But when expanding the view in chrome, the result is:
0: "16:03"
1: "16:00"
2: "16:01"
3: "16:02"
So, iterating the array by using index-values obviously leads to a different result than using .toString(). I have no idea what is happening here. I'm mainly confused, why the stringified version looks different than the actual drill down on indexes?
Running a vanilla-example of these steps leads to the desired result. So it has to do something with the "context" of that array. But I have no idea where to start digging ;)
Here's a screenshot
edit:
Following the example over here, it should work like that...
https://www.chartjs.org/docs/latest/developers/updates.html
Comment of #CBroe made me figure it out:
Uppon initial loading, I did not outline the labels explicit, because there i'm having whole objects like {x:"16:00", temp="20", rain="0"} i'm feeding the datarows of chart.js with.
Now, when altering the label-array, chart-js seems to apply the following logic:
Labels-Array is a dedicated Array that EXISTS but is empty if not explicit defined.
In the Getter of that array, Any Labels derived from data-objects are appended to the array.
hence, pushing to the actual array starts with index "0" if it's inititially empty. But looking at the result of the getter then delivers the static array + any required label derived from the data objects given.
Now outlining the labels-array explicit as well, this resolves the issue.
Sorry - I'm a newbie!
I need to use a script to read a date from a Googlesheet, add a week and save the new date back to the sheet.
I've tried various suggestions from various posts without success. The approach I thought should work is failing to get a millisecond value from a date from a cell - subsequent processing appeared OK.
var oldDate = sheet.getRange('oldDateRange').getValue(); // obtains a date object and then...
var oldDateValue = oldDate.getMilliseconds() // I expected to return milliseconds but shows as undefined...
See link to a simplified illustration sheet and script illustrating my problem.
This is my first question on StackOverflow - feedback welcome on how to make it more helpful for others....
In order to convert the date obtained from the sheet to milliseconds, I think you simply need to replace .getMilliseconds() with .getTime()
My input excel sheet has field "date" with two different types of values as shown below
2015-03-02 11:06:35
3/2/2015 4:03:53 AM
I am reading them as "string" and performing below logic
var temp = date.getString();
temp = str2date(temp,"dd.MM.yyyy HH:mm:ss");
I get the below error
*Could not apply the given format dd.MM.yyyy HH:mm:ss on the string for 2015-03-02 11:06:35 : Format.parseObject(String) failed*
I tried reading them as "date" , but I got the below error
Unparseable date: " 2015-03-02 11:06:35 "
How can we handle this error?
A couple ideas from the docs. http://wiki.pentaho.com/display/EAI/JavaScript+Values
First try calling getDate() it should be a function associated with the cell in question.
If that doesn't work try calling getNumber() in excel all dates are represented in floating point. The whole number part is days since jan 1 1970 and the fraction part is the percentage of the way through the day. I'm sure if you look around there is a js wrapper around this functionality.
Another idea would be to determine all the numberformat strings. Loop over them catching errors. The one that doesn't throw an error should be the correct one. Or you could write a small regex pattern to better examine the dates coming out.
Finally, I got result. I will explain step by step please follow steps very carefully.
Step 1: Data Grid => I created one field called fail_date i.e String datatype.
Step 2: Modified Java Script Value => I wrote some code like these.Please follow screen shot.
Step 3: Select values => Here i converted date datatype.
Step 4: Modified Java Script Value 2 => Here also i wrote one code.Please follow screen shot.
Step 5: Select values => Finally, I converted require data format.here correct_date field is your required output.
Step 6: Final output screen will be like these.
Step 7: Below screen shot show whole transformation screen.
Hope this helps.
Can you use a library. I've used xdate its really good. And it parses both of these date strings
var xdate = require('xdate');
xdate('2015-03-02 11:06:35').toDate(); // returns a js date object
xdate('3/2/2015 4:03:53 AM').toDate(); // returns another js date object.
I'm trying to import data For a large number of dates from here: https://demanda.ree.es/movil/peninsula/demanda/tablas/2014-11-03/2
Once/if that's possible I want to automate it so it retrieves the data for a given set of dates. Say, entire 2013.
I can't find anything in the webpage source that would give a hint as to from where the data is retrieved from. I've tried importing the data both using:
Data/From Web: Gets javascript error
Open/ Other web locations: Just retrieves a worksheet filled with grey cells, no data.
Thanks for any help!
Use the following links:
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/maxMinPeninsula?callback=angular.callbacks._0&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/prevProgPeninsula?callback=angular.callbacks._1&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=2013-01-01
https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/coeficientesCO2?callback=angular.callbacks._3&curva=DEMANDA&fecha=2013-01-01
Use the "fecha" parameter to set the date. It seems it is not possible to get the whole year at once so you should iterate the calls to that link and change "fecha" to 2013-01-02, 2013-01-03, etc. for each month.
Muchas gracias #miguel-febres! It now works more or less*. Where did you find the links from? :)
It runs some 10-20 loops and returns an address error, upon which I just start the macro again and it works... strange.
Sub Macro1()
Application.DisplayAlerts = False
Do
Workbooks.OpenText Filename:="https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=" & ActiveCell.Value & ""
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("Spain").Activate
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
'close table
Windows("demandaGeneracionPeninsula").Activate
ActiveWindow.Close
ActiveCell.Offset(-1, 1).Activate
Loop Until ActiveCell.Value = ""
End Sub
Now I just have to parse the results.. :)
Hi I'm fairly new to JavaScript and d3.js. I've created my chart and everything is running great on that end of things. However I'm trying to display some information in text in addtion to the graph which just shows montly sales total this year in comparison to the previous finacial year result.
The weird thing that I'm getting is that the text that is being displayed in the h2 is just showing [object Object] even though all the data is loading in fine when I've de-bugged it in firebug it shows this http://i.imgur.com/rOnZQXG.png (I cant embedd as I dont have a high enough rep)
which is the correct data
This is the code that I've used for the text -
d3.csv("OrderValueToday.csv", function(today) {
console.log(today);
var totalSales = today
svgLabel = d3.select("#label").append("h2")
.text(totalSales)
});
The CSV that I'm getting already has the total sales today so there is no summing done on my end this is already been done for me when I get the data. The CSV is formatting like so
Today
20000
and this is the same pretty much for all the data that I have. If you could help me out fix this problem that would be fantastic as this the final thing that get this project done. Cheers
By the looks of things you're passing in an array containing an object. You just need to access the Today value.
d3.csv("OrderValueToday.csv", function(obj) {
var text = 'Total sales today = ';
var totalSales = text + obj[0].Today;
svgLabel = d3.select("#label").append("h2")
.text(totalSales);
});