How to format Palette step in datetime format?

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

How to format Palette step in datetime format?

Post by jhyap » Tue Apr 16, 2013 7:32 am

First of all, I want to have a color legendBox as show in custom.JPG, which the palette color gradient should fill the legendBox according to palette step in datetime format
[img]
color bar custom by me
color bar custom by me
custom.JPG (16.11 KiB) Viewed 10860 times
[/img]

Then, I try to assume that by setting bellow will give me what I want (I create the m_chart3D just intention to show the legendBox only):

Code: Select all

 m_chart3D.View3D.YAxisPrimary3D.LabelsTimeFormat = "HH:mm:ss";
 m_chart3D.View3D.YAxisPrimary3D.ValueType = AxisValueType.DateTime;
But, end up, I get the result as shown in arction LegendBox.JPG:
[img]
result I get when I try to set the color legendBox using arction chart
result I get when I try to set the color legendBox using arction chart
arction legendBox.JPG (12.1 KiB) Viewed 10860 times
[/attachment][/img]

Below is my code for palette range

Code: Select all

   ValueRangePalette m_palette = new ValueRangePalette();
            m_palette.Steps.Clear();
            m_palette.MinValue = get_Now1(5);
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.DarkRed, get_Now1(0)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.DarkRed, get_Now1(5)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.Red, get_Now1(10)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.Yellow, get_Now1(15)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.GreenYellow, get_Now1(20)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.LightGreen, get_Now1(25)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.Turquoise, get_Now1(30)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.DeepSkyBlue, get_Now1(35)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.SteelBlue, get_Now1(40)));
            m_palette.Steps.Add(new PaletteStep(m_palette, Color.Blue, get_Now1(45)));
            m_palette.Type = PaletteType.Gradient;
Below is my code to get the time convert into double format since the palette Add.Step is only supporting type double

Code: Select all

private static double get_Now1(int minus)
        {
            return DateTime.Now.AddMinutes(-minus).ToOADate();
        }
Below is my chart LegendBox setting

Code: Select all

            m_chart3D.View3D.YAxisPrimary3D.AutoFormatLabels = false;
            m_chart3D.View3D.YAxisPrimary3D.LabelsTimeFormat = "HH:mm:ss";
            m_chart3D.View3D.YAxisPrimary3D.ValueType = AxisValueType.DateTime;
            m_chart3D.View3D.YAxisPrimary3D.Units.Text = "time";
            m_chart3D.View3D.YAxisPrimary3D.Reversed = true; //Show time now on top

            // Add IntensityGridSeries, which owns the palette
            SurfaceGridSeries3D grid = new SurfaceGridSeries3D(m_chart3D.View3D, Axis3DBinding.Primary,
                Axis3DBinding.Primary, Axis3DBinding.Primary);
            grid.WireframeType = SurfaceWireframeType.None;
            grid.ContourLineType = ContourLineType.None;
            grid.Fill = SurfaceFillStyle.Paletted;
            grid.Title.Text = "Date Time";
            grid.ContourPalette = m_palette;

            m_chart3D.View3D.SurfaceGridSeries3D.Add(grid);
Am I doing the correct way to set the palette step and legendBox time format?

Regards,
:firing: JH

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: How to format Palette step in datetime format?

Post by ArctionPasi » Tue Apr 16, 2013 12:36 pm

For the surface series, set:

Code: Select all

m_chart3D.View3D.SurfaceGridSeries3D[0].Title.Text = "Time"; 
Configure the Y axis as follows:

Code: Select all

m_chart3D.View3D.YAxisPrimary3D.Units.Text = "";
m_chart3D.View3D.YAxisPrimary3D.Reversed = false; 
m_chart3D.View3D.YAxisPrimary3D.ValueType = AxisValueType.DateTime;
Set the palette like this, here, I've used only 3 steps:

Code: Select all

DateTime dtNow = DateTime.Now;

Code: Select all

ValueRangePalette palette = m_chart3D.View3D.SurfaceGridSeries3D[0].ContourPalette; 
palette.Steps.Clear();
palette.MinValue = m_chart3D.View3D.YAxisPrimary3D.DateTimeToAxisValue(dtNow - TimeSpan.FromMinutes(45));
palette.Steps.Add(new PaletteStep(palette, Color.Blue, m_chart3D.View3D.YAxisPrimary3D.DateTimeToAxisValue(dtNow - TimeSpan.FromMinutes(45))));
palette.Steps.Add(new PaletteStep(palette, Color.Yellow, m_chart3D.View3D.YAxisPrimary3D.DateTimeToAxisValue(dtNow-TimeSpan.FromMinutes(15))));
palette.Steps.Add(new PaletteStep(palette, Color.Red, m_chart3D.View3D.YAxisPrimary3D.DateTimeToAxisValue(dtNow + TimeSpan.FromMinutes(0))));
palette.Type = PaletteType.Gradient;
Then the legend box will show up like this:
time_legendbox.jpg
time_legendbox.jpg (9.68 KiB) Viewed 10844 times
:ugeek:
LightningChart Support Team, PT

jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

Re: How to format Palette step in datetime format?

Post by jhyap » Tue Apr 16, 2013 12:51 pm

thumbs up

Post Reply