Profile Picture

Range Chart or Coloring Stock Chart

Posted By Jerry Jacob 10 Years Ago
Author
Message
Jerry Jacob
Question Posted 10 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 9 Years Ago
Posts: 15, Visits: 78
Initially I made a range chart but I could not find out how to change the width of the line to be the size I wanted, however the coloring worked.

Next I tried to instead use a stock chart to do the same thing, and while the width is great, I can't seem to figure out how to change the color of each bar.  I have the following and it doesn't seem to work.

Color lineColor = Color.FromArgb(convertedItems[0],convertedItems[1],convertedItems[2]);
range.FillStyles[i] = new NColorFillStyle(lineColor);

Any suggestions?

Nevron Support
Posted 9 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: 3 hours ago
Posts: 3,054, Visits: 4,012
Hi Jerry,
We just tested the range series with the following code:

private void Form1_Load(object sender, EventArgs e)
{
// setup chart
NChart chart = nChartControl1.Charts[0];
chart.Enable3D = false;

// setup shape series
NRangeSeries rangeSeries = (NRangeSeries)chart.Series.Add(SeriesType.Range);
rangeSeries.FillStyle = new NColorFillStyle(Color.Red);
rangeSeries.BorderStyle.Color = Color.DarkRed;
rangeSeries.Legend.Mode = SeriesLegendMode.None;
rangeSeries.DataLabelStyle.Visible = false;
rangeSeries.UseXValues = true;
rangeSeries.UseZValues = true;

    // add data
AddDataPoint(rangeSeries, 1, 5, 11, 17, 5, 9);
AddDataPoint(rangeSeries, 4, 7, 15, 19, 16, 19);
AddDataPoint(rangeSeries, 5, 15, 6, 11, 12, 18);
AddDataPoint(rangeSeries, 9, 14, 2, 5, 3, 5);
AddDataPoint(rangeSeries, 15, 19, 2, 5, 3, 5);

rangeSeries.FillStyles[0] = new NColorFillStyle(Color.Red);
rangeSeries.FillStyles[1] = new NColorFillStyle(Color.Green);
rangeSeries.FillStyles[2] = new NColorFillStyle(Color.Blue);

rangeSeries.BorderStyles[0] = new NStrokeStyle(2, Color.Yellow);
rangeSeries.BorderStyles[1] = new NStrokeStyle(2, Color.Cyan);
rangeSeries.BorderStyles[2] = new NStrokeStyle(2, Color.Magenta);
}

private void AddDataPoint(NRangeSeries series, double x1, double x2, double y1, double y2, double z1, double z2)
{
series.XValues.Add(x1);
series.X2Values.Add(x2);
series.Values.Add(y1);
series.Y2Values.Add(y2);
series.ZValues.Add(z1);
series.Z2Values.Add(z2);
}

and it was working properly - the filling and stroke for the first three ranges were modified as expected. Hope this helps - can you post the code that you use to automate the control for review?

Best Regards,
Nevron Support Team



Jerry Jacob
Posted 9 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 9 Years Ago
Posts: 15, Visits: 78
That is very similar to the code I have however the width of the line doesn't seem to get larger after 2, which is still quite small.  If i change the number to 5 or 6 it doesn't look any different.

      Color lineColor = Color.FromArgb(convertedItems[0],convertedItems[1],convertedItems[2]);
     
       range.FillStyles[i] = new NColorFillStyle(lineColor);
       range.BorderStyles[i] = new NStrokeStyle(10, lineColor);


Nevron Support
Posted 9 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: 3 hours ago
Posts: 3,054, Visits: 4,012
Hi Jerry,

We just tested again with the following code:

// setup chart
NChart chart = nChartControl1.Charts[0];
chart.Enable3D = false;

// setup shape series
NRangeSeries rangeSeries = (NRangeSeries)chart.Series.Add(SeriesType.Range);
rangeSeries.FillStyle = new NColorFillStyle(Color.Red);
rangeSeries.BorderStyle.Color = Color.DarkRed;
rangeSeries.Legend.Mode = SeriesLegendMode.None;
rangeSeries.DataLabelStyle.Visible = false;
rangeSeries.UseXValues = true;
rangeSeries.UseZValues = true;

// add data
AddDataPoint(rangeSeries, 1, 5, 11, 17, 5, 9);
AddDataPoint(rangeSeries, 4, 7, 15, 19, 16, 19);
AddDataPoint(rangeSeries, 5, 15, 6, 11, 12, 18);
AddDataPoint(rangeSeries, 9, 14, 2, 5, 3, 5);
AddDataPoint(rangeSeries, 15, 19, 2, 5, 3, 5);

rangeSeries.FillStyles[0] = new NColorFillStyle(Color.Red);
rangeSeries.FillStyles[1] = new NColorFillStyle(Color.Green);
rangeSeries.FillStyles[2] = new NColorFillStyle(Color.Blue);

int lineWidth = 10;

rangeSeries.BorderStyles[0] = new NStrokeStyle(lineWidth, Color.Yellow);
rangeSeries.BorderStyles[1] = new NStrokeStyle(lineWidth, Color.Cyan);
rangeSeries.BorderStyles[2] = new NStrokeStyle(lineWidth, Color.Magenta);

and again it works Ok. What is the version that you're testing with? Also can you post the code you use to automate the control - it should be something really small...

Best Regards,
Nevron Support Team



Jerry Jacob
Posted 9 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 9 Years Ago
Posts: 15, Visits: 78
The code I have is as follows

using System;
using System.Drawing;
using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;
using System.Text.RegularExpressions;

namespace MyNamespace
{
  public class MyClass
  {
    public static void RSMain(NRSChartCodeContext context)
    {
      if (context.document.Charts.Count == 0)
        return;
      
      NChart chart = context.document.Charts[0] as NChart;
           
      if (chart == null)
        return;
      NRangeSeries range = chart.Series[2] as NRangeSeries;
      //NStockSeries range = chart.Series[2] as NStockSeries;
    
      int dpCount = range.Values.Count;
      int backColorOffset = 0;

      for (int i = 0; i < dpCount; i++)
      {
      string strColors = (string)range.Labels[backColorOffset+i];
      if (strColors == "") {
      strColors = "0,0,0";
      }
      char[] delimiterChars = {','};
      string[] intColors = strColors.Split(delimiterChars);
      int[] convertedItems = Array.ConvertAll<string, int>(intColors, int.Parse);
      
       Color lineColor = Color.FromArgb(convertedItems[0],convertedItems[1],convertedItems[2]);
       int lineWidth = 50;

       range.FillStyles[i] = new NColorFillStyle(lineColor);
       range.BorderStyles[i] = new NStrokeStyle(lineWidth, lineColor);
      }
      // clean up the chart
      for (int i = range.Values.Count - 1; i >= dpCount; i--)
      {
        range.RemoveDataPointAt(i);
      }
    }
  }
}

But what I am saying is not that it doesn't run, but that the width after passing 2 doesnt change. If i change it to 1 and then to 2 i see a difference, but 2 to 3 or 2 to 10 or 2 to 50 shows no change in size.  

Using a stock chart I was able to get better widths, but the problem was I couldn't seem to change the colors the same way I am changing them now.

Nevron Support
Posted 9 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: 3 hours ago
Posts: 3,054, Visits: 4,012
Hi Jerry,
What is the version of the control you're currently using - we just tested with following code in SSRS:

using System;
using System.Drawing;
using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
 /// <summary>
 /// Sample class
 /// </summary>
 public class MyClass
 {
  /// <summary>
  /// Main entry point
  /// </summary>
  /// <param name="context"></param>
  public static void RSMain(NRSChartCodeContext context)
  {
   NChart chart = context.document.Charts[0];
   
   NRangeSeries rangeSeries = (NRangeSeries)chart.Series[0];
   
   for (int i = 0; i < rangeSeries.Values.Count; i++)
   {
    rangeSeries.BorderStyles[i] = new NStrokeStyle(5, Color.Red);
   }
  }
 }
}
And the borders looked OK. Can you check what happens with similar code in your project?




Best Regards,
Nevron Support Team



Jerry Jacob
Posted 9 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 9 Years Ago
Posts: 15, Visits: 78
Thanks for the quick responses.  I was able to figure out the problem.  I believe the problem was that I was rotating the chart by switching to 3d and rotate 270.  After using it in 2d and Left to Right Orientation the bars seem to be resizing correctly.

On this same chart I am trying to use markers or data points, not sure which is better to use for my case but I want to be able to take the diamond and instead of having it as a square rotated be a thinner diamond.  I tried adjusting the width Percent and height percent.  Doing this for the bar Shape worked as I wanted by adjusting width percent to 5 and height percent to 1.  The diamond turns into a marker that looks like >. Is there a way to just make the diamond thinner while preserving the height?

Nevron Support
Posted 9 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: 3 hours ago
Posts: 3,054, Visits: 4,012
Hi Jerry,
The marker style has properties called Width and Height that control the size of the marker - for example:

   NChart chart = nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();

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

   bar.MarkerStyle.Visible = true;
   bar.MarkerStyle.PointShape = PointShape.Diamond;
   bar.MarkerStyle.Width = new NLength(10);
   bar.MarkerStyle.Height = new NLength(20);

   chart.Series.Add(bar);



Best Regards,
Nevron Support Team



Jerry Jacob
Posted 9 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 9 Years Ago
Posts: 15, Visits: 78
So I was able to implement that, however when I try that out what ends up happening is the diamond turns into a Triangle with the other half cut off. What I am looking for is the diamond width to shrink while preserving the shape of a diamond.



Nevron Support
Posted 9 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: 3 hours ago
Posts: 3,054, Visits: 4,012
Hi Jerry,

Can you send us a screenshot?


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic