Profile Picture

2D Point Chart in Chart Gallery - smiliar sample code?

Posted By Jacky zhang 13 Years Ago
Author
Message
Jacky zhang
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 16, Visits: 1

Hi,

I saw the "2D Point Chart" demo picure in Chart Gallery. But I can not find any smiliar point chart in the sample source code.  Can you give a sample how to show this gradient style of point and datalabel.

thanks,

-Jacky

 



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Jacky,

All the images in the gallery are generated using the control, without any post processing in any imaging software.

The point chart screenshots just illustrate possible configurations of the control that anyone can achieve - in the case of the 2D chart it simply uses per data point fill style, data labels. The following code sample shows the the chart API functions involved to recreate the screenshot:

  private void Form1_Load(object sender, EventArgs e)
  {
   nChartControl1.Panels.Clear();

   NCartesianChart chart = new NCartesianChart();
   nChartControl1.Panels.Add(chart);

   NPointSeries point = new NPointSeries();
   chart.Series.Add(point);

   point.PointShape = PointShape.Ellipse;
   point.InflateMargins = true;

   point.Values.Add(10);
   point.Values.Add(20);
   point.Values.Add(30);

   point.FillStyles[0] = new NGradientFillStyle(Color.White, Color.Orange);
   point.FillStyles[1] = new NGradientFillStyle(Color.White, Color.Gray);
   point.FillStyles[2] = new NGradientFillStyle(Color.White, Color.DarkRed);

   point.BorderStyles[0] = new NStrokeStyle(2, Color.Orange);
   point.BorderStyles[1] = new NStrokeStyle(2, Color.Gray);
   point.BorderStyles[2] = new NStrokeStyle(2, Color.DarkRed);

   point.DataLabelStyles[0] = CreateDataLabelStyle(point, (NFillStyle)point.FillStyles[0]);
   point.DataLabelStyles[1] = CreateDataLabelStyle(point, (NFillStyle)point.FillStyles[1]);
   point.DataLabelStyles[2] = CreateDataLabelStyle(point, (NFillStyle)point.FillStyles[2]);

   // ordinal scale labels
   NOrdinalScaleConfigurator ordScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
   ordScale.AutoLabels = false;
   ordScale.Labels.Add("Item 1");
   ordScale.Labels.Add("Item 2");
   ordScale.Labels.Add("Item 3");

   // y scale stripes
   NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
   NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
   stripStyle.Interlaced = true;
   stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
   linearScale.StripStyles.Add(stripStyle);
  }

  private static NDataLabelStyle CreateDataLabelStyle(NPointSeries point, NFillStyle fillStyle)
  {
   NDataLabelStyle dls3 = (NDataLabelStyle)point.DataLabelStyle.Clone();

   dls3.TextStyle.BackplaneStyle.FillStyle = (NFillStyle)fillStyle.Clone();
   dls3.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderWidth = new NLength(0);
   dls3.Visible = true;
   dls3.TextStyle.BackplaneStyle.Shape = BackplaneShape.SmoothEdgeRectangle;

   return dls3;
  }

Hope this helps - let us know if you have any questions or comments.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic