My particles.js won't load with my WorpdPress custom theme.
The console throws this error:
I found plugin for this Particles effect, but I don't know how to use it :D And, I'd like to implement my own.
So, particles worked just fine, until I transformed my website into a WordPress theme... It's obviously problem with a JSON file....how can I go around this?
btw....it's on localhost....would it make difference when on a server?
Ok, so I managed to solve this problem. Not sure if it's THE solution, but what worked for me was: I had to put the JSON config inline, in a custom app.js file. Then it worked.
When the JSON config is in a separate file, WP has a problem loading it. It throws GET 404 not found. So....this worked for me...
I found the solution here: https://github.com/VincentGarreau/particles.js/issues/157
what I did was include the json settings in a variable and place that code in the javascript file that you put this code
particlesJS.load('particles-js', 'assets/particles.json', function() {
console.log('callback - particles.js config loaded');
});
But I did not use particlesJS.load, just particlesJS. So it would look something like this
var config = {
particles: {
number: {
value: 100
},
color: {
value: "#d4d4d4"
},
shape: {
type: "circle",
stroke: {
width: 0,
color: "#d4d4d4"
},
polygon: {
nb_sides: 5
}
},
opacity: {
value: 0.5,
random: false,
anim: {
enable: false,
speed: 1,
opacity_min: 0.1,
sync: false
}
},
size: {
value: 3,
random: true,
anim: {
enable: false,
speed: 40,
size_min: 0.1,
sync: false
}
},
line_linked: {
enable: true,
distance: 150,
color: "#d4d4d4",
opacity: 0.4,
width: 1
},
move: {
enable: true,
speed: 2,
direction: "none",
random: false,
straight: false,
out_mode: "out",
attract: {
enable: false,
rotateX: 600,
rotateY: 1200
}
}
},
retina_detect: true
}
particlesJS("your-id-or-class", config, function () {})
Related
I use a DrawChart method and try to set the logarithmic option to the yaxis to true without success:
The datas (for the series) contains :
"[{type:"bar",data:[1.19576304413727E-08,1.30322021618667E-07]}]"
I try to place the logarithmic : true option in several place without succes. For me it must be placed into the yaxis part.
Thank you in advance
chart.updateOptions({
series: datas,
chart: {
toolbar: {
show: showToolbar
},
animations: {
enabled: false
},
type: 'bar'
},
plotOptions: {
bar: {
horizontal: false,
columnWidth: '50%',
endingShape: 'rounded'
}
},
stroke: {
show: true,
width: 2,
colors: ['transparent']
},
xaxis: {
title: {
text: 'Masse'
},
categories: categories//,
//tickAmount: 10
},
yaxis: {
labels: {
formatter: function (value) {
//var ex;
return value.toExponential();
//return value;
}
},
title: {
text: unit
},
tickAmount: 10
//min: min,
//max: max,
//decimalsInFloat: 3
},
grid: {
padding: {
left: 50,
right: 50
}
},
legend: {
show: true,
position: 'bottom',
horizontalAlign: 'left',
showForSingleSeries: true,
showForNullSeries: true,
showForZeroSeries: true
},
})
I found the problem !
When you have log values really small (like 5.32E-9), the logarithm option doesnt work if you try to display the legend thrue a JS function.
So multiply by 1E10 the divide into the JS function (where you display the legend) by 1E10.
I have issue with highcharts spline chart. The problem is that on chrome browser animation is not smooth, on other browsers animation works well.
So the question is, what can be problem that Chrome is not processing graph as it should.
$(function () {
history_points_graph = new Highcharts.Chart({
chart: {
renderTo: 'container',
animation: true,
type: 'spline',
events: {
load: function(){
//history_points_graph = this;
//applyFilterGraph_1(1,1);
}
}
},
title: {
text: null
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000
},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2
},
legend: {
enabled: false
},
plotOptions: {
area: {
marker: {
radius: 2
},
lineWidth: 4,
states: {
hover: {
lineWidth: 3
}
}
}
},
series: [{
name: 'Random data',
dataGrouping:false,
enableMouseTracking:false,
animation:{
duration:1000
},
data: [[1096063200,524],[1285624800,429]]
}]
});
});
How can I resolve this ?
I had issue with transition on Chrome. Simply the page where I load graph I added css code.
*{-webkit-transition: all 0ms ease !important; transition: all 0ms ease!important;}
Has anyone ever tried to insert another chart with completely different data to the tooltip which is popping up when hovering over data points?
I have checked the possibilty to pass html to the formatter, but not sure how dynamically this is working.
I have a bubble chart and it would be perfect to add small line charts to the tooltips of the bubbles.
Yes, it is possible.
If you set tooltip's useHTML to true and create a chart in it, then you will get a chart in a tooltip.
Example: http://jsfiddle.net/n9z7r5uj/
$(function() {
$('#container').highcharts({
series: [{
type: 'bubble',
data: [[1,2,3],[4,1,6],[2,3,9]]
}],
tooltip: {
useHTML: true,
pointFormatter: function() {
var data = [this.x, this.y, this.z];
setTimeout(function() {
$('#chart').highcharts({
title: {
text: ''
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
animation: false,
data: data
}],
yAxis: {
title: ''
},
xAxis: {
categories: ['x','y','z']
}
});
}, 0);
return '<div id="chart" style="width: 100px; height: 150px;"></div>';
}
}
});
});
I'm trying to create a chart using CanvasJS but I'm getting the following error:
Uncaught TypeError: b[a].render is not a function
w.render # canvasjs.min.js:84
Aa.Chart.render # canvasjs.min.js:412
window.onload # statistics:107
The code is the example code found on their website:
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Number of Students in Each Room"
},
axisX:{
title: "Rooms"
},
axisY:{
title: "percentage"
},
data: [
{
type: "stackedColumn100",
legendText: "Boys",
showInLegend: "true",
indexLabel: "#percent %",
indexLabelPlacement: "inside",
indexLabelFontColor: "white",
dataPoints: [
{ y: 40, label: "Cafeteria"},
{ y: 10, label: "Lounge" },
{ y: 72, label: "Games Room" },
{ y: 30, label: "Lecture Hall" },
{ y: 21, label: "Library"}
]
},
{
type: "stackedColumn100",
legendText: "Girls",
showInLegend: "true",
indexLabel: "#percent %",
indexLabelPlacement: "inside",
indexLabelFontColor: "white",
dataPoints: [
{ y: 20, label: "Cafeteria"},
{ y: 14, label: "Lounge" },
{ y: 40, label: "Games Room" },
{ y: 43, label: "Lecture Hall" },
{ y: 17, label: "Library"}
]
}
]
});
chart.render();
}
</script>
<script type="text/javascript" src="/assets/script/canvasjs.min.js"></script></head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>
</html>
I've tried the same code on my machine and it's working fine, but when I upload it to my server, then I'm getting the previously mentioned error.
Does anyone has any idea what is wrong here?
Thanks!
The issue is a bug in Canvas.js - they are using "for...in" to iterate over an array, but if any other Javascript has extended the Array prototype they mistakenly assume the array is non-empty and you get the error (see Why is using "for...in" with array iteration a bad idea? for a discussion about this type of problem).
See my bug report: http://canvasjs.com/forums/topic/canvas-js-javascript-bug/ and fiddle reproducing this: http://jsfiddle.net/QwZuf/298/
If you're willing to use the non-minified code temporarily, you can patch this yourself by using "canvasjs.js" and locating the following (line 2406 in 1.7.0 GA):
for (index in plotAreaElements) {
plotAreaElements[index].render();
}
Wrap it in a simple length test and you should be fine until an official patch is available:
if (plotAreaElements.length > 0) {
for (index in plotAreaElements) {
plotAreaElements[index].render();
}
}
Edit: per the comment below, this bug has now been officially patched.
The tooltip in my Highchart is behaving strangely. It is living its own life. It doesn't show the tooltip of the point on which I hover, but shows the tooltip of any point randomly.
Here is a JSFiddle example: http://jsfiddle.net/AeV7h/9/
$(function () {
var data=[[28,0],[24,3],[16,10]];
var param= { WodTag: "cur_spd", Name: "Current speed", Color: "#C6C6C6", LineStyle: "Solid", SeriesType: "line", LineWidth: 2, TickInterval: null, MinValue: null, MaxValue: null, Decimals: 2 };
$('#container').highcharts({
chart: {
height: 700,
width: 400,
plotBorderWidth: 1,
plotBorderColor: '#E4E4E4',
},
xAxis: {
title: {
useHTML: true,
text: param.Name + "( m/s )",
},
gridLineWidth: 1,
min: param.MinValue,
max: param.MaxValue,
gridLineDashStyle: 'Dot',
tickInterval: param.TickInterval
},
yAxis: {
title: {
text: 'Depth(m)',
},
reversed: true,
tickLength: 50,
gridLineDashStyle: 'Dot'
},
title: {
text: null,
},
legend: {
enabled: false
},
credits: {
enabled: false
},
tooltip: {
useHTML: true,
formatter: function () {
return this.y;
}
},
series: [{
name: param.Name,
data: data,
color: param.Color,
dashStyle: param.LineStyle,
lineWidth: param.LineWidth,
type: "line"
}]
});
});
Can anyone help and tell me why it is behaving like this, and how I can fix it?
Your problem is that your data is not sorted by increasing X value. If you read the Series.data documentation it says that (API):
Note data must be sorted by X in order for the tooltip positioning and data grouping to work.
You should always sort your data like this before handing it over to Highcharts. Highcharts doesn't sort any data. Doing it by hand for your example your data should look like this:
var data=[[16,10],[24,3],[28,0]];
As in this JSFiddle demonstration, and everything works as intended.