'DotNet.Highcharts to Highsoft.HighCharts (9.3.2.1) Conversion

I've found an example online using the older DotNet.Highcharts api. https://www.c-sharpcorner.com/article/dotnet-highcharts-with-asp-net-mvc/. I'm trying to duplicate this using the newer Highsoft.Highcharts (9.3.2.1) api. There are a few syntax differences that I'm hoping I can get help with.

  1. The style object is a hashtable. How can I convert the following to a hashtable?

    Style = "fontWeight: 'bold', fontSize: '17px'"     
    
  2. The data values in the example are encapsulated in a Series object. In the new api there is no data object in the series. I'm guessing it corresponds to the Data object in the Chart. How can I change this to populate the data object?

    columnChart.Series = (new Series[]
    {
       new Series{
         Name = "Sachin Tendulkar",
         Data = new Data(new object[] { 812, 412, 628, 1425, 460, 972, 204, 513, 315 })
       },
       new Series()
       {
         Name = "M S Dhoni",
         Data = new Data(new object[] { 19, 895, 821, 1103, 1097, 1198, 600, 764, 524, })
       }
    }
    
  3. How do I change this since there is no longer a BackgroundColorGradient?

    BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFADD8E6"))
    

This is what I have so far in the conversion:

        Highcharts columnChart = new Highcharts();
        columnChart.Chart = (new Chart()
        {
            Type = ChartType.Column,
            BackgroundColor = "blue",
            //Style = "fontWeight: 'bold', fontSize: '17px'",
            BorderColor = "LightBlue",
            BorderRadius = 0,
            BorderWidth = 2
        });

        columnChart.Title = (new Title()
        {
            Text = "Sachin Vs Dhoni"
        });

        columnChart.Subtitle = (new Subtitle()
        {
            Text = "Played 9 Years Together From 2004 To 2012"
        });

        columnChart.XAxis = (new XAxis()
        {
            Type = "Category",
            Title = new XAxisTitle()
            {
                Text = "Years",
                Style = new System.Collections.Hashtable("fontWeight: 'bold', fontSize: '17px'")
            },
            Categories = new List<string> { "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012" }
        });

        columnChart.YAxis = (new YAxis()
        {
            Title = new YAxisTitle()
            {
                Text = "Runs",
                Style = "fontWeight: 'bold', fontSize: '17px'"
            },
            ShowFirstLabel = true,
            ShowLastLabel = true,
            Min = 0
        });

        columnChart.Legend = (new Legend
        {
            Enabled = true,
            BorderColor = "CornflowerBlue",
            BorderRadius = 6,
            //BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFADD8E6"))
        });

        columnChart.Series = (new Series[]
        {
            new Series{

                Name = "Sachin Tendulkar",
                Data = new Data(new object[] { 812, 412, 628, 1425, 460, 972, 204, 513, 315 })
            },
            new Series()
            {
                Name = "M S Dhoni",
                Data = new Data(new object[] { 19, 895, 821, 1103, 1097, 1198, 600, 764, 524, })
            }
        }
        );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source