Jump to content
JChartFX Community

Tinman

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Tinman

  1. I am using the code from here: http://www.jchartfx.com/demo/64983802-edb8-e211-84a5-0019b9e6b500 This is working perfectly fine with my own data, but I have set of buttons that will send an AJAX request to a data file and get a response that should update the charts, but it does not seem to update properly. The chart code is more or less exactly the same as your example (I am just testing things to see if it works before I put time into it) The below code is what happens when the one of the buttons are pressed (jquery) function data_send(var1,event) { event.preventDefault(); $.post("graph_data.php", { company: var1, dataType : "json", }) .done(function(result) { if(!result) { return; } ChartWhole.setDataSource(result.d); ChartWhole.getDataSourceSettings().reloadData(); ChartDetail.setDataSource(result.d); ChartDetail.getDataSourceSettings().reloadData(); }); }; I tried using many variations of the bold code, but the charts do not want to update, the response from the request comes through (checks out with FireBug) In a format like this, which is exactly the same format (not exactly the same values, it is the correct values) that shows on page load. [{"Open":167,"Date":"2013-10-02T16:45:05.000Z"},{"Open":163,"Date":"2013-10-03T23:30:05.000Z"},{"Open":157,"Date":"2013-10-04T22:45:05.000Z"} The above data does not seem to then be loaded into the two charts properly, first I did not use the reloadData() at all, but then when using setDataSource() did not work I looked for other things that I might have to do so I added the reloadData() into the mix, though its still not doing anything, I have also tried using both setDataSource(result.d) and setDataSource(result) I would be very appriciative of a solution to this issue.
  2. Thanks! Would it be much work to move away from the jQuery UI stuff? Do I need different inclueds or wull the jChartFX Full cover it, it seems like going without jQuery UI would be my best option since I want to have more control over the looks of the charts and I also want to add that amazing Zoom ScrollBar and it seems there is only a No JS Framework, is that something I need to get or it that something built in? The example HTML code only shows a little part, and not what files would need to be included to make it work. Thanks again for your help, the chart is working wonderfully, it took me a long time to find a plugin that would work for my need, I was almost giving up hope on using JavaScript and was about to start work and a freaking PHP image generator
  3. ok, you got me thinking and I got it working by adding some php code into there, here is what I did For the variable it was really just one line of php code var items = <?php include 'graph_data.php' ?>; If I want to pass any variables to the data I can just add them like so var items = <?php $var = 'something'; include 'graph_data.php' ?>; Then in graph_data.php just have a call for $var and it shows up! On another note on the same code as above, how would I go about removing the title, or more specificly turn it "visible: false" like I can with the legend? Removing the line titles: [{ text: "Mapping Fields to chart elements"}], Just make as generic "Chart Title" appear there, but I would want the entire box gone so that its just the charts with the X values and Y values shown. Also how would I go about setting the Y value minimum to what is the lowest data value on the chart, it does the maximum fine, but the minimum is always 0, this is an issue if the values are between 4950 and 5000, you can barely see a change on the graph. Other then that, it displays beutifully and data updates fine, I have tried 8 other different chart software but they all seem to break when being loaded through an AJAX call, but this one actually works and has a very good load time and seems to not slow down systems like some of the others. (Sorry if this double posts, I tried to use the quick reply, but I dont think anything happened)
  4. You got me thinking and I solved the issue with a single line of php var items = <?php include 'graph_data.php';?>; It basically just included the php file content right there and its working! Now I have another question, using the same code as above, how would I go about disabling the Title? If I remove the "titles: [{ text: "Mapping Fields to chart elements"}]," it just displays a generic "Chart Title" I would just like it to be gone, I have been looking around and I can not seem to find anything that works.
  5. So I am trying to load data from a PHP file that prints out JSON data, I am using the code I found on an example (with some modifications, but it still displays the static data fine) <html> <head> <title>jChartFX using JQueryUI</title> <style type="text/css"> #targetchart { width: 608px; height: 408px; padding: 4px; border: 1px solid #dddddd; background: #eeeeee } #targetchart h3 { text-align: center; margin: 0; } </style> <link type="text/css" href="http://www.jchartfx.com/resources/Include/cupertino/jquery-ui-1.8.21.custom.css" rel="Stylesheet" /> <script type="text/javascript" src="http://www.jchartfx.com/scripts/jquery-1.7.1.js"></script> <script type="text/javascript" src="http://www.jchartfx.com/scripts/jquery-ui-1.8.18.custom.min.js"></script> <script type="text/javascript" src="http://www.jchartfx.com/jChartFX/7.0.4728.16930/jchartfx.full.js"></script> </head> <body> <div class="ChartDiv1" id="targetchart" style="display:inline-block"> <div id="myDiv" style="width:100%;height:100%;display:inline-block"> </div> </div> <script language="javascript" type="text/javascript"> var chart1; $(document).ready(function ($) { var items = [ { "Open": 24.2, "Date": "2003-03-01T23:45:10.280Z" }, { "Open": 21.3, "Date": "2003-03-02T23:45:10.280Z" }, { "Open": 22.4, "Date": "2003-03-03T23:45:10.280Z" }, { "Open": 24.3, "Date": "2003-03-04T23:45:10.280Z" }, { "Open": 22.6, "Date": "2003-03-05T23:45:10.280Z" } ]; $("div", ".ChartDiv1").chart({ gallery: cfx.Gallery.Bar, dataValues: items, dataSourceSettings: { fields: [{ name: "Open", usage: cfx.FieldUsage.Value }, { name: "Date", usage: cfx.FieldUsage.XValue}] }, titles: [{ text: "Mapping Fields to chart elements"}], axisY:{ min:0, max:30 } }); }); </script> </body> </html> Now instead of var items being static data, I would want it to be the data generated from my php file, the php file outputs this when run: [{"Open":626,"Date":"2013-09-27 14:30:06"},{"Open":615,"Date":"2013-09-27 15:45:05"},{"Open":604,"Date":"2013-09-27 17:45:05"},{"Open":593,"Date":"2013-09-27 20:00:05"},{"Open":588,"Date":"2013-09-27 22:00:06"},{"Open":583,"Date":"2013-09-28 00:00:02"},{"Open":573,"Date":"2013-09-28 02:00:07"},{"Open":568,"Date":"2013-09-28 04:00:05"},{"Open":558,"Date":"2013-09-28 06:00:05"},{"Open":548,"Date":"2013-09-28 08:00:05"},{"Open":544,"Date":"2013-09-28 08:45:07"},{"Open":534,"Date":"2013-09-28 11:00:27"},{"Open":525,"Date":"2013-09-28 13:00:03"},{"Open":517,"Date":"2013-09-28 15:00:02"},{"Open":508,"Date":"2013-09-28 17:00:02"},{"Open":504,"Date":"2013-09-28 19:00:02"},{"Open":500,"Date":"2013-09-28 21:00:02"},{"Open":496,"Date":"2013-09-28 23:00:02"}] (and may contain more or less data, but all in correct format) If I copy this data into the items variable it displays fine, but if I try something like this (replacing the current item variable code): var items; $.get('data.php', function (response) { items = response; }); It does not display anything, it seems like it fails to render entierly. How would I go about making the items variable the same as whatever data.php is outputting?
×
×
  • Create New...