Search code examples
highchartsdotnethighcharts

dotnethighcharts - pointwidth


Im using dotnethighcharts and want the columns to have a pointwidth=20, but I cant get it to work with dotnethighcharts, any suggestions how to make that?

      Highcharts chart;
        chart = new Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetXAxis(new XAxis
            {
                Categories = new[] { "1", "2" },
                Title = new XAxisTitle { Text = string.Empty }
            })
            .SetPlotOptions(new PlotOptions
            {
                Bar = new PlotOptionsBar
                {
                    DataLabels = new PlotOptionsBarDataLabels { Enabled = true }
                },
            })

            .SetSeries(new[]
            {
                new Series {Name = "1", Data = new Data(new object[] {1})},
                new Series {Name = "2", Data = new Data(new object[] {4})}
            });

Here is an example how to us pointwidth http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/column-pointwidth-20/


Solution

  • The answer - I was missing this

     Column = new PlotOptionsColumn
                    {
                        PointPadding = 0.2,
                        PointWidth = 40,
                        BorderWidth = 0
                    }
    

    Here is all code

        Highcharts chart;
        chart = new Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetXAxis(new XAxis
            {
                Categories = new[] { "1", "2" },
                Title = new XAxisTitle { Text = string.Empty }
            })
            .SetPlotOptions(new PlotOptions
            { 
                 Column = new PlotOptionsColumn
                    {
                        PointPadding = 0.2,
                        PointWidth = 40,
                        BorderWidth = 0
                    },
                Bar = new PlotOptionsBar
                {
                    DataLabels = new PlotOptionsBarDataLabels { Enabled = true }
                },
            })
    
            .SetSeries(new[]
            {
                new Series {Name = "1", Data = new Data(new object[] {1})},
                new Series {Name = "2", Data = new Data(new object[] {4})}
            });