Gantt Chart or Stached Horizontal bar


Author
Message
Hans Henrik Friis Pedersen...
Hans Henrik Friis Pedersen
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 28, Visits: 136
Hi,

I would like to make a chart similar to the attached photo. I think I can make something similar to this using a stacked horizontal bars but:

1) There are approx. 125 "many colored" rectangles in one bar. Does that mean I have to make 125 series of a bar in order t make this chart?

2) How do I control the colors so that a rectangle of barseries1 is red in one bar but yellow in another bar? For instance, the very first rectangle is green at the bar at the top but blue at the third highest bar - How do I control this if I'm using the same barseries?https://www.nevron.com/forum/uploads/images/731ed9ec-ea3f-49b1-8c7b-15ee.png 
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Hans,

You can control the filling of each bar using the FillStyles series of bar - for example:

   NChart chart = nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();

   bar.Values.Add(10);
   bar.FillStyles[0] = new NColorFillStyle(Color.Red);

   bar.Values.Add(20);
   bar.FillStyles[1] = new NColorFillStyle(Color.Green);

   bar.Values.Add(30);
   bar.FillStyles[2] = new NColorFillStyle(Color.Blue);

   chart.Series.Add(bar);

Creates three bars with different colors. An alternative approach to this chart will be to use bars with mapped image fill that is generated so that it represents the color stripes you want. For example:

   NChart chart = nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();

   bar.Values.Add(10);

   chart.Series.Add(bar);

   chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);

   chart.Axis(StandardAxis.PrimaryY).UpdateScale();

   Bitmap bmp = new Bitmap(1, 1024, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

   for (int i = 0; i < 1024; i++)
   {
    bmp.SetPixel(0, i, Color.FromArgb(i % 255, i % 255, i % 255));
   }

   NImageFillStyle imgFill = new NImageFillStyle(bmp);
   imgFill.TextureMappingStyle.MapMode = MapMode.RelativeToObject;
   imgFill.TextureMappingStyle.MapLayout = MapLayout.Stretched;
   bar.FillStyle = imgFill;

Creates a bar series with four white to black stripes. Hope this helps - let us know if you have any questions or meet any problems.




Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search