In d3.js I can load a dataset and filter it on 'year'. This opproach gives me the possibility to calculate my d3 scales and vertical axis based on my complete dataset's max y value.
My aim is to get the graph to be visually comparable when changing view from one year to another. - With the same maxscale value, and the same relative vertical height per unit in the columns after reloading data for another year.
Do anybody know how to accomplish this in dimple.js?
Thanks :)
In the documentation there are some examples of what you're trying to achieve..
Namely, one in which the axis min and max settings are manually set..
// Setting min and max dates requires them to be set
// as actual javascript date objects
y.overrideMin = new Date("01/01/2000 9:00 am");
y.overrideMax = new Date("01/01/2000 6:00 pm");
In this case they are Time values for a day, which make sense not to change, but the same should apply.. But, you should give us some of your code examples for more specific answers.
So from chart change to chart change, you will retain the same Min & Max as the previous year.
Reference DimpleJS Advanced Time Axis
Related
I am writing an application for Windows 10 using Delphi 11 and Steema TeeChart pro 11 components.
I use AddXY(….) to plot a DateTime series of about 1000 values as points in Chart1 with BottomAxis set to DateTime and the Leftaxis set to float.
Thereafter I zoom in a small part of the data in Chart1 using the mouse wheel or drawing a rectangle.
Then I want to plot a new time series (AddXY(….)) of 1000 values in Chart1, keeping the zoomed in min and max values for the bottom axes, but use automatic scaling for LeftAxis. Before plotting the second series I delete the first.
The second series have the same DateTime values as the first series, but the Y values are sometimes very different compared with the first series and may not be visible in the graph.
Now the problem occurs. The Left axis will be automatic scaled based on all the data points and not on the points only falling within the zoomed X boundaries.
Does TChart have a simple method to find the min and max Y-values for the second series within the zoomed in time period. I thought of using the LeftAxis.AdjustMinMax() procedure for rescaling the left axis?
Of course I could scan through all the Y-values within the zoomed in period and calculate the min and max value. Then, how do I know the starting and ending valueindex of the data points falling within the zoomed in time period? I hoped to avoid using this method due to speed resons if number of points are > 1000.
Hopefully someone more experienced TeeChart programmer than I am can give me some suggestions of the best way to achieve this.
I am using dimple.v2.3.0 to create line and area chart. When creating chart with category x-axis, Dimple leaves a gap between the y-axis and the line/area. I would like to ask is there any way to remove the gap?
I'm afraid there isn't a good answer for this, it's done this way because dimple allows you to combine with bars etc. There is a time axis for dates which will not include the gap and therefore answers the majority of cases with area charts, however categorical axes will always have the gap.
There is a hacky workaround you can use in this case where you have integers on your x axis which is to treat them as dates and put them on a time axis:
var x = myChart.addTimeAxis("x", "Call", "%Y", "%-Y");
x.timePeriod = d3.timeYear;
x.timeInterval = 1;
This will parse and display your calls as years and display them on the time axis. The "%-Y" display format shows a 4 digit year with no leading zeroes. This will work for integers up to 9999. Here it is working in your fiddle:
https://jsfiddle.net/zuuaar1t/
I'm using DC.JS scatterplots to let users select points of interest. If you use elastic axis you cannot select the highest value point. Look at the DC.JS example (https://dc-js.github.io/dc.js/examples/scatter-brushing.html). You cannot select the highest point in the left or right plot.
In several cases, the highest or lowest point(s) is exactly what people need to be able to select because those are the outliers we care about. If you disable elastic axis and make sure you specify a range that is higher than the max value, you can select the point.
Is there another solution besides setting the axis domain based on current min/max and expanding them little bit? This is sometimes ugly when the minimum=0 and now your domain needs to include some small negative number.
--Nico
Always when I face this issue, I increase the y domain by 5% manually.
For instance:
var balanceDomain = d3.scale.linear().domain([0, s.balanceDimension.top(1)[0].balance + (s.balanceDimension.top(1)[0].balance*0.05)]);
s.amountOverallScore
.width(400)
.height(400)
.x(someDomain)
.y(balanceDomain)
...
Maybe this is not the best solution, but always work for me.
Hope it helps (=.
In my application the values were always positive and I used the following to get correct behavior:
// using reductio on the all_grp to get easy access to filtered min,max,avg,etc.
totalTimeMinValue = all_grp.top(1)[0].value.min;
totalTimeMaxValue = all_grp.top(1)[0].value.max;
// now use it to scale the charts we want
detail1_chart.y(d3.scale.linear().domain([totalTimeMinValue-1, totalTimeMaxValue+1]));
detail3_chart.y(d3.scale.linear().domain([totalTimeMinValue-1, totalTimeMaxValue+1]));
This keeps both charts in sink. An additional benefit was that my rather large dots (symbolsize=15) are no longer being clipped.
Thanks Roger.
I'm trying to reduce the number of points in a DC.js line chart to improve performance. The docs lead me to believe xUnits() is the way to do this:
The coordinate grid chart uses the xUnits function to calculate the number of data projections on x axis such as the number of bars for a bar chart or the number of dots for a line chart.
but xUnits does not even seem to be used:
http://jsfiddle.net/m5tguakf/2/
What am I doing wrong?
The number of points is actually determined by crossfilter - dc.js doesn't do any aggregation on its own, so it has no way to add or reduce the number of points.
That documentation may be misleading - it doesn't alter the shape of the data. xUnits is really just needed for dc.js to know the number of elements it is going to draw. It's used for two purposes:
to determine the width of bars or box-plots
to know whether the x scale is ordinal or quantitative
Could dc.js just count the number of points in the crossfilter group? Perhaps.
Anyway, to get back to your original question: if you want to reduce the number of points drawn, aggregate your data differently in your group. Usually this means creating larger bins which either sum or average the data which fall into that interval.
As a simple example, you can combine every other point in your fiddle by binning by even numbers, like so:
var BINSIZE = 2;
// ...
speedSumGroup = runDimension
.group(function(r) { return Math.floor(r/BINSIZE) * BINSIZE; })
// ...
http://jsfiddle.net/gordonwoodhull/djrhodkj/2/
This causes e.g. both Run 6 and Run 7 to fall in the same bin, because they have the same group key. In a real example, you'd probably want to average them, as shown in the annotated stock example.
I have some data which is collected for 6 days during 8:00AM to 11:00AM. I need to plot all the data on same plot one over other. The way I am doing now:
hold on
plot(y1,x1,':b*','MarkerEdgeColor','k')
plot(y2,x2,':r*','MarkerEdgeColor','k')
plot(y3,x3,':y*','MarkerEdgeColor','k')
plot(y4,x4,':g*','MarkerEdgeColor','k')
plot(y5,x5,':c*','MarkerEdgeColor','k')
plot(y6,x6,':w*','MarkerEdgeColor','k')
datetick('x','HH:MM:SS')
hold off
where x1 to x6 has y axis data and y1 to y6 have
y(i) = datenum(Year(1:5), Month(1:5), Input_Vector(1:5,2), Input_Vector(1:5,3), Input_Vector(1:5,4), Input_Vector(1:5,5));
When I plot using above, I get the image attached
But what I need to find patterns by observing them. So I need to have something one above other with x axis 8:00:00 to 11:00:00
I need something like and I got this by making DAY parameter constant date.
If you want to plot one day over another, then the method you used to make the second graph - discarding/replacing the date part of your datetime - is likely the best way to do it. It matches up nicely with the conceptual question that the graph answers, i.e.: "Is there a link between time of day and duration of journey, regardless of the day it was taken on?"
If you still want to preserve the day information, you could always perform the multiple plots with different line specs, and have the legend show which line corresponds to which day.
If the above question - finding a link between time and journey duration - is what you are trying to do, rather than plotting that specific type of graph, I would also try something like this:
Split your day into half hour or quarter hour slots and take the average of all data points in each block. This gives you a single value for each half/quarter hour span.
Plot this as a bar chart with error bars showing standard error (this can be done using bar and errorbars)
If I see anything, try fitting it with an appropriate model and check for goodness of fit. In your case this would probably be a Gaussian model, as your data kinda looks like it peaks around 9:20.