flot

plotting Graph with flot

牧云@^-^@ 提交于 2019-12-06 15:04:57
I want to plot graph using flot and mysql but an exception occurs getData.php $sql = mysql_query("SELECT count(Msg_ID) as msgCount,From_user FROM Messages GROUP BY From_user"); echo "["; while($result = mysql_fetch_array($sql)) { //print_r($result); echo "[".$result['msgCount'].",".$result['From_user']."]"."\n"; } echo "]"; And for plotting <div id="plotarea" style="width:600px;height:300px;"> <script type="text/javascript"> var options = { lines: { show: true }, points: { show: true }, xaxis: { min:0,max:5 }, yaxis: { min:1 ,max:60}, }; $.ajax({ url:"getData.php", type:"post", success

Flot: Zoom to Far Right by Default

不想你离开。 提交于 2019-12-06 11:26:39
Let's say you have a flot graph that's 500 pixels wide and it has 100 ticks on the x axis. That will obviously be very crowded by default. The "navigate" plugin helps this situation. For example, if you want to limit it to only 10 ticks at once, you can do this: $.plot(...).zoom({'amount': total_ticks / 10}); However, I'm not sure how to make it so that when the graph is first drawn, it is showing the last ten (the ten on the far right) by default, not just a random set of ten from the middle. Also, although the example I gave assumes there are 100 ticks, I won't actually know the number

Displaying graphs using Django-graphos

≯℡__Kan透↙ 提交于 2019-12-06 05:52:53
I am having problem while displaying graphs with django-graphos . I have tried according to the documentation.its not showing the site names in the x-axis and also no plots on the graph : my code : models.py class MonthlySiteResponse(models.Model): site_name = models.CharField(max_length=30) response_time = models.FloatField() views.py def fn(request) : site_response_details = {'Site A' : 1.864, 'Site B' : 2.086, 'Site C' : 2.873, 'Site D' : 2.22 } #Saving data in my model fields for name, value in site_response.items() : new = MonthlySiteResponse() new.site_name = name new.response_time =

how to draw multiple bar charts grouped by category with flot js

若如初见. 提交于 2019-12-06 05:47:05
I'm using flot library to display a bar charts and I need to group by certain value in this way: | | +----+ +----+ | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | | | | | | | | | | | |-+----+---+----+--------+----+---- val 1 val2 val3 category #1 category #2 Thanks Sergey G. for the Ascii :) I have the variables d1, d2, d3 to the values ​​of the bars 1, 2 and 3 respectively (sorted by category). The question is: How do I add the category below ticks? Sorry for my bad "Google-Translator" English and thank you very much! Code: $.plot( $("#placeholder"), [ { label: labelChart

How to check if JSON array is equal to

家住魔仙堡 提交于 2019-12-06 01:28:09
I am creating pie charts with JSON and Flot. The JS function to create the pie chart receives a JSON array from Django in this format: [1, 3, 2, 5, 4] If there is no data, the JSON array is: [0, 0, 0, 0, 0] I'm trying to adjust the function so that if there is no data, then the pie will not be plotted and some text will appear instead (e.g. "Nothing to show yet"). So far I have tried: function loadWeekChart(theData) { var blankData = [0, 0, 0, 0, 0]; if ($.data(theData) == $.data(blankData)){ $('#week-pie-chart').empty().append('Nothing to show yet'); } else { $.plot($("#week-pie-chart"),

Flot: How to keep x and y axes the same scale?

非 Y 不嫁゛ 提交于 2019-12-05 18:28:43
I want to plot on a standard Cartesian plane, so 1 unit on x axis has the same length as 1 unit on y axis. I also use the navigate plugin to zoom and pan. Is there anyway I can have this constraint? can't find anything about this in Flot api. Thanks, I had to do something similar and this was the first test: fiddle The main point is that you set the max values for the axis in the same ratio as the width and height of your placeholder div: options.xaxes[0].max = options.yaxes[0].max * $('#ph').width() / $('#ph').height(); $.plot($('#ph'), data, options); 来源: https://stackoverflow.com/questions

Flot reset zoom

你。 提交于 2019-12-05 17:42:15
I'm using Flot Charts with mouse scroll to zoom in and out. I created a button to call zoomOut() and it works well, but I can't find any solution to how I can zoom out all the way so that it Looks just like when it was first loaded. I don't want to reload that who container because it using ajax to pull data from mysql on refresh. I Googled but couldn't find anything. You can save your initial ranges of axes and redraw your plot like in example for navigating. But your code will be look like these: // do the zooming plotObjectPointer = $.plot(placeholder, plotData, $.extend(true, {}, options,

Comma Separated Numbers For an Axis in Flot

梦想的初衷 提交于 2019-12-05 15:32:18
问题 Is there a way to have Flot make axis numbers be comma-separated? So for example, instead of 1000000 have 1,000,000 回答1: You can do that by using the tickFormatter property of the axis. xaxis: { tickFormatter: function(val, axis) { // insert comma logic here and return the string } } Source: http://people.iola.dk/olau/flot/API.txt (under "Customizing the axes") This page has a function to format numbers with commas: http://www.mredkj.com/javascript/nfbasic.html For Example on the yaxis: $

Flot graph does not render when parent container is hidden

我的未来我决定 提交于 2019-12-05 15:13:12
问题 I was having an issue where a flot graph would not render in a tabbed interface because the placeholder divs were children of divs with 'display: none'. The axes would be displayed, but no graph content. I wrote the javascript function below as a wrapper for the plot function in order to solve this issue. It might be useful for others doing something similar. function safePlot(placeholderDiv, data, options){ // Move the graph place holder to the hidden loader // div to render var

How can I make JsonResult return an array of arrays (without field names) rather than an array of objects?

我的未来我决定 提交于 2019-12-05 13:12:32
I have an IEnumerable list of date/value pairs that I am returning as a Json list to flot. However, when I call JsonResult(), the result looks like this: [{"Date":date1, "Value":value1}, {"Date":date2, "Value":value2}...] Flot is expecting [[date1, value1], [date2, value2]...] Is there any simple way to get the MVC framework to output objects like this or do I need to write my own seralizer / StringBuffer code? For that matter I don't even need to output the field names, just the values themselves. It sounds like you just need to return a string like this: var builder = new StringBuilder();