3d point cloud, how to make the legend show 'better'?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

3d point cloud, how to make the legend show 'better'?

Post by greggorob64 » Wed Mar 29, 2017 7:53 pm

Hi, I'm doing some data visualization (image shown below), I have a point cloud, with some color coding based on an intensity value

If you see in the legend, the legend color code is all dotted. How can I make it a pretty, colorful legend? Thanks! I dumped the code below too, there's not too much of it.

Image

Code: Select all

this.chart = new Arction.WinForms.Charting.LightningChartUltimate(LightningChartUltimate);

         chart.BeginUpdate();
         try
         {
            this.chart.Name = "chart";
            chart.Dock = DockStyle.Fill;
            this.chart.Options.ShowDebugData = false;
            this.chart.ColorTheme = ColorTheme.SkyBlue;
            this.Controls.Add(this.chart);

            chart.Name = "Point cloud chart";

            series = new SurfaceMeshSeries3D(chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
            chart.View3D.SurfaceMeshSeries3D.Add(series);

            chart.ActiveView = ActiveView.View3D;
            series.ColorSaturation = 100;
            series.WireframeType = SurfaceWireframeType3D.DotsPalettedByValue;
            series.ContourLineType = ContourLineType3D.None;
            series.Fill = SurfaceFillStyle.None;
            series.ContourLineType = ContourLineType3D.None;
            series.ContourPalette = CreatePalette(series);
            this.series.Clear();
         }
         finally
         {
            chart.EndUpdate();
         }

Code: Select all

      /// <summary>
      /// Create palette.
      /// </summary>
      /// <param name="ownerSeries">palette owner</param>
      /// <returns>ValueRangePalette</returns>
      private ValueRangePalette CreatePalette(SeriesBase3D ownerSeries)
      {
         ValueRangePalette palette = new ValueRangePalette(ownerSeries);

         Color[] colors = new Color[] { Color.Blue, Color.Teal, Color.Green, Color.Yellow, Color.Red };

         var palletList = new List<PaletteStep>();

         colors.Select((c, i) => new PaletteStep() { Color = colors[i], MaxValue = 255.0 / (float)colors.Length * (i + 1) });

         series.ContourPalette.Steps = palletList;
         series.ContourPalette.Type = PaletteType.Gradient;
         series.ContourPalette.MinValue = 0;
         return palette;
      }

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: 3d point cloud, how to make the legend show 'better'?

Post by ArctionKestutis » Thu Mar 30, 2017 1:50 pm

Hi Greg,

The simplest approach is to create another, Dummy Series. Set same palette, and desired Fill option. Finally, just disable Series.ShowInLegendBox for the first mesh.

All the best.

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: 3d point cloud, how to make the legend show 'better'?

Post by greggorob64 » Fri Mar 31, 2017 7:31 pm

Thanks for the help, solution works great! Thank you.

Code: Select all

              legendSeries = new SurfaceMeshSeries3D(chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
               legendSeries.ColorSaturation = 100;
               legendSeries.WireframeType = SurfaceWireframeType3D.DotsPalettedByValue;
               legendSeries.ContourLineType = ContourLineType3D.None;
               legendSeries.Fill = SurfaceFillStyle.PalettedByY;
               legendSeries.Title.Text = "Intensity";
               legendSeries.ShowInLegendBox = true;

               legendSeries.ContourPalette = new ValueRangePalette(legendSeries)
               {
                  ShowMinValueLegendLabel = false,
                  Steps = CreatePaletteSteps(),
                  Type = PaletteType.Gradient,
                  MinValue = 0
               };
               chart.View3D.SurfaceMeshSeries3D.Add(legendSeries);
            }

Post Reply