Skip to content

Commit 001bd58

Browse files
committed
Implemented Options3d and ParallelAxes
1 parent b3cfc66 commit 001bd58

17 files changed

+1146
-19
lines changed

DotNet.Highcharts/DotNet.Highcharts/DotNet.Highcharts.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<Reference Include="System.Xml" />
5959
</ItemGroup>
6060
<ItemGroup>
61+
<Compile Include="Enums\TickmarkPlacements.cs" />
62+
<Compile Include="Helpers\StringNumber.cs" />
63+
<Compile Include="Helpers\StringBool.cs" />
6164
<Compile Include="Options\Accessibility\Accessibility.cs" />
6265
<Compile Include="Options\Accessibility\AccessibilityKeyboardNavigation.cs" />
6366
<Compile Include="Options\Accessibility\AccessibilityKeyboardNavigationModes.cs" />
@@ -135,7 +138,16 @@
135138
<Compile Include="Options\Navigation.cs" />
136139
<Compile Include="Options\NavigationButtonOptions.cs" />
137140
<Compile Include="Options\Navigator.cs" />
141+
<Compile Include="Options\Options3d\Options3d.cs" />
142+
<Compile Include="Options\Options3d\Options3dFrame.cs" />
143+
<Compile Include="Options\Options3d\Options3dFrameSide.cs" />
144+
<Compile Include="Options\Options3d\Options3dSpecificFrameSide.cs" />
138145
<Compile Include="Options\Pane.cs" />
146+
<Compile Include="Options\ParallelAxes\ParallelAxes.cs" />
147+
<Compile Include="Options\ParallelAxes\ParallelAxesCrosshair.cs" />
148+
<Compile Include="Options\ParallelAxes\ParallelAxesEvents.cs" />
149+
<Compile Include="Options\ParallelAxes\ParallelAxesLabels.cs" />
150+
<Compile Include="Options\ParallelAxes\ParallelAxesTitle.cs" />
139151
<Compile Include="Options\PlotOptions\PlotOptions.cs" />
140152
<Compile Include="Options\PlotOptions\PlotOptionsArea.cs" />
141153
<Compile Include="Options\PlotOptions\PlotOptionsAreaDataLabels.cs" />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace DotNet.Highcharts.Enums
2+
{
3+
public enum TickmarkPlacements
4+
{
5+
Between,
6+
On
7+
}
8+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System.Globalization;
2+
3+
namespace DotNet.Highcharts.Helpers
4+
{
5+
public struct StringBool
6+
{
7+
private readonly bool? _bool;
8+
private readonly string _string;
9+
10+
public StringBool(string str)
11+
{
12+
_string = str;
13+
_bool = null;
14+
}
15+
16+
public StringBool(bool boolean)
17+
{
18+
_bool = boolean;
19+
_string = null;
20+
}
21+
22+
public static implicit operator StringBool(string value) { return new StringBool(value); }
23+
public static implicit operator StringBool(bool value) { return new StringBool(value); }
24+
25+
public static StringBool GetValue(object o)
26+
{
27+
switch (o)
28+
{
29+
case string _:
30+
return new StringBool((string)o);
31+
case Number _:
32+
return new StringBool((bool)o);
33+
}
34+
35+
return new StringBool();
36+
}
37+
38+
public static implicit operator string(StringBool a)
39+
{
40+
if (a._string != null)
41+
return a._string;
42+
43+
return a._bool.HasValue ?
44+
a._bool.ToString() : null;
45+
}
46+
47+
public static implicit operator bool? (StringBool a)
48+
{
49+
if (a._bool.HasValue)
50+
return a._bool;
51+
52+
return a._string != null ? a : null;
53+
}
54+
55+
public override string ToString()
56+
{
57+
if (_bool.HasValue)
58+
return _bool.ToString();
59+
60+
return _string?.ToString(CultureInfo.InvariantCulture) ?? string.Empty;
61+
}
62+
}
63+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System.Globalization;
2+
3+
namespace DotNet.Highcharts.Helpers
4+
{
5+
public struct StringNumber
6+
{
7+
private readonly Number? _heightInPixels;
8+
private readonly string _heightInPercent;
9+
10+
public StringNumber(string percent)
11+
{
12+
_heightInPercent = percent;
13+
_heightInPixels = null;
14+
}
15+
16+
public StringNumber(Number number)
17+
{
18+
_heightInPixels = number;
19+
_heightInPercent = null;
20+
}
21+
22+
public static implicit operator StringNumber(string value) { return new StringNumber(value); }
23+
public static implicit operator StringNumber(Number value) { return new StringNumber(value); }
24+
public static implicit operator StringNumber(int value) { return new StringNumber(value); }
25+
public static implicit operator StringNumber(double value) { return new StringNumber(value); }
26+
27+
public static StringNumber GetHeight(object o)
28+
{
29+
switch (o)
30+
{
31+
case string _:
32+
return new StringNumber((string)o);
33+
case Number _:
34+
return new StringNumber((Number)o);
35+
}
36+
37+
return new StringNumber();
38+
}
39+
40+
public static implicit operator string(StringNumber a)
41+
{
42+
if (a._heightInPercent != null)
43+
return a._heightInPercent;
44+
45+
return a._heightInPixels.HasValue ?
46+
a._heightInPixels.ToString() : null;
47+
}
48+
49+
public static implicit operator Number? (StringNumber a)
50+
{
51+
if (a._heightInPixels.HasValue)
52+
return a._heightInPixels;
53+
54+
return a._heightInPercent != null ? a : null;
55+
}
56+
57+
public override string ToString()
58+
{
59+
if (_heightInPixels.HasValue)
60+
return _heightInPixels.ToString();
61+
62+
return _heightInPercent?.ToString(CultureInfo.InvariantCulture) ?? string.Empty;
63+
}
64+
}
65+
}

DotNet.Highcharts/DotNet.Highcharts/Highcharts.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ public virtual string GetOptions()
391391
}
392392
else
393393
{
394-
options.Append(_chart != null ? "chart: {{ renderTo:'{0}', {1} }}".FormatWith(ContainerName, JsonSerializer.Serialize(_chart, false)) : "chart: {{ renderTo:'{0}' }}".FormatWith(ContainerName));
394+
options.Append(_chart != null ?
395+
"chart: {{ renderTo:'{0}', {1} }}".FormatWith(ContainerName, JsonSerializer.Serialize(_chart, false)) :
396+
"chart: {{ renderTo:'{0}' }}".FormatWith(ContainerName));
395397
}
396398

397399
if (_accessibility != null)

DotNet.Highcharts/DotNet.Highcharts/JsonSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static string GetValue(object value, Type type, JsonFormatter formatter)
147147
jsonFormat = JSON_DEFAULT_FORMAT;
148148
return GetJsonString(formatter.JsonValueFormat, jsonFormat, value.ToString().Replace("\r\n", " ").Replace(" ", ""));
149149
}
150-
if (value is int || value is long || value is short || value is byte || type == typeof(Number))
150+
if (value is int || value is long || value is short || value is byte || type == typeof(Number) || type == typeof(StringNumber) || type == typeof(StringBool))
151151
return GetJsonString(formatter.JsonValueFormat, JSON_DEFAULT_FORMAT, value.ToString());
152152
if (value is double)
153153
return GetJsonString(formatter.JsonValueFormat, JSON_DEFAULT_FORMAT, ((double)value).ToString(CultureInfo.InvariantCulture));

DotNet.Highcharts/DotNet.Highcharts/Options/Chart.cs

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using DotNet.Highcharts.Enums;
44
using DotNet.Highcharts.Attributes;
55
using DotNet.Highcharts.Helpers;
6+
// ReSharper disable InconsistentNaming
67

78
namespace DotNet.Highcharts.Options
89
{
@@ -58,6 +59,7 @@ public class Chart
5859
/// Alias of <code>type</code>.
5960
/// Default: line
6061
/// </summary>
62+
[Obsolete]
6163
public ChartTypes? DefaultSeriesType { get; set; }
6264

6365
/// <summary>
@@ -72,10 +74,12 @@ public class Chart
7274
/// </summary>
7375
public ChartEvents Events { get; set; }
7476

75-
/// <summary>
76-
/// An explicit height for the chart. By default the height is calculated from the offset height of the containing element, or 400 pixels if the containing element's height is 0.
77-
/// </summary>
78-
public Number? Height { get; set; }
77+
/// <summary>
78+
/// An explicit height for the chart. If a number, the height is given in pixels. If given a percentage string (for example '56%'), the height is given as the percentage of the actual chart width. This allows for preserving the aspect ratio across responsive sizes.
79+
/// By default (when null) the height is calculated from the offset height of the containing element, or 400 pixels if the containing element's height is 0.
80+
/// Default: null
81+
/// </summary>
82+
public StringNumber? Height { get; set; }
7983

8084
/// <summary>
8185
/// If true, the axes will scale to the remaining visible series once one series is hidden. If false, hiding and showing a series will not affect the axes or the other series. For stacks, once one series within the stack is hidden, the rest of the stack will close in around it even if the axis is not affected.
@@ -92,7 +96,7 @@ public class Chart
9296
/// <summary>
9397
/// <p>The margin between the outer edge of the chart and the plot area. The numbers in the array designate top, right, bottom and left respectively. Use the options <code>marginTop</code>, <code>marginRight</code>, <code>marginBottom</code> and <code>marginLeft</code> for shorthand setting of one option.</p> <p>Since version 2.1, the margin is 0 by default. The actual space is dynamically calculated from the offset of axis labels, axis title, title, subtitle and legend in addition to the <code>spacingTop</code>, <code>spacingRight</code>, <code>spacingBottom</code> and <code>spacingLeft</code> options.</p> Defaults to <code>[null]</code>.
9498
/// </summary>
95-
public int[] Margin { get; set; }
99+
public Number?[] Margin { get; set; }
96100

97101
/// <summary>
98102
/// The margin between the bottom outer edge of the chart and the plot area. Use this to set a fixed pixel value for the margin as opposed to the default dynamic margin. See also <code>spacingBottom</code>.
@@ -114,6 +118,51 @@ public class Chart
114118
/// </summary>
115119
public Number? MarginTop { get; set; }
116120

121+
/// <summary>
122+
/// Options to render charts in 3 dimensions. This feature requires highcharts-3d.js, found in the download package or online at code.highcharts.com/highcharts-3d.js.
123+
/// </summary>
124+
public Options3d.Options3d Options3d { get; set; }
125+
126+
/// <summary>
127+
/// Allows setting a key to switch between zooming and panning. Can be one of alt, ctrl, meta (the command key on Mac and Windows key on Windows) or shift. The keys are mapped directly to the key properties of the click event argument (event.altKey, event.ctrlKey, event.metaKey and event.shiftKey).
128+
/// Default: undefined
129+
/// </summary>
130+
public string PanKey { get; set; }
131+
132+
/// <summary>
133+
/// Allow panning in a chart. Best used with panKey to combine zooming and panning.
134+
/// On touch devices, when the tooltip.followTouchMove option is true (default), panning requires two fingers. To allow panning with one finger, set followTouchMove to false.
135+
/// Default: false
136+
/// </summary>
137+
public bool? Panning { get; set; }
138+
139+
/// <summary>
140+
/// Common options for all yAxes rendered in a parallel coordinates plot. This feature requires modules/parallel-coordinates.js.
141+
/// The default options are:
142+
///parallelAxes: {
143+
/// lineWidth: 1, // classic mode only
144+
/// gridlinesWidth: 0, // classic mode only
145+
/// title: {
146+
/// text: '',
147+
/// reserveSpace: false
148+
/// },
149+
/// labels: {
150+
/// x: 0,
151+
/// y: 0,
152+
/// align: 'center',
153+
/// reserveSpace: false
154+
/// },
155+
/// offset: 0
156+
/// }
157+
/// </summary>
158+
public ParallelAxes.ParallelAxes ParallelAxes { get; set; }
159+
160+
/// <summary>
161+
/// Flag to render charts as a parallel coordinates plot. In a parallel coordinates plot (||-coords) by default all required yAxes are generated and the legend is disabled. This feature requires modules/parallel-coordinates.js.
162+
/// Default: false
163+
/// </summary>
164+
public bool? ParallelCoordinates { get; set; }
165+
117166
/// <summary>
118167
/// Equivalent to <a href='#chart.zoomType'>zoomType</a>, but for multitouch gestures only. By default, the <code>pinchType</code> is the same as the <code>zoomType</code> setting. However, pinching can be enabled separately in some cases, for example in stock charts where a mouse drag pans the chart, while pinching is enabled.
119168
/// Default: null

0 commit comments

Comments
 (0)