I'm using the Grid component in fusion charts and need a date string to be used in the value place. It will always fail when i do this as it is looking for a number. Is there anyway it can allow text to be used aswell?
Thanks
The ability to have date-time axis values is not yet available in FusionCharts. Nevertheless, the use case for you does not fit right.
Ideally, the grid component's right column should show a number (value). The left column is text showing the labels. For a grid, it makes very less sense to have text on both columns.
Instead of a date, the right column should show how many month's or days or hours, etc.
Excerpts from FusionCharts documentation: http://docs.fusioncharts.com/charts/contents/advanced/number-format/Number_Scaling.html
Say we're plotting a chart which indicates the time taken by a list of automated processes. Each process in the list can take time ranging from a few seconds to few days. And we've the data for each process in seconds itself. Now, if we were to show all the data on the chart in seconds only, it won't appear too legible. What we can do is build a scale indicating time and then specify it to the chart. This scale, in human terms, would look something as under:
60 seconds = 1 minute
60 minute = 1 hr
24 hrs = 1 day
7 days = 1 week
Now, to convert this scale into FusionCharts XML format, you'll have to do it as under:
First you would need to define the unit of the data which you're providing. Like, in this example, you're providing all data in seconds. So, default number scale would be represented in seconds. We can represent it as <chart defaultNumberScale='s' ...>
Next, we define our own scale for the chart as: <chart numberScaleValue='60,60,24,7' numberScaleUnit='min,hr,day,wk' >. If you carefully see this and match it with our range, you'll find that whatever numeric figures are present on the left hand side of the range is put in numberScaleValue and whatever units are present on the right side of the scale has been put under numberScaleUnit - all separated by commas.
Set the chart formatting flags to on as: <chart formatNumber='1' formatNumberScale='1' ...>
The entire XML would look like:
<chart defaultNumberScale='s' numberScaleValue='60,60,24,7' numberScaleUnit='min,hr,day,wk'><set label='A' value='38' /><set label='B' value='150' /><set label='C' value='11050' /><set label='D' value='334345' /><set label='E' value='1334345' /></chart>
A sample grid (not with the above data) would look like this:
Related
I am having an issue with saving a PDF file from PHPExcel and it creating widow/orphans with my data.
I know of the function to create page breaks,
$objPHPExcel->getActiveSheet()->setBreak( 'A10' , PHPExcel_Worksheet::BREAK_ROW );
but I would like to know if there is a function to know the current height of a range of cells.
I have found references to "getRowDimension" in functions like
$objPHPExcel->getActiveSheet()->getRowDimension('10')->setRowHeight(100);
but I cannot find any documentation on that function. Does anyone know if it can calculate the height of the chosen row and/or take a range of rows?
Also, is there a function to calculate the usable space between the header and footer of each page? Or should I calculate that from the page margin?
Thank you,
Nick
$objPHPExcel->getActiveSheet()
->getRowDimension('10')
->getRowHeight();
Will return the row height for the specified row. This is the height in "points", where 1 point is the equivalent of about 1/72 of an inch (or about 0.35mm). A value of 0 indicates a hidden row; while a value of -1 is the default value, which is 12.75pt (about 1/6 of an inch).
The PHPExcel_Shared_Drawing class contains a number of functions for converting between points and other units of measure, such as pointsToPixels() and pixelsToPoints(), and pixelsToEMU() and EMUToPixels() (English Metric Units).
The whole issue of Microsoft's units of measure is really a confusing minefield, but there's a useful blog post here discussing the different units of measure use in MS Office
This question might be similar to others but is a bit different. Let's say we have a set of intervals that goes like this let's say A-9 are numbers but for the sake of formatting I used letters):
<-a---> <------c--->
<------------MAIN>
ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
<--d-> <--b------->
So we have the Main interval which goes from I to Z, the interval a that goes from M to S and so on.
Now I want to have the intervals where I have the most overlaps WITHIN the main one (which is essentially the basic constraint) that would be M-O with (a and d) and Q-S (a and b) and U-Z (b and c) with 2 overlaps each (everything beyond Z is out of the question because it is outside the main interval
I essentially want a list (aka array) of the intervals and the number of overlaps inside the Main, while not counting the main into that number (sorting not needed there are enough ways to do this) in PHP.
I thought of making a picture of the intervals and then counting the colors for each pixel column but that's
averting the problem
inefficient
probably pretty slow
so, TLDR, I need a solution that
works in PHP
is relatively fast
is reliable
gives you the overlapping intervals with their overlap count
has a main interval used as base constraint which is not counted to the overlap.
I know it's a very specific question but I am not that well versed in Math and algorithms.
Build 2 vectors. One contains the start points and one contains the end points of each interval.
Sort the 2 vectors.
While you have something in any of the two vectors:
pick the minimum between the 2.
If you picked it from the vector with start points increment the number of overlapping intervals by 1, else decrease it by 1.
If your point is also the starting point of the main interval set a flag that you results are valid now.
If your point is the end point of the main interval you can stop.
If the flag is set then you can compare the current number of overlapping intervals with the max so far and update accordingly.
You can decrease 1 from the max to ignore the main interval. You can keep a list of sections where you have the max count (Just make sure you clear it when you getter a better result).
This is O(NlogN) with the number of intervals you have.
The basic algorithm for this is go over the whole length with a counter that increases when you meet a start point and decreases when you meet an end point.
Keep track of the maximum this counter gets to.
Go over the whole length again, this time add locations to your result array when:
1. You are within the MAIN part borders.
2. Your counter (which is maintained the same way) is equal to the maximum you calculated before.
I need to draw a line chart using PHP which fullfills the following requirements:
Textual X-Axis descriptors
Not every serie has values for all X-Axis values
Markers on the given points
I have already detailed watched pChart, JpGraph and LibChart, but I didn't manage to get the expected result. It should look like this (poorly drawn with MsPaint):
EDIT: The exact problems:
With Libchart, I didn't manage to get different series with not all x axis values filled
With pChart, there was the same problem (e.g. at the above example, pChart would not make a line at the blue series from desc 3 to desc 6, when values 4 and 5 have the value VOID). I could also calculate the values between, but then they would also have markers (e.g. at desc 4 and desc 5)
With JpGraph, I didn't manage to create textual x axis values
Thank you for your help, Community!
Found a solution using pChart:
I can use VOID for points which do not have an own value, and set a config setting like the following one:
$myPicture->drawLineChart(array('BreakVoid'=>false,'VoidTicks'=>0));
Using this settings, VOID will draw correct lines to the next known value.
I'm working on something that when a range filter is active, the range facets will update accordingly. If no filter is given, I'm using a default range & gap. If a filter is set I do a second solr call to recalculate the facet range gap.
So for example at first I show range facets of a gap of 10YEARS. When you filter one of those, it shows 10 range facets of 1YEAR. If you filter again, it'll show 12 buckets with a 1 month range etc...
It kind of works, but I'm having trouble when the range filter includes a *. Solr knows how to correctly filter results when solrfield:[1960-01-01T00:00:00Z TO *] is given, but I don't know how I recalculate the date range facet gaps based on *. Right now I calculate the difference between the two dates as a unix timestamp and calculate the range gap based on that.
Also, is there a name for what I'm trying to do here? I'd call it 'variable range gaps', but I'm not sure if that's correct.
I'm not even sure if what I'm doing is the best approach. Any advice is welcome.
Edit: what my question comes down to is: I would like to calculate difference (as unix timestamp) between the highest and lowest date of a field in every solr query.
Edit 2: Every solr call I do takes about 300ms (on a relatively small index). That's quite a bit in case I do 2 extra calls with a date sort to find the highest and lowest date value in the query. Then performing the 4th solr call with the correct date gap (and from/to values), would get a bit slow.
You can probably turn it into familiar "limited date range" case. If it is impossible for your data to have datetime set in the future, your can replace * with NOW always receiving the same resultset (as no date can be later than current moment) and calculate gaps basing on current timestamp.
I have some data of balances ($), dates, and memos. I want to plot this as a line graph. I was happily plotting away with http://www.maani.us/xml_charts/ until I realized that my x-axis was off: there aren't balances for every day, and sometimes there are multiple balances on a single day. How can I compensate for this (space out the dates appropriately)?. I tried using unix_timestamps for the dates so that it could have a numeric value, but this only works for scatter plots (and it sucks at that). The memos I want to appear as tooltips.
Are there any other libraries/APIs that can handle this? Will Fusion Charts do it? Basically I need a chart API that can handle numeric values for both the X and Y axis, but allows me to rename the X axis so it doesn't actually appear as numbers, and supports tooltips (ie is flash based).
Mark,
In FusionCharts scatter chart, we've numeric x and y axis. The good part is that the scatter chart can be made to behave like a line chart. You can connect the points of the scatter chart using a line by setting:
<dataset drawLine='1' ....>
So to show dates on the x-axis, do the following:
Set the value of the least date in your dataset as 0
For every other date, calculate the dateDiff(leastDate, days) and set that as the x-axis value.
Hope that helps...