Custom JSON file doesn't work with Highcharts - json

I'm very new to HighCharts and have a question about integrating JSON files.
I'm attempting to call a JSON file for my HighCharts file, however when I attempt to call it, the chart breaks and nothing is displayed. I am using the base Highcharts code in order to do this.
Here is my JSON input file that I am trying to use:
[
[Date.UTC(2012,00,01),2],
[Date.UTC(2012,00,02),6],
[Date.UTC(2012,00,03),4],
[Date.UTC(2012,00,04),0],
[Date.UTC(2012,00,05),2],
[Date.UTC(2012,00,06),3],
[Date.UTC(2012,00,07),1],
[Date.UTC(2012,00,08),3],
[Date.UTC(2012,00,09),7],
[Date.UTC(2012,00,10),8]
]
I have found other examples which say that it would be better to create an array with the data in it and put it into the JS file, and while that may work now it won't be feasible in the future as the chart will eventually have to reference large JSON files that will be stored in another directory.
Here's a link to the JSFiddle that references the outside JSON file. Any help would be appreciated.

Related

What would be the best way to write JSON in a locally stored file in React Native

Im currently working on a new design for a mobile app (only frontend). In the project I need to use states to change the css of a button. If the button has changed, next time the app is refreshed the state should be as you left it.
That is why I have a locally stored JSON file that is structured the same as how the apps current database is. Reading it is no issue, but I can't get the writing to work.
How I read the JSON:
const jsonData = require('../data.json')
function GetBaseState(id){
console.log(jsonData.bases[id].state)
}
How would I go about changing that state in the JSON file?
In order to both of reading and writing Json file , you are able to use react-native-fs. For example by readFile method you can read json file and by writeFile method writing your json file in local storage.
react-native-fs have good documents that you are able to reading that for more information and usage.

How can I use any json or array or any js file in .testcaferc.json?

I have created one file .testcaferc.json that contains all configuration information like browser name, specs, timeouts etc. I want to fetch the configuration data from file so that I have to change the information at only one place
I want to store all these information in single file, I tried, js, json and array. But I can not import all above format files in my .testcaferc.json, when I press Alt+F8 I see the error "Expected a JSON object, array or literal"
Is there any way I can import json, array or js data in .testcaferc.json?
Thanks in advance!!
The JSON format doesn't support any import directives. The TestCafe configuration file (.testcaferc.json) is a simple JSON file. So, the TestCafe configuration file doesn't support such functionality.
To achieve your goal, you can transform the existing .testcaferc.json file before test running: load data from various sources and add/replace values for the appropriate data fields.
Also, there is a suggestion in the TestCafe GitHub repository, which will make your scenario easier to implement. Track it to be notified about its progress.

Add a new data in .JSON file using angularJS

I am new in angular JS. I find it quite difficult to push an object in my data.JSON file. I've read data from my .JSON file using $http.get. Is it possible to write data using $http.post? Please help me with the solution. Thanks in advance.

Google Charts using JSON (without Webserver!)

So I want to create a chart using Google Chart API. The problem is following:
I need to create a chart which would use JSON data for the Output.
Example:
I am creating a BarChart which should show Montly Income. Each bar should represent X value of income. But this income changes monthly and I dont want to update the new numbers (as there are plenty) manually by writting them inside the JSON structure (I will use PERL scripts that will gather the new data).
I have read plenty on ther web, but all are using JSON COMBINED WITH PHP ! But I do not have a Web Server. What I want is to create a JSON FOLDER on my desktop, which will contain 100 JSON files inside it.
And when I browse my HTML page, I will click on Monthly Income (May) and this should open a new HTML page which should have some sort of INCLUDE or call function, which should call a SPECIFIC JSON file from the JSON folder on my computer that is coresponded with the path I have chosen on my webpage (in this case Monthly income (May)).
I think my problem is MORE SIMPLE than the method with PHP updating, because I am not worried with the updates - I will update my text files with PERL script. I just need a way, how to include a JSON file into my HTML script, without using PHP or any of these WEB SERVER related stuff.
Any ideas / suggestion ?
Thanks,
David
You can't reliably do it cross-browser with JSON because some browsers block ajax calls from local files (e.g., file:// URLs). But you can do it with JSON-P.
You create the files like this:
dataCallback(/*...JSON here...*/)
E.g.:
dataCallback({
"foo": "bar"
});
...and use this to load the relevant:
<script>
function dataCallback(data) {
// Here, the data will be the deserialized (parsed) data
}
</script>
<script src="/path/to/jsonp/file"></script>
Basically this is using JavaScript, rather than JSON, but where the data file although technically code is really just a function call with the data in the argument.

JSON format for Three.JS

I have a problem with JSON format.
I am going to generate a 2D building plan in JSON format automatically. Then this JSON file is loaded to Three.JS for visualization.
Currently, I can easily create various geometry type in JSON format based on:
https://github.com/mrdoob/three.js/wiki/JSON-Model-format-3.1
However, I need to know more about this data format.
Firstly, how can I add text to the model?
Secondly, I could not find line as a geometry in this format. Is there?
Thirdly, is there any document that I can refer to it for more explanation regarding this
format?
Lastly, how can I add additional information about geometries
inside the JSON format? for example when I create a polygon in JSON
format, I want to add additional information regarding that polygon
such as area, owner,...
Either through a texture, or by creating THREE.TextGeometry and merging that with the other geometry
AFAIK, no. You might be able to emulate lines by loading a separate object that you render as wireframe.
I've used the source code: Loader, JSONLoader
I don't think that's possible while maintaining compatibility, i.e. you would need to patch Three.js loader.
One option for achieving what you want could be to add custom entries to the JSON, e.g. "lines": [], "customFaceProperties": [] and then parse them yourself once the stock Loader has parsed everything it understands.
Also, since it seems you might be creating something that has different things in it, you might want to take a peek at the scene loading capabilities: example, SceneLoader.js