Мои правила реагирования не применяются в Highcharts. NET.
Может ли кто-нибудь указать мне правильное направление?
Я хочу, чтобы шаг = 2 применялся при максимальной ширине 460.
Я могу поставить шаг = 2 на оси х в объекте старших графиков, но в результате на графике всегда будет 2 шага. Я хочу, чтобы это было только в случае применения адаптивного условия.
Это код моего контроллера:
public ActionResult FundInformation()
{
var fondsViewModel = new FondsViewModel();
List<Series> tmpList = new List<Series>();
List<string> colorList = new List<string>();
//var data = fonds.GrafiekData;
List<double> fondsdata = new List<double> { 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 54.4, 54.4, 54.4, 54.4, 54.4 };
List<ColumnSeriesData> fondslist = new List<ColumnSeriesData>();
fondsdata.ForEach(p => fondslist.Add(new ColumnSeriesData { Y = p }));
ColumnSeries Cs = new ColumnSeries
{
Name = "Fonds",
Data = fondslist,
Stack = "ul",
};
tmpList.Add(Cs);
colorList.Add("#CCCCCC");
var chartId = $"chart{Guid.NewGuid().ToString("N")}";
Highcharts myChart = new Highcharts()
{
Colors = colorList,
Chart = new Chart
{
ClassName = "grafiek",
//StyledMode = true,
Height = 135,
Type = ChartType.Column,
Events = new ChartEvents
{
//Redraw = "function(e) {console.log(this)}"
}
},
Title = new Title
{
Text = "Fonds"
},
Credits = new Credits
{
Enabled = false
},
Legend = new Legend
{
Enabled = false
},
XAxis = new List<XAxis>
{
new XAxis
{
GridLineWidth= 0,
Min = 1,
Max = Cs.Data.Count(),
TickAmount = Cs.Data.Count(),
Reversed = true,
StartOnTick = true,
Labels = new XAxisLabels
{
Enabled= true,
//Step=2
}
}
},
YAxis = new List<YAxis>
{
new YAxis
{
TickAmount = 3,
GridLineWidth = 0.5,
MinorGridLineWidth = 0,
AllowDecimals = false,
Title = new YAxisTitle
{
Enabled = false
},
Labels = new YAxisLabels
{
Enabled = true,
Format = "{value}%",
},
StackLabels = new YAxisStackLabels
{
Enabled = false
}
}
},
Tooltip = new Tooltip
{
Enabled = false,
Shared = true,
Shadow = new Shadow
{
Enabled = false
}
},
PlotOptions = new PlotOptions
{
Column = new PlotOptionsColumn
{
Stacking = PlotOptionsColumnStacking.Normal,
PointStart = 1,
PointPadding = 0,
GroupPadding = 0.03,
BorderWidth = 0,
},
Series = new PlotOptionsSeries
{
EnableMouseTracking = false,
States = new PlotOptionsSeriesStates
{
Hover = new PlotOptionsSeriesStatesHover
{
Enabled = false
},
},
DataLabels = new PlotOptionsSeriesDataLabels
{
Enabled = false,
Y = -35,
Rotation = 0,
Align = PlotOptionsSeriesDataLabelsAlign.Center,
Inside = true,
}
}
},
Responsive = new Responsive
{
Rules = new List<ResponsiveRules>
{
new ResponsiveRules
{
Condition = new ResponsiveRulesCondition
{
MaxWidth=460,
},
ChartOptions = new
{
XAxis = new List<XAxis>
{
new XAxis
{
Labels = new XAxisLabels
{
Step = 2,
}
}
},
}
},
}
},
Series = tmpList,
};
myChart.ID = chartId;
fondsViewModel.FondsId = chartId;
fondsViewModel.Chart = myChart;
fondsViewModel.FondsNaam = "Some name fonds";
fondsViewModel.LabelFondsBeschrijvingKnop = "Omschrijving";
fondsViewModel.FondsBeschrijvingContent = "Something something";
fondsViewModel.FondsBeschrijvingUrl = "Something.com";
return View(fondsViewModel);
}
И это мой код просмотра:
@model WebApplication3.Controllers.FondsViewModel
@using Highsoft.Web.Mvc.Charts.Rendering
@{
var renderer = new HighchartsRenderer(Model.Chart, "somekey");
}
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div class="pensioen-bij-row verdeling">
<div class="fondsdetail">
<div id="@Model.FondsId" class="grafiek"></div>
@Html.Raw(renderer.RenderHtml(false))
<button class="fondsbeschrijving">@Model.LabelFondsBeschrijvingKnop</button>
<div class="beschrijving">
@Html.Raw(Model.FondsBeschrijvingContent)
<a class="externe-link" href="@Model.FondsBeschrijvingUrl" target="_blank"><span>@Model.FondsNaam</span></a>
</div>
</div>
</div>
Я использую Highsoft.Highcharts 8.0.