How to Cause Bars to Overlap in VCL TeeChart - teechart

I have two series in a horizontal TeeDBChart. I would like to draw one series behind the other. The help says that "...you can choose if they will be drawn side-by-side, back-to-front or Stacked." Side-by-side and stacked choices are reasonably obvious, but how do I display them back-to-front?
I used to have this working perfectly, but now it doesn't. Not sure exactly when it broke.
Here's a rundown of the Multiple Bar settings:
None = all bars from both series in a single spot on the axis - complete overlap
Side = all bars from a series in a single spot on the axis - overlap within series
Side All = all bars from both series spread across the axis evenly - no overlap
What I really want is bars to be matched and overlapped based on axis values. That is, bars for the same axis value will overlap.

Try setting series' MultiBar property to mbNone, for example:
uses VCLTee.Series;
procedure TForm1.FormCreate(Sender: TObject);
var Series1, Series2: THorizBarSeries;
begin
Series1 := THorizBarSeries.Create(Self);
Series1.FillSampleValues();
Series1.MultiBar := mbNone;
Series2 := THorizBarSeries.Create(Self);
Series2.FillSampleValues();
Series2.MultiBar := mbNone;
Chart1.AddSeries(Series1);
Chart1.AddSeries(Series2);
end;
Code above produces this chart:
Is this what you are looking for? Otherwise, can you please post a code snippet reproducing your problem?

Related

Longest Recharts Stack Bar does not fill the chart’s entire length (width) when layout is set to vertical

Example of a horizontally stacked bar chart, where the longest bar is drawn right up to the chart’s topmost edge:
Example of a vertically stacked bar chart, where the longest bar stops before the chart’s rightmost edge:
More precisely, it seems like the scale goes up to 20 here, as opposed to the biggest total stack value present in the data set, like 36 in the horizontal variant above which seems like an arbitrary enough number to align to – I guess except that it’s not a prime number.
I’ve been struggling to figure out why it behaves like this, but have thus far come up short. The two data sets have the same exact anatomy – are there any more props that has to be defined, other than type – when flipping the layout like this?
Well I’ve been reading the docs so much that I zoned out when it came to the domain prop, however that is the solution to this; domain={[0, 'dataMax']} and Bob’s your uncle.

How to add a properly scaled y axis to a stacked d3 bar chart

I've been working with Mike Bostock's stacked bar chart (here: https://bl.ocks.org/mbostock/4679202).
I've successfully made a number of modifications, but what I'm stuck on is trying to add a y axis with ticks and properly scaled values.
I thought it would simply be done by using this:
var yAxisRight = d3.svg.axis().scale(y2) //define ticks
.orient("right").ticks(5);
However, that results in the values for only ONE set of the stack being used for the entire Y axis. This results in an incorrect scale. The values for the range of all stacks COMBINED needs to be used to determine the range of values I believe.
Is there an easy way to do this that I'm missing? To sum the range of all the columns.
If not, how would I write a function to set the range based on the values in all 4 columns?
Here is a working JSfiddle of what I have now (which is incorrect):
https://jsfiddle.net/1jhm7ths/
If I understood correctly what you tried to achieve, you need to compute your range based on your stacked data and not the original ones. I updated your jsFiddle with the following modification on line 92:
y2.domain([0, d3.max(dataByGroup, function(d) { return d3.sum(d.values, function(v) {return v.value;}); })]); //added
What this does is taking each group, computing the sum of all values, and the taking the max of the sums.
On a side note, I would discourage learning d3 v3 and try to focus on the v4 for longer term support, latest functionalities, modulariy, and a ton of other advantages.

Dimple JS - Removing gap between the y-axis and the chart

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/

dc.js not respecting xUnits

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.

Can interpolation be limited to positive values?

I currently use LineChart in order to display discrete data across 7 points on the x-axis (the days of the week). To improve the appearance of the chart, I use interpolate('monotone') to make the line smoother:
As you can see, however, this causes the line to at some points slip beneath the x-axis. Is there any way I can prevent this? The graph itself is created like this:
var chart = nv.models.lineChart()
.interpolate('monotone')
.width(400)
.useInteractiveGuideline(true)
.showLegend(true);
You can't prevent this explicitly; I would choose a different interpolation here.

Resources