Toggle navigation Highcharts
  • About Us
    • About Us
    • Job Openings
    • Contact Us
    • News
    • Resellers
  • Home
  • Products
    • Highcharts
    • Highstock
    • Highmaps
    • Mobile
    • Highcharts Cloud
    • Highcharts Editor
    • Wrappers
    • Plugins
  • Demo
    • Highcharts demos
    • Highstock demos
    • Highmaps demo
  • Docs
    • General Documentation
    • API Reference
    • Changelog
    • Roadmap
  • Support
    • Support
    • Download
  • Blog
  • Community
    • Project Showcase
    • Chart Code Showcase
    • Contribute
  • Buy
  • About Us
    • About Us
    • Job Openings
    • Contact Us
    • News
    • Resellers
Highstock .NET 
  • Highcharts .NET
  • Highstock .NET
Demos 
  • Demos
  • API
  • Docs
  • See on NuGet
  • Download 
  • Demo
  • API
  • Docs
  • See on NuGet
  • Download 
Highstock .NET
 Highcharts  Highstock
  • GENERAL
    • Single line series
    • Two panes, candlestick and volume
    • Compare multiple series
    • 52,000 points with data grouping
    • 1,7 million points with async loading
    • Intraday Area
    • Intraday with breaks
    • Intraday Candlestick
    • Flags marking events
    • Dynamically Updated Data
  • CHART TYPES
    • Line with markers and shadow
    • Spline
    • Step line
    • Area
    • Area spline
    • Area range
    • Area spline range
    • Candlestick
    • OHLC
    • Column
    • Column range
    • Point markers only
  • VARIOUS FEATURES
    • Plot lines on Y axis
    • Plot bands on Y axis
    • Reversed Y axis
    • Styled scrollbar
    • Disabled scrollbar
    • Disabled navigator
  • FLAGS
    • Flags placement
    • Flags shapes and colors
list

Controller Code

using Highsoft.Web.Mvc.Stocks;
using MVC_Demo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;

namespace MVC_Demo.Areas.Highstock.Controllers.Shared
{
    public partial class SharedController : Controller
    {
        public ActionResult FlagsShapesColors()
        {
            List<LineSeriesData> currencyData = new List<LineSeriesData>();
            double? lastDate;
            int days = 86400000; // milliseconds in a day

            using (var db = new HighstockDataEntities())
            {
                foreach (Flag flag in db.Flags)
                {
                    currencyData.Add(new LineSeriesData
                    {
                        Y = Convert.ToDouble(flag.Value),
                        X = Convert.ToDouble(flag.Date)
                    }
                    );
                }

                lastDate = db.Flags.ToList().Last().Date;
            }

            ViewBag.CurrencyData = currencyData.OrderBy(o => o.X).ToList();


            List<FlagsSeriesData> aData = new List<FlagsSeriesData>();
            aData.Add(new FlagsSeriesData
                            {
                                X = lastDate - 5 * days,
                                Title = "A"                                
                            }
            );
            aData.Add(new FlagsSeriesData
                            {
                                X = lastDate - 20 * days,
                                Title = "A"
                            }
           );

            List<FlagsSeriesData> bData = new List<FlagsSeriesData>();
            bData.Add(new FlagsSeriesData
            {
                X = lastDate - 10 * days,
                Title = "A"
            }
            );
            bData.Add(new FlagsSeriesData
            {
                X = lastDate - 15 * days,
                Title = "A"
            }
           );

            List<FlagsSeriesData> cData = new List<FlagsSeriesData>();
            cData.Add(new FlagsSeriesData
            {
                X = lastDate - 13 * days,
                Title = "A"
            }
            );
            cData.Add(new FlagsSeriesData
            {
                X = lastDate - 23 * days,
                Title = "A"
            }
           );

            ViewBag.AData = aData;
            ViewBag.BData = bData;
            ViewBag.CData = cData;


            return View(ViewBag);
        } 

    }
}

Controller Code

@using Highsoft.Web.Mvc.Stocks
@using Highsoft.Web.Mvc.Stocks.Rendering

<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

@{ var chartOptions =
      new Highstock
      {
          RangeSelector = new RangeSelector
          {
              Selected = 0
          },
          Title = new Title
          {
              Text = "USD to EUR exchange rate"
          },
          Tooltip = new Tooltip
          {
              ValueDecimals = 4,
              Shared = true
          },
          YAxis = new List<YAxis>
              {
                new YAxis
                {
                    Title = new YAxisTitle
                    {
                        Text = "Exchange rate"
                    }
                }
                              },
          Series = new List<Series>
              {
                new LineSeries
                {
                    Data = ViewBag.CurrencyData as List<LineSeriesData>,
                    Name = "USD to EUR",
                    Id = "currency",
                    Tooltip = new LineSeriesTooltip
                    {
                        ValueDecimals = 2
                    }
                },
                new FlagsSeries
                {
                    Data = ViewBag.AData as List<FlagsSeriesData>,
                    Name = "Flags on Series",
                    OnSeries = "currency",
                    Shape = "squarepin"
                },
                new FlagsSeries
                {
                    Data = ViewBag.BData as List<FlagsSeriesData>,
                    Name = "Flags on Series 2",
                    OnSeries = "currency",
                    Color = "#7cb5ec",
                    Shape = "circlepin"
                },
                new FlagsSeries
                {
                    Data = ViewBag.CData as List<FlagsSeriesData>,
                    Name = "Flags on Series 3",
                    Shape = "flag"
                }
                              },
          PlotOptions = new PlotOptions
          {
              Series = new PlotOptionsSeries
              {
                  TurboThreshold = 5000
              }
          }

      };

    chartOptions.ID = "chart";
    var renderer = new HighstockRenderer(chartOptions);
}

@Html.Raw(renderer.RenderHtml())
© 2023 All rights reserved.