ChartDirector 6.2 (.NET Edition)

Dual X-Axis




This example demonstrates a chart with two x-axes and two y-axes.

ChartDirector supports arbitrary number of axes. The first two x and y axes are most commonly used and can be retrieved using XYChart.xAxis, XYChart.xAxis2, XYChart.yAxis and XYChart.yAxis2. These axes are by default positioned at the edges of the plot area.

The key features demonstrated in this example are:

Source Code Listing

[Windows Forms - C# version] NetWinCharts\CSharpWinCharts\dualxaxis.cs
using System;
using ChartDirector;

namespace CSharpChartExplorer
{
    public class dualxaxis : DemoModule
    {
        //Name of demo module
        public string getName() { return "Dual X-Axis"; }

        //Number of charts produced in this demo module
        public int getNoOfCharts() { return 1; }

        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data0 = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56,
                60, 70, 76, 63, 67, 75, 64, 51};
            double[] data1 = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
                59, 73, 77, 84, 82, 80, 84, 98};

            // The labels for the bottom x axis. Note the "-" means a minor tick.
            string[] labels0 = {"0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5"};

            // The labels for the top x axis. Note that "-" means a minor tick.
            string[] labels1 = {"Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
                "22", "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12"};

            // Create a XYChart object of size 310 x 310 pixels
            XYChart c = new XYChart(310, 310);

            // Set the plotarea at (50, 50) and of size 200 x 200 pixels
            c.setPlotArea(50, 50, 200, 200);

            // Add a title to the primary (left) y axis
            c.yAxis().setTitle("US Dollars");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis().setTickLength(-4);

            // Add a title to the secondary (right) y axis
            c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis2().setTickLength(-4);

            // Synchronize the y-axis such that y2 = 7.8 x y1
            c.syncYAxis(7.8);

            // Add a title to the bottom x axis
            c.xAxis().setTitle("Hong Kong Time");

            // Set the labels on the x axis.
            c.xAxis().setLabels(labels0);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means
            // ticks inside the plot area)
            c.xAxis().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis().setLabelGap(6);

            // Add a title to the top x-axis
            c.xAxis2().setTitle("New York Time");

            // Set the labels on the x axis.
            c.xAxis2().setLabels(labels1);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis2().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means
            // ticks inside the plot area)
            c.xAxis2().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis2().setLabelGap(6);

            // Add a line layer to the chart with a line width of 2 pixels
            c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2);

            // Add an area layer to the chart with no area boundary line
            c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                "title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun " +
                "{=3+{x}/24|0} {=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {value})'");
        }
    }
}

[Windows Forms - VB Version] NetWinCharts\VBNetWinCharts\dualxaxis.vb
Imports System
Imports Microsoft.VisualBasic
Imports ChartDirector

Public Class dualxaxis
    Implements DemoModule

    'Name of demo module
    Public Function getName() As String Implements DemoModule.getName
        Return "Dual X-Axis"
    End Function

    'Number of charts produced in this demo module
    Public Function getNoOfCharts() As Integer Implements DemoModule.getNoOfCharts
        Return 1
    End Function

    'Main code for creating chart.
    'Note: the argument chartIndex is unused because this demo only has 1 chart.
    Public Sub createChart(viewer As WinChartViewer, chartIndex As Integer) _
        Implements DemoModule.createChart

        ' The data for the chart
        Dim data0() As Double = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, _
            56, 60, 70, 76, 63, 67, 75, 64, 51}
        Dim data1() As Double = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, _
            58, 59, 73, 77, 84, 82, 80, 84, 98}

        ' The labels for the bottom x axis. Note the "-" means a minor tick.
        Dim labels0() As String = {"0<*br*>Jun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
            "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", _
            "0<*br*>Jun 5"}

        ' The labels for the top x axis. Note that "-" means a minor tick.
        Dim labels1() As String = {"Jun 3<*br*>12", "13", "14", "15", "16", "17", "18", "19", _
            "20", "21", "22", "23", "Jun 4<*br*>0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
            "10", "11", "12"}

        ' Create a XYChart object of size 310 x 310 pixels
        Dim c As XYChart = New XYChart(310, 310)

        ' Set the plotarea at (50, 50) and of size 200 x 200 pixels
        c.setPlotArea(50, 50, 200, 200)

        ' Add a title to the primary (left) y axis
        c.yAxis().setTitle("US Dollars")

        ' Set the tick length to -4 pixels (-ve means ticks inside the plot area)
        c.yAxis().setTickLength(-4)

        ' Add a title to the secondary (right) y axis
        c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)")

        ' Set the tick length to -4 pixels (-ve means ticks inside the plot area)
        c.yAxis2().setTickLength(-4)

        ' Synchronize the y-axis such that y2 = 7.8 x y1
        c.syncYAxis(7.8)

        ' Add a title to the bottom x axis
        c.xAxis().setTitle("Hong Kong Time")

        ' Set the labels on the x axis.
        c.xAxis().setLabels(labels0)

        ' Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
        c.xAxis().setLabelStep(3, 1)

        ' Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
        ' inside the plot area)
        c.xAxis().setTickLength2(-4, -2)

        ' Set the distance between the axis labels and the axis to 6 pixels
        c.xAxis().setLabelGap(6)

        ' Add a title to the top x-axis
        c.xAxis2().setTitle("New York Time")

        ' Set the labels on the x axis.
        c.xAxis2().setLabels(labels1)

        ' Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
        c.xAxis2().setLabelStep(3, 1)

        ' Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
        ' inside the plot area)
        c.xAxis2().setTickLength2(-4, -2)

        ' Set the distance between the axis labels and the axis to 6 pixels
        c.xAxis2().setLabelGap(6)

        ' Add a line layer to the chart with a line width of 2 pixels
        c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2)

        ' Add an area layer to the chart with no area boundary line
        c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0)

        ' Output the chart
        viewer.Chart = c

        'include tool tip for the chart
        viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{dataSetName}" & vbLf & _
            "HKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun {=3+{x}/24|0} {=({x}+12)%24}:00)" & _
            vbLf & "HKD {={value}*7.8} (USD {value})'")

    End Sub

End Class

[WPF - C#] NetWPFCharts\dualxaxis.cs
using System;
using ChartDirector;

namespace CSharpWPFDemo
{
    public class dualxaxis : DemoModule
    {
        //Name of demo module
        public string getName() { return "Dual X-Axis"; }

        //Number of charts produced in this demo module
        public int getNoOfCharts() { return 1; }

        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WPFChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data0 = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56,
                60, 70, 76, 63, 67, 75, 64, 51};
            double[] data1 = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
                59, 73, 77, 84, 82, 80, 84, 98};

            // The labels for the bottom x axis. Note the "-" means a minor tick.
            string[] labels0 = {"0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5"};

            // The labels for the top x axis. Note that "-" means a minor tick.
            string[] labels1 = {"Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
                "22", "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12"};

            // Create a XYChart object of size 310 x 310 pixels
            XYChart c = new XYChart(310, 310);

            // Set the plotarea at (50, 50) and of size 200 x 200 pixels
            c.setPlotArea(50, 50, 200, 200);

            // Add a title to the primary (left) y axis
            c.yAxis().setTitle("US Dollars");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis().setTickLength(-4);

            // Add a title to the secondary (right) y axis
            c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis2().setTickLength(-4);

            // Synchronize the y-axis such that y2 = 7.8 x y1
            c.syncYAxis(7.8);

            // Add a title to the bottom x axis
            c.xAxis().setTitle("Hong Kong Time");

            // Set the labels on the x axis.
            c.xAxis().setLabels(labels0);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means
            // ticks inside the plot area)
            c.xAxis().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis().setLabelGap(6);

            // Add a title to the top x-axis
            c.xAxis2().setTitle("New York Time");

            // Set the labels on the x axis.
            c.xAxis2().setLabels(labels1);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis2().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means
            // ticks inside the plot area)
            c.xAxis2().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis2().setLabelGap(6);

            // Add a line layer to the chart with a line width of 2 pixels
            c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2);

            // Add an area layer to the chart with no area boundary line
            c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                "title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun " +
                "{=3+{x}/24|0} {=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {value})'");
        }
    }
}

[ASP.NET Web Forms - C# version] NetWebCharts\CSharpASP\dualxaxis.aspx
(Click here on how to convert this code to code-behind style.)
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="ChartDirector" %>
<%@ Register TagPrefix="chart" Namespace="ChartDirector" Assembly="netchartdir" %>

<!DOCTYPE html>

<script runat="server">

//
// Page Load event handler
//
protected void Page_Load(object sender, EventArgs e)
{
    // The data for the chart
    double[] data0 = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70,
        76, 63, 67, 75, 64, 51};
    double[] data1 = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73,
        77, 84, 82, 80, 84, 98};

    // The labels for the bottom x axis. Note the "-" means a minor tick.
    string[] labels0 = {"0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
        "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5"};

    // The labels for the top x axis. Note that "-" means a minor tick.
    string[] labels1 = {"Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
        "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};

    // Create a XYChart object of size 310 x 310 pixels
    XYChart c = new XYChart(310, 310);

    // Set the plotarea at (50, 50) and of size 200 x 200 pixels
    c.setPlotArea(50, 50, 200, 200);

    // Add a title to the primary (left) y axis
    c.yAxis().setTitle("US Dollars");

    // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
    c.yAxis().setTickLength(-4);

    // Add a title to the secondary (right) y axis
    c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)");

    // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
    c.yAxis2().setTickLength(-4);

    // Synchronize the y-axis such that y2 = 7.8 x y1
    c.syncYAxis(7.8);

    // Add a title to the bottom x axis
    c.xAxis().setTitle("Hong Kong Time");

    // Set the labels on the x axis.
    c.xAxis().setLabels(labels0);

    // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
    c.xAxis().setLabelStep(3, 1);

    // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
    // inside the plot area)
    c.xAxis().setTickLength2(-4, -2);

    // Set the distance between the axis labels and the axis to 6 pixels
    c.xAxis().setLabelGap(6);

    // Add a title to the top x-axis
    c.xAxis2().setTitle("New York Time");

    // Set the labels on the x axis.
    c.xAxis2().setLabels(labels1);

    // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
    c.xAxis2().setLabelStep(3, 1);

    // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
    // inside the plot area)
    c.xAxis2().setTickLength2(-4, -2);

    // Set the distance between the axis labels and the axis to 6 pixels
    c.xAxis2().setLabelGap(6);

    // Add a line layer to the chart with a line width of 2 pixels
    c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2);

    // Add an area layer to the chart with no area boundary line
    c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0);

    // Output the chart
    WebChartViewer1.Image = c.makeWebImage(Chart.PNG);

    // Include tool tip for the chart
    WebChartViewer1.ImageMap = c.getHTMLImageMap("", "",
        "title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun {=3+{x}/24|0} " +
        "{=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {value})'");
}

</script>

<html>
<body>
    <chart:WebChartViewer id="WebChartViewer1" runat="server" />
</body>
</html>

[ASP.NET Web Forms - VB Version] NetWebCharts\VBNetASP\dualxaxis.aspx
(Click here on how to convert this code to code-behind style.)
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="ChartDirector" %>
<%@ Register TagPrefix="chart" Namespace="ChartDirector" Assembly="netchartdir" %>

<!DOCTYPE html>

<script runat="server">

'
' Page Load event handler
'
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

    ' The data for the chart
    Dim data0() As Double = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, _
        60, 70, 76, 63, 67, 75, 64, 51}
    Dim data1() As Double = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, _
        59, 73, 77, 84, 82, 80, 84, 98}

    ' The labels for the bottom x axis. Note the "-" means a minor tick.
    Dim labels0() As String = {"0<*br*>Jun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", _
        "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", _
        "0<*br*>Jun 5"}

    ' The labels for the top x axis. Note that "-" means a minor tick.
    Dim labels1() As String = {"Jun 3<*br*>12", "13", "14", "15", "16", "17", "18", "19", "20", _
        "21", "22", "23", "Jun 4<*br*>0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", _
        "12"}

    ' Create a XYChart object of size 310 x 310 pixels
    Dim c As XYChart = New XYChart(310, 310)

    ' Set the plotarea at (50, 50) and of size 200 x 200 pixels
    c.setPlotArea(50, 50, 200, 200)

    ' Add a title to the primary (left) y axis
    c.yAxis().setTitle("US Dollars")

    ' Set the tick length to -4 pixels (-ve means ticks inside the plot area)
    c.yAxis().setTickLength(-4)

    ' Add a title to the secondary (right) y axis
    c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)")

    ' Set the tick length to -4 pixels (-ve means ticks inside the plot area)
    c.yAxis2().setTickLength(-4)

    ' Synchronize the y-axis such that y2 = 7.8 x y1
    c.syncYAxis(7.8)

    ' Add a title to the bottom x axis
    c.xAxis().setTitle("Hong Kong Time")

    ' Set the labels on the x axis.
    c.xAxis().setLabels(labels0)

    ' Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
    c.xAxis().setLabelStep(3, 1)

    ' Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
    ' inside the plot area)
    c.xAxis().setTickLength2(-4, -2)

    ' Set the distance between the axis labels and the axis to 6 pixels
    c.xAxis().setLabelGap(6)

    ' Add a title to the top x-axis
    c.xAxis2().setTitle("New York Time")

    ' Set the labels on the x axis.
    c.xAxis2().setLabels(labels1)

    ' Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
    c.xAxis2().setLabelStep(3, 1)

    ' Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
    ' inside the plot area)
    c.xAxis2().setTickLength2(-4, -2)

    ' Set the distance between the axis labels and the axis to 6 pixels
    c.xAxis2().setLabelGap(6)

    ' Add a line layer to the chart with a line width of 2 pixels
    c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2)

    ' Add an area layer to the chart with no area boundary line
    c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0)

    ' Output the chart
    WebChartViewer1.Image = c.makeWebImage(Chart.PNG)

    ' Include tool tip for the chart
    WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='{dataSetName}" & vbLf & _
        "HKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun {=3+{x}/24|0} {=({x}+12)%24}:00)" & vbLf & _
        "HKD {={value}*7.8} (USD {value})'")

End Sub

</script>

<html>
<body>
    <chart:WebChartViewer id="WebChartViewer1" runat="server" />
</body>
</html>

[ASP.NET MVC - Controller] NetMvcCharts\Controllers\DualxaxisController.cs
using System;
using System.Web.Mvc;
using ChartDirector;

namespace NetMvcCharts.Controllers
{
    public class DualxaxisController : Controller
    {
        //
        // Default Action
        //
        public ActionResult Index()
        {
            ViewBag.Title = "Dual X-Axis";
            createChart(ViewBag.Viewer = new RazorChartViewer(HttpContext, "chart1"));
            return View("~/Views/Shared/ChartView.cshtml");
        }

        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the chart
            double[] data0 = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70,
                76, 63, 67, 75, 64, 51};
            double[] data1 = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73,
                77, 84, 82, 80, 84, 98};

            // The labels for the bottom x axis. Note the "-" means a minor tick.
            string[] labels0 = {"0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5"};

            // The labels for the top x axis. Note that "-" means a minor tick.
            string[] labels1 = {"Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
                "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};

            // Create a XYChart object of size 310 x 310 pixels
            XYChart c = new XYChart(310, 310);

            // Set the plotarea at (50, 50) and of size 200 x 200 pixels
            c.setPlotArea(50, 50, 200, 200);

            // Add a title to the primary (left) y axis
            c.yAxis().setTitle("US Dollars");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis().setTickLength(-4);

            // Add a title to the secondary (right) y axis
            c.yAxis2().setTitle("HK Dollars (1 USD = 7.8 HKD)");

            // Set the tick length to -4 pixels (-ve means ticks inside the plot area)
            c.yAxis2().setTickLength(-4);

            // Synchronize the y-axis such that y2 = 7.8 x y1
            c.syncYAxis(7.8);

            // Add a title to the bottom x axis
            c.xAxis().setTitle("Hong Kong Time");

            // Set the labels on the x axis.
            c.xAxis().setLabels(labels0);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
            // inside the plot area)
            c.xAxis().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis().setLabelGap(6);

            // Add a title to the top x-axis
            c.xAxis2().setTitle("New York Time");

            // Set the labels on the x axis.
            c.xAxis2().setLabels(labels1);

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis2().setLabelStep(3, 1);

            // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks
            // inside the plot area)
            c.xAxis2().setTickLength2(-4, -2);

            // Set the distance between the axis labels and the axis to 6 pixels
            c.xAxis2().setLabelGap(6);

            // Add a line layer to the chart with a line width of 2 pixels
            c.addLineLayer(data0, -1, "Red Transactions").setLineWidth(2);

            // Add an area layer to the chart with no area boundary line
            c.addAreaLayer(data1, -1, "Green Transactions").setLineWidth(0);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                "title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun {=3+{x}/24|0} " +
                "{=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {value})'");
        }
    }
}

[ASP.NET MVC - View] NetMvcCharts\Views\Shared\ChartView.cshtml
@{ Layout = null; }

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
</head>
<body style="margin:5px 0px 0px 5px">
    <div style="font:bold 18pt verdana;">
        @ViewBag.Title
    </div>
    <hr style="border:solid 1px #000080" />
    <div>
        @{
            if (ViewBag.Viewer is Array)
            {
                // Display multiple charts
                for (int i = 0; i < ViewBag.Viewer.Length; ++i)
                {
                    @:@Html.Raw(ViewBag.Viewer[i].RenderHTML())
                }
            }
            else
            {
                // Display one chart only
                @:@Html.Raw(ViewBag.Viewer.RenderHTML())
            }
        }
    </div>
</body>
</html>