FAQ/How-do-I-set-only-one-Y-axis-in-a-chart.md
... ...
@@ -4,13 +4,13 @@
4 4
5 5
##Purpose
6 6
7
-By default, Izenda uses HTML charting engine. Charting engine can be set via AdHocSettings.ChartingEngine. For more information, refer to [[ChartingEngine|http://wiki.izenda.us/API/CodeSamples/ChartingEngine]]
7
+By default, Izenda uses HTML charting engine. Charting engine can be set via AdHocSettings.ChartingEngine. For more information, refer to [[ChartingEngine|http://wiki.izenda.us/API/CodeSamples/ChartingEngine]].
8 8
9 9
Izenda charts will display two or more y axes on a chart if multiple plotted items have different ranges. This is to prevent very high values from making lower values unreadably small on the chart, and allow for proportional comparison.
10 10
11 11
If you would like to override this feature and display only one chart, you can use the following code:
12 12
13
-###C#
13
+### C# (Dundas engine)
14 14
```csharp
15 15
public override void CustomizeDundasChart(object chart, Hashtable properties, Type chartType)
16 16
{
... ...
@@ -24,6 +24,51 @@ public override void CustomizeDundasChart(object chart, Hashtable properties, Ty
24 24
dchart.Series[1].YAxisType = Dundas.Charting.WebControl.AxisType.Primary;
25 25
}
26 26
```
27
+### C# (HTML engine)
28
+Code to hide the right Y axis:
29
+```csharp
30
+/* HTML charts */
31
+public override void CustomizeChart(object chart, Hashtable properties)
32
+{
33
+ if (chart is StringBuilder)
34
+ {
35
+ StringBuilder sb = (StringBuilder)chart;
36
+ String strChart = sb.ToString();
37
+
38
+ if (!strChart.Contains("BarChart"))
39
+ return;
40
+
41
+ string pattern = @"var\s+(?BarChart\d+Instance);";
42
+ string chartVarName = Regex.Match(strChart, pattern).Groups["chartvarname"].Value;
43
+
44
+ sb = sb.Replace("} catch (e) {", "var yAxisLength = " + chartVarName + ".yAxis.length; if(yAxisLength > 1){ for(var i = 1; i < yAxisLength; ++i){" + chartVarName + ".options.yAxis[i].labels.enabled = false; " + chartVarName + ".options.yAxis[i].title.text = null; " + chartVarName + ".yAxis[i].update();}}} catch (e) {");
45
+ }
46
+
47
+ base.CustomizeChart(chart, properties);
48
+}
49
+```
50
+Сode to use a common left Y axis:
51
+```csharp
52
+/* HTML charts */
53
+public override void CustomizeChart(object chart, Hashtable properties)
54
+{
55
+ if (chart is StringBuilder)
56
+ {
57
+ StringBuilder sb = (StringBuilder)chart;
58
+ String strChart = sb.ToString();
59
+
60
+ if (!strChart.Contains("BarChart"))
61
+ return;
62
+
63
+ sb = sb.Replace("yAxis: 1", "");
64
+ }
65
+
66
+ base.CustomizeChart(chart, properties);
67
+}
68
+
69
+```
70
+
71
+
27 72
###VB
28 73
```visualbasic
29 74
Public Overrides Sub CustomizeDundasChart(chart As Object, properties As Hashtable, chartType As Type)