Try the following example:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store s = this.Chart1.GetStore();
s.DataSource = new object[]
{
new
{
x = 0,
y = 0
},
new
{
x = 2,
y = 1
},
new
{
x = 3,
y = 2
}
};
s.DataBind();
}
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<script>
var noDecimalsRenderer = function (value, i) {
if (i != null && i == 0)
this.axisLabels = [];
value = Math.round(value);
console.log(value);
if (this.axisLabels.indexOf(value) != -1)
return '';
else {
this.axisLabels.push(value);
return value;
}
};
Ext.override(Ext.chart.axis.Axis, {
drawVerticalLabels: function () {
var me = this,
inflections = me.inflections,
position = me.position,
ln = inflections.length,
chart = me.chart,
insetPadding = chart.insetPadding,
labels = me.labels,
maxWidth = 0,
max = Math.max,
floor = Math.floor,
ceil = Math.ceil,
axes = me.chart.axes,
gutters = me.chart.maxGutters,
bbox, point, prevLabel, prevLabelId,
hasTop = axes.findIndex('position', 'top') != -1,
hasBottom = axes.findIndex('position', 'bottom') != -1,
adjustEnd = me.adjustEnd,
textLabel, text,
last = ln - 1, x, y, i;
for (i = 0; i < ln; i++) {
point = inflections[i];
text = me.label.renderer(labels[i], i);
textLabel = me.getOrCreateLabel(i, text);
bbox = textLabel._bbox;
maxWidth = max(maxWidth, bbox.width + me.dashSize + me.label.padding);
y = point[1];
if (adjustEnd && (gutters.bottom + gutters.top) < bbox.height / 2) {
if (i == last && !hasTop) {
y = Math.max(y, me.y - me.length + ceil(bbox.height / 2) - insetPadding);
}
else if (i == 0 && !hasBottom) {
y = me.y + gutters.bottom - floor(bbox.height / 2);
}
}
if (position == 'left') {
x = point[0] - bbox.width - me.dashSize - me.label.padding - 2;
}
else {
x = point[0] + me.dashSize + me.label.padding + 2;
}
textLabel.setAttributes(Ext.apply({
hidden: false,
x: x,
y: y
}, me.label), true);
if (i != 0 && me.intersect(textLabel, prevLabel)) {
if (i === last && prevLabelId !== 0) {
prevLabel.hide(true);
} else {
textLabel.hide(true);
continue;
}
}
prevLabel = textLabel;
prevLabelId = i;
}
return maxWidth;
},
drawHorizontalLabels: function () {
var me = this,
labelConf = me.label,
floor = Math.floor,
max = Math.max,
axes = me.chart.axes,
insetPadding = me.chart.insetPadding,
gutters = me.chart.maxGutters,
position = me.position,
inflections = me.inflections,
ln = inflections.length,
labels = me.labels,
maxHeight = 0,
ratio,
bbox, point, prevLabel, prevLabelId,
adjustEnd = me.adjustEnd,
hasLeft = axes.findIndex('position', 'left') != -1,
hasRight = axes.findIndex('position', 'right') != -1,
textLabel, text,
last, x, y, i, firstLabel;
last = ln - 1;
point = inflections[0];
firstLabel = me.getOrCreateLabel(0, me.label.renderer(labels[0], 0));
ratio = Math.floor(Math.abs(Math.sin(labelConf.rotate && (labelConf.rotate.degrees * Math.PI / 180) || 0)));
for (i = 0; i < ln; i++) {
point = inflections[i];
text = me.label.renderer(labels[i], i);
textLabel = me.getOrCreateLabel(i, text);
bbox = textLabel._bbox;
maxHeight = max(maxHeight, bbox.height + me.dashSize + me.label.padding);
x = floor(point[0] - (ratio ? bbox.height : bbox.width) / 2);
if (adjustEnd && gutters.left == 0 && gutters.right == 0) {
if (i == 0 && !hasLeft) {
x = point[0];
}
else if (i == last && !hasRight) {
x = Math.min(x, point[0] - bbox.width + insetPadding);
}
}
if (position == 'top') {
y = point[1] - (me.dashSize * 2) - me.label.padding - (bbox.height / 2);
}
else {
y = point[1] + (me.dashSize * 2) + me.label.padding + (bbox.height / 2);
}
textLabel.setAttributes({
hidden: false,
x: x,
y: y
}, true);
if (i != 0 && (me.intersect(textLabel, prevLabel) || me.intersect(textLabel, firstLabel))) {
if (i === last && prevLabelId !== 0) {
prevLabel.hide(true);
} else {
textLabel.hide(true);
continue;
}
}
prevLabel = textLabel;
prevLabelId = i;
}
return maxHeight;
}
});
</script>
<ext:Chart ID="Chart1" runat="server" Width="400" Height="400">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="x" />
<ext:ModelField Name="y" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Axes>
<ext:NumericAxis Title="X" Fields="x" Position="Bottom">
<Label>
<Renderer Fn="noDecimalsRenderer" />
</Label>
</ext:NumericAxis>
<ext:NumericAxis Title="Y" Fields="y" Position="Left">
<Label>
<Renderer Fn="noDecimalsRenderer" />
</Label>
</ext:NumericAxis>
</Axes>
<Series>
<ext:LineSeries Titles="Chart" XField="x" YField="y" />
</Series>
</ext:Chart>
</body>
</html>