Whether it is possible to place some series of bar with the same value of X.
That is, if there are points in a 3 series with values 10,20,30 that Y was to 30, but not the to 10+20+30, and we see only the third series?
Bars grouping one on another
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Bars grouping one on another
Yes, possible, if I understood your question right.
Like this, it renders 3rd series in front, overlapped, and doesn't put them side-by-side.
Code: Select all
m_chart.ViewXY.YAxes[0].SetRange(0, 60);
int iBarWidth = 50;
//NOTE: NEGATIVE BARWIDTH IN BARSPACING SETS THEM AT SAME POSITION
m_chart.ViewXY.BarViewOptions.BarSpacing = -iBarWidth;
m_chart.ViewXY.BarViewOptions.Grouping = BarsGrouping.ByLocation;
int iPointCount = 3;
double[] aYValues1 = new double[] { 10, 20, 30};
double[] aYValues2 = new double[] { 25, 5, 15 };
for (int iBar = 0; iBar < iPointCount; iBar++)
{
BarSeriesValue[] aData = new BarSeriesValue[2];
aData[0].Value = aYValues1[iBar];
aData[0].Location = 2;
aData[1].Value = aYValues2[iBar];
aData[1].Location = 6;
//Set label text
aData[0].Text = aYValues1[iBar].ToString("0");
aData[1].Text = aYValues2[iBar].ToString("0");
BarSeries bs = new BarSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
bs.BarThickness = iBarWidth;
//Set series fill
bs.Fill.Color = DefaultColors.Series[iBar];
bs.Fill.GradientColor = ChartTools.CalcGradient(DefaultColors.Series[iBar], Color.Black, 50);
//Set label text style
bs.LabelStyle.Angle = 0;
bs.LabelStyle.VerticalAlign = BarsTitleVerticalAlign.BarTop;
//Assign the values
bs.Values = aData;
m_chart.ViewXY.BarSeries.Add(bs);
}
LightningChart Support Team, PT