Set background to transparent

Apr 17, 2012 at 3:17 PM

Hello,

Thanks for this wonderful project.

I would like to set background color of my graphs to transparent. 

I found that you can do that by setting backgroundColor option to null.

Example: http://jsfiddle.net/BGurung/LZ8Mu/7/

Is it possible to do that with DotNet.HighCharts?

Thanks again.

Coordinator
Apr 18, 2012 at 10:02 PM

Hi,

Usually you can configure the background color of the chart like this:

BackgroundColor = Color.Transparent

But there is a bug (which will be fixed in the next release) and you can't use it. Anyway there is a workaround by using Gradient:

BackgroundColor = new BackColorOrGradient(new Gradient
{
    LinearGradient = new[] { 0, 0, 0, 400 },
    Stops = new object[,]
            {
                { 0, Color.FromArgb(13, 255, 255, 255) },
                { 1, Color.FromArgb(13, 255, 255, 255) }
            }
})
I hope this helps.

 

Marked as answer by Vangi on 10/24/2013 at 3:05 AM
Apr 19, 2012 at 11:32 AM

Yes,

Thanks once again,

Excellent project.

Apr 19, 2012 at 6:04 PM

What would be the syntax to add gradient coloring to a bar/column? In VB I have tried several variations that looks something like:

...            
          .SetOptions(New Helpers.GlobalOptions() With { _
                .Colors = New Gradient() With { _
                        .LinearGradient = {0, 0, 0, 400}, _
                        .Stops = New Object(,) {{0, Color.FromArgb(13, 255, 255, 255)}, {1, Color.FromArgb(13, 255, 255, 255)}} _
                }}) _
...

Of course this does not work due to several types of errors and not being able to find a valid syntax:

Value of type 'DotNet.Highcharts.Helpers.Gradient' cannot be converted to '1-dimensional array of System.Drawing.Color'.

Feb 25, 2013 at 8:03 PM
Edited Feb 26, 2013 at 10:53 AM
Hello,

Thanks for this cool project!
BackgroundColor = new BackColorOrGradient(Color.White)
I've got JS error

JsonSerializer result
... animation: { animation: false }, backgroundColor: { 'white' }, zoomType: 'x' ...

Thanks in advance
Feb 26, 2013 at 10:46 AM
Edited Feb 26, 2013 at 10:53 AM
sergioneli wrote:
Hello,

Thanks for this cool project!
BackgroundColor = new BackColorOrGradient(Color.White)
I've got JS error

JsonSerializer result
... animation: { animation: false }, backgroundColor: { 'white' }, zoomType: 'x' ...

Thanks in advance
Hi all

One of the solutions for those who have faced a similar problem
// new condition in JsonSerializer.GetValue
if (value is BackColorOrGradient)
{
   var colorOrGradient = value as BackColorOrGradient;

   if (colorOrGradient.Color != null)
   {
    return GetColorString(formatter.JsonValueFormat, colorOrGradient.Color);
   }

   return GetJsonString(formatter.JsonValueFormat,
        JSON_DEFAULT_FORMAT,
        GetJsonObject(colorOrGradient.Gradient, formatter.UseCurlyBracketsForObject));
   }
i hope this helps
Mar 29, 2013 at 12:57 AM
ntenisOT wrote:
Hello, Thanks for this wonderful project. I would like to set background color of my graphs to transparent.  I found that you can do that by setting backgroundColor option to null. Example: http://jsfiddle.net/BGurung/LZ8Mu/7/ Is it possible to do that with DotNet.HighCharts? Thanks again.
Hi,

the following code is a great workaround
LineChart1.Appearance.borderWidth = 500;

so you just need to play with your borderwidth on the cs file.