I'm new to Flot, so my understanding of ticks is the number of columns that flot will draw on the chart.
As my labels are quite long, having 6 ticks fits nicely. But most times, it just exceeds the number I set, and that screws up the labels.
I assume this has to do with Flot's algorithm? Is there any way I can fix it to 6 columns?
A simplet of how I set it.
xaxis: { mode: 'time', timeformat: "%y/%m/%d %H:%M:%S", tick:6 },
The ticks option is a guideline. Flot tries to match that value, but its first priority is to choose 'round' values, i.e. 5:00 instead of 5:01.
There are several ways to work around this, depending on your data. The guaranteed solution is to calculate your six tick values manually, and provide them to Flot in the 'ticks' array option. Besides that, you may be able to coax Flot into generating the correct number of ticks by adjusting the minTickSize and axis min/max.
Related
How do I get the chart pictured below to use labels 1000, 6000, 11000, and so on on the X-axis, rather than 1001, 6001, 11001 and so on? This is a general question not specific to this chart. I've experienced this problem with any single chart I created over the last 20 years.
It didn't bother me a lot before, but now that I am working on producing high quality visualizations, it has become an eyesore big enough to bother me. I hope there is a simple workaround.
Excel chart:
Simply select the respective axis -> right-click -> Format Axis...
Then adjust the bounds as required to e.g., Minimum: 1,000 and Maximum: 6,000, and the Major units to 5,000 (step-size). You could also change the Minor units but you do not use tick marks anyways. In effect, adjusting these parameters you can adjust the format of the axis to exactly fit you needs.
EDIT: Further explanation based on the comment
You need to explicitly select the x-axis by clicking on it so that it is highlighted as shown below (not the yellow part of course):
If this does not work, you can also select the x-axis in the following way; assuming you are able to adjust the y-axis as mentioned in your comment. Select the y-axis -> right click -> Format Axis....
Inside Format Axis you need to select Axis Options and select Horizontal (Value) Axis:
I'm trying to tailor the chart above to take up as little vertical space as possible. It is a line chart showing binary data (1 or 0 for door open or closed), but it seems to force me to have the decimal ticks between the two values, even thought every point's y-axis value is 1 or 0 as integers. Ideally it would be no taller than the width of the y-axis label.
Is this possible? I've tried various things to do with the container, removing y-axis ticks etc, but I'm struggling to get it more compact than this.
UPDATE:
I've managed to get rid of the decimal ticks with config from these docs. Still no luck on the height...is there an undocumented minimum or something?
Per this question, the answer is to set a fixed height on the chart canvas.
Fix the height of Y-Axis of Bar chart in chart.js?
After a couple hours of work I come to you guys with this graphing problem. I need to create a Milestone-Trend-Analysis which can be seen on the german wikipedia , though not in the english version.
General Information
In short, the diagram has report dates on the x-axis (for now, on every first of the month, another report is due).
The y-axis should mirror the x-axis completely. In length and also the tickmarks. The dates get bigger from the bottom to the top.
In my case the x-Axis is on top of the diagram.
Every report consists of a number of "due-dates", one for each assignement in progress. They are the estimated "finishing dates" of that particular assignement.
If the estimated finishing date stays the same in the next report period, the graph for that assignement stays on the same level. If the estimate is earlier, the graph trends down. Normally they go up, since the assignement has some delay :-D
The x-axis needs to be dynamic, since the whole project is basically finished when its last assignement is finished. If one of the assignements is running late, the whole project gets delayed an thus the x-axis needs to be longer/get more ticks.
Since the y-Axis mirrors that, it has to change too.
MY PROBLEM
The x-axis has a number of discreet values, since the reports come in every month, or every two weeks. But that does not change.
The values for the finishing dates are continuous, since the assignements can be terminated whenever.
That leaves me with the problem of having to cut the y-axis in equal-size chunks, although the months of the year are not equal in size. At least that is, what I think excel forces me to do.
I can assign a max limit and a min limit for the y-axis and I can assign a distance between each main tickmark. Since Excel works with a continous number for each date, the 2014/01/01 would be 41640. And 2015/01/01 is 42005. Since I have 12 month on the x-axis and I need 12 on the y axis, I would have to have the main Ticks at a distance of 30.42 ... which gives me the following Months on my axis
January January March .... December December
Does anyone know an answer for this? Is there a way to have excel make the tickmarks on the y-axis not equal distance?
Any input greatly appreciated.
Kaz
I did not find a way to make Excel have variable tick mark distances. But since I coud not have it that way, I had to make the month equally long.
This works for me now:
'calculate the norm for different type of month including Schaltjahr
Select Case cellMonth
'February
Case 2
'Schaltjahr and Schaltjahrhundert
If (cellYear Mod 4 = 0) Or (cellYear Mod 400 = 0) Then
resultDay = (30 / 29) * cellDay
Else
resultDay = (30 / 28) * cellDay
End If
'31 day months
Case 1, 3, 5, 7, 8, 10, 12
resultDay = (30 / 31) * cellDay
'30 day months
Case Else
resultDay = cellDay
End Select
Now I just have to scale the axis to numberOfMonths * 30. It now leaves adjusting the names of the y-Axis, which seems to be a whole different story.
Kaz
You can put arbitrary labels along the Y axis by adding a dummy XY series.
Here is some data that I think captures your issue, plus a line chart showing the data, plus the data that I'll use to construct a dummy Y axis.
I used a line chart so the X axis at least would be easy. You just have to make sure that the axis is formatted as a date axis with Base Unit of Days.
Here is how I built the axis.
Top Left Chart Below: I copied the dummy axis data, both columns of the data includingt the header row. I selected the chart, and used Paste Special to add the data as a new series, data in columns, series names in first row, categories in first column (but don't replace existing categories).
Top Right Chart Below: I right-clicked on the added series, clicked on Change Series Chart Type, and selected XY Scatter with Lines and Markers. Excel also put this series onto the secondary axes.
Middle Left Chart Below: I formatted the added series to be plotted on the Primary axis.
Middle Right Chart Below: I changed the scale of the vertical axis, giving it a minimum of the first date and a maximum of the last (1/1/16 to 9/1/16).
Bottom Left Chart Below: I formatted the vertical axis to show no labels.
Bottom Right Chart Below: Format format format. I formatted the dummy axis series so it used light gary lines (matching the horizontal axis) and light gray cross markers (simulating tickmarks). I changed the tickmarks of the horizontal axis so they crossed the axis, matching the cross markers of the dummy series. I added data labels to the left of the dummy series points, simulating vertical axis labels.
The xaxis in my flot line charts can take an array of data up to but no more than 16 in length. The problem is when my data is less than 16, the x axis is spreading out to show the maximum value of whatever the length of the data array is.
Even if my data is say 4 in length, i'd still like to show 16 points on the xaxis.
I have tried various configs and nothing seems to be working :(
http://www.discussthemarket.com/ratings/
The graphs lower down have an x axis greater than the graphs nearer the top which have fewer items in the data. I'd like to consistently apply a fixed length of 16 to the x axis but am really struggling.
One possibility is to provide a number for the ticks option:
ticks: 16
However that is treated only as a guideline; Flot always tries to make the ticks fit, and will reduce the number when it detects that they would overlap or run off the side of the plot. If you really want to force it to use 16 (which I wouldn't recommend, since the labels will probably overlap) you'll need to manually provide an array of ticks:
ticks: [0, 5, 10, ...]
I've cracked it byadding another data set which is 16 in length but has lines:{show:false} set :) job done!
You can use minTickSize according to the documentation of flot.
minTickSize : [1, "day"],
I have 3 columns of data, eg:
http://i.stack.imgur.com/XjGmu.jpg
When Excel creates a line graph of this, the blue line is what i get.
This is not correct because the time stamp shows the time when something is switched on (255) or off (0) (could also be the current state eg 16:08). So I'd like a graph like this - see the red line (with a time-based X axis off course):
http://i.stack.imgur.com/vNvPk.jpg
Anyone can help? Thanks
As #Jon49 indicated, you need to plot additional data points--two y values for each x value: one to plot the point at y=255 and one to plot y=0.
If the time-span of the data is at least a few days, you can use a line chart. But in your case since the values are within a day, the scatter chart with straight lines is the only option due to the limitations of the scale units for line charts.
The key is the values need to be in the correct order. Each y=255 value needs to be followed by the next time-stamp's 255 value followed by it's 0 value, followed by the next time-stamp's 0 value:
Excel doesn't support this type of discrete value graph (at least not excel 2k3 that I am using); your best bet is to use a bar graph and then go into the settings and set the gap width down to zero.
Not sure what the best way is but I would automate what I describe below on how to do (unless this is a one time deal, then just brute force it):
Separate the 255s from the 0s. Make sure for every 0 time there is a corresponding 255 time. Take the zero times and put in a scatter plot then add a y-error bar and make the fixed value equal to 255. Format to how you like it.
Now for the 255s. Add those to the chart by pairs. Make the chart type for these pairs scatter plot with a line. Format how you would like them to look.
Let me know if that doesn't make sense to you.