@using Trirand.Web.Mvc
@using Trirand.Web.Mvc.Chart;
@using Trirand.Web.Mvc.Chart.Series;
@using Trirand.Web.Mvc.Chart.Data;

<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>Chartfor ASP.NET MVC - WordCloud Google Trends</title>
    <script type="text/javascript" src="~/Scripts/trirand/chart/corechart.min.js"></script>
    <script type="text/javascript" src="~/Scripts/trirand/chart/corechart-wordcloud.min.js"></script>
</head>
<body>
    <div>
        <!--
        The Html.Trirand().CoreChart() helper has two parameters
            - the model of the chart -- all chart properties, data and settings
            - the ID of the chart -- can be used for client-side manipulation
        In this example we are using hardcoded model in the View, but you can contruct the model in
        the controller based on runtime criteria and database data and pass the model
        to the View using ViewData
        -->
        @(Html.Trirand().CoreChart(
                     new CoreChart
                     {
                        Title = new List<Title>
                        {
                            new Title()
                            {
                                Text = "Google Trends",
                                Link = "http://www.google.com/trends/hottrends"
                            }
                        },
                        Tooltip = new ToolTip
                        {
                            Show = true
                        },
                        Series = new List<object>()
                        {
                            new WordCloud()
                            {
                                Name = "Google Trends",
                                Size = new List<string> { "80%", "80%"},
                                TextRotation = new List<int> { 0, 45, 90, -45 },
                                TextPadding = 0,
                                AutoSize = new AutoSizeConfig
                                {
                                    Enable = true,
                                    MinSize = 14
                                },
                                Data = ViewData["data1"] as List<Data>
                            }
                        }
                     }
            , "Chart")
        )

        <br />
        <div>
             
        </div>
    </div>
</body>
</html>

using System.Web.Mvc;
using System;
using System.Collections.Generic;
using Trirand.Web.Mvc.Chart.Data;
using Trirand.Web.Mvc.Chart.Style;

namespace CoreDemo.Controllers.Chart
{
    public partial class ChartController : Controller
    {
        private ItemStyle CreateRandomItemStyle()
        {
            ItemStyle style = new ItemStyle();
            Random random = new Random();

            int red = random.Next(20, 240);
            int green = random.Next(20, 240);
            int blue = random.Next(20, 240);

            style.Normal = new Normal
            {
                Color = $"rgb({red},{green},{blue})"
            };


            return style;
        }
        
        public ActionResult GoogleTrends()
        {
            List<Data> data1 = new List<Data>
            {
                new Data
                {
                    Name = "Macys",
                    Value = 6181,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Amy Schumer",
                    Value = 4386,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Jurassic World",
                    Value = 4055,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Charter Communications",
                    Value = 2467,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Chick Fil A",
                    Value = 2244,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Planet Fitness",
                    Value = 1898,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Pitch Perfect",
                    Value = 1484,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Express",
                    Value = 1112,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Home",
                    Value = 965,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Johnny Depp",
                    Value = 847,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Lena Dunham",
                    Value = 582,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Lewis Hamilton",
                    Value = 555,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "KXAN",
                    Value = 550,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Mary Ellen Mark",
                    Value = 462,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Farrah Abraham",
                    Value = 366,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Rita Ora",
                    Value = 360,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Serena Williams",
                    Value = 282,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "NCAA baseball tourNament",
                    Value = 273,
                    ItemStyle = CreateRandomItemStyle()
                },
                new Data
                {
                    Name = "Point Break",
                    Value = 265,
                    ItemStyle = CreateRandomItemStyle()
                }
            };

            ViewData["data1"] = data1;

            return View("");
        }
    }
}