I'm trying to update series types in Highchart but there is a data loss in it.
Here is my snippet:
h = Highcharts.charts[0]
h.series[0].options.type
-> "candlestick"
h.series[0].options.data[0]
-> [1386543600000, 111.69, 111.79, 109, 109.39]
h.series[0].update({type: "spline"})
h.series[0].options.data[0]
-> Object {x: 1386543600000, y: 111.69}
jsfiddle, which show the dataloss with Highstock/StockChart: http://jsfiddle.net/fqd1bshm/1/
Update 1
If I use the navigator with Highcharts: http://jsfiddle.net/9mby1xqn/1/
the same problem occurs.
Thanks
Found a solution. It was the navigator that "updates" the data. If you want it to stop doing that, you have to set the adaptToUpdatedData value in the Highcharts configuration.
Should then look like this:
navigator: {
enabled: true,
adaptToUpdatedData: false
}
jsfiddle: http://jsfiddle.net/9mby1xqn/3/
Related
How to take current view and set the view to orthographic?
I tried using viewer.getCamera() to get parameters how the view is currently set and then setting it with viewer.applyCamera().
var camera = viewer.getCamera();
console.log('Camera: ' + JSON.stringify(camera));
Which returns:
Camera: {
"metadata": {"version":4.3,"type":"Object","generator":"ObjectExporter"},
"object":{"uuid":"78D2EA86-853B-473F-9E0E-E3F0C8874E40",
"type":"Camera",
"matrix":[1,0,0,0,0,1,0.00009999999747378752,0,0,-0.00009999999747378752,1,0,114010.796875,88329.0078125,135503.609375,1],
"children":[
{"uuid":"53C7FA49-B00C-4616-9E7A-CCB94A661A45",
"type":"DirectionalLight",
"color":8355711,"intensity":0,
"matrix":1,0,0,0,0,1,0,0,0,0,1,0,-0.5,0.20000000298023224,0.05999999865889549,1]},
{
"uuid":"7D5EC244-7268-4190-8480-4BD1DD56F8CB",
"type":"Object3D","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
}]}}
Then I tried setting, with the "matrix" array as params, but the view jumps.
viewer.setViewFromArray(params);
I followed the format of an array with the data from current camera and applied them by viewer.setViewFromArray. I kept all other parameters, but only set the last param to 1 (ortho).It looks working well at my side.
viewerApp.myCurrentViewer.setViewFromArray([
viewerApp.myCurrentViewer.getCamera().position.x,
viewerApp.myCurrentViewer.getCamera().position.y,
viewerApp.myCurrentViewer.getCamera().position.z,
viewerApp.myCurrentViewer.getCamera().target.x,
viewerApp.myCurrentViewer.getCamera().target.y,
viewerApp.myCurrentViewer.getCamera().target.z,
viewerApp.myCurrentViewer.getCamera().up.x,
viewerApp.myCurrentViewer.getCamera().up.y,
viewerApp.myCurrentViewer.getCamera().up.z,
viewerApp.myCurrentViewer.getCamera().aspect,
viewerApp.myCurrentViewer.getCamera().fov,
1,
1
]);
you can also check the source Viewer3D.js to get the workflow how setViewFromArray works.
Viewer3D.prototype.setViewFromArray = function(params, name){....}
IF you simply want to switch the view between perspective and orthographic, you can use the direct API:
Viewer.navigation.toOrthographic()
Viewer.navigation.toPerspective()
I'm using primefaces 6.0 line chart component, which is based on jqPlot. In my charts I have null values, which I need because I'm making use of the breakOnNull plotting option, so the curves have breaks on the null points, but unfortunately the null "points" are being shown as string (see screenshot).
So far I have tried to solve this setting the hideZeros: true option - no success. I also tried a simple custom pointLabels renderer:
this.cfg.seriesDefaults.pointLabels =
{
show: true,
location: 's',
formatString: '%.1f',
formatter: function(format, val){
console.log(val);
return (val== null?"":val);}
}
but this doesn't work either since the null values are not being passed to it all, which I can not understand.
Any help will be appreciated.
You can iterate over the pointLabels divs with jQuery each function and when detecting a null string, change it to be null.
Here is an example for the approach, this addition function to the (document).ready event will remove the text of the x-axis labels, after the chart has been created. With a similar apporach you can remove your required values from the corresponding divs:
$('.jqplot-xaxis-tick').each(function(i,elem) {
$(this).text(null);
});
Here is a jsfiddle with example for the x-axis labels being removed by the described approach.
Tried checking if the null values are by accident 'null' strings by changing return (val== null?"":val);} to return (val== 'null'?"":val);}
Cocos Creator - I have a node that I want to rotate towards another node, here is the code I'm using:
update: function (dt) {
this.rotate();
},
rotate: function () {
var diff = this.target.position - this.node.position;
var angle = Math.atan2(diff.x, diff.y);
this.node.rotation = cc.radiansToDegress(angle);
},
But it's not rotating at all, I tried to search the docs but couldn't find anything helpful.
var diff = this.target.position - this.node.position;
You're basically trying to subtract an object from an object. Check
{'x':2, 'y':3} - {'x':4, 'y':6}
in your JS console. The result is NaN
You need to subtract each dimension manually.
var diff = {
'x' : this.target.position.x - this.node.position.x,
'y':this.target.position.y - this.node.position.y
};
Apologies to necro this question, but since this is a top search result I just wanted to add that the problem here is that the signature of Math.atan2 takes it's coordinates backwards:
Syntax:
Math.atan2(y, x)
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2
I've a Higstock lineal graph. Sometimes I need to show just one serie, other times I need two or three series to draw.
Obviously, this is an example of adding series dynamically. I put:
$(function() {
var chart = new Highcharts.StockChart({
// ...
series: []
// ...
})
chart.addSeries({name : "Value1",data : value1Data});
chart.addSeries({name : "Value2",data : value2Data});
chart.addSeries({name : "Value3",data : value3Data});
But not working, the chart needs to have at least one serie with data values in "series" node, not allowing an empty series node, like I put before.
I need to add all my series dynamically.
Anyone can help me? Thanks.
Example: http://jsfiddle.net/8aP69/1/
FYI: The graph only draws the navigation bar.
After many little test, a man that I loved him give me the solution.
I need to set initial series node like that:
series: [{ name: "Serie1", data : [null]}] // first serie has to be null
And after that, adding data point for first serie.
chart.series[0].setData(data1); // adding his data here
I want to hide the labels. I believe it is something to do with the option bubble.textStyle and setting the color to none but I can't figure it out.
Bubble <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
colorvar="Year", sizevar="Profit",
options=list(hAxis='{minValue:75, maxValue:125}',
width=500, height=300))
plot(Bubble)
Thanks..
The tricky thing is that it's a JSON object inside a JSON object. First you use bubble="{} to create the first JSON object and then textStyle:{} to create the next JSON object inside bubble="{}.
Here is my code and a screenshot,
# install.packages("googleVis", dependencies = TRUE)
require(googleVis)
Bubble <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
colorvar="Year", sizevar="Profit",
options=list(hAxis='{minValue:75, maxValue:125}',
width=500, height=300),
bubble="{textStyle:{color: 'none', fontName:
<global-font-name>, fontSize:
<global-font-size>}}")
plot(Bubble)