/// <summary> /// Resolve axis references with error info. /// </summary> /// <param name="icrc">The context.</param> protected void EnsureAxes(IChartComponentContext icrc) { IChartErrorInfo icei = icrc as IChartErrorInfo; if (CategoryAxis2 == null) { if (!String.IsNullOrEmpty(CategoryAxis2Name)) { CategoryAxis2 = icrc.Find(CategoryAxis2Name) as IChartAxis; if (CategoryAxis2 == null) { icei?.Report(new ChartValidationResult(NameOrType(), $"Value axis '{CategoryAxis2Name}' was not found", new[] { nameof(CategoryAxis2), nameof(CategoryAxis2Name) })); } } else { icei?.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(CategoryAxis2)}' was not set", new[] { nameof(CategoryAxis2), nameof(CategoryAxis2) })); } } if (CategoryAxis1 == null) { if (!String.IsNullOrEmpty(CategoryAxisName)) { CategoryAxis1 = icrc.Find(CategoryAxisName) as IChartAxis; if (CategoryAxis1 == null) { icei?.Report(new ChartValidationResult(NameOrType(), $"Value axis '{CategoryAxisName}' was not found", new[] { nameof(CategoryAxis1), nameof(CategoryAxisName) })); } } else { icei?.Report(new ChartValidationResult(NameOrType(), $"Property '{nameof(CategoryAxisName)}' was not set", new[] { nameof(CategoryAxis1), nameof(CategoryAxisName) })); } } }
/// <summary> /// Resolve axis references. /// </summary> /// <param name="iccc">The context.</param> protected void EnsureAxes(IChartComponentContext iccc) { if (ValueAxis == null && !String.IsNullOrEmpty(ValueAxisName)) { ValueAxis = iccc.Find(ValueAxisName) as IChartAxis; } else { if (iccc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(NameOrType(), $"Value axis '{ValueAxisName}' was not found", new[] { nameof(ValueAxis), nameof(ValueAxisName) })); } } }
/// <summary> /// Resolve component and axis references. /// </summary> /// <param name="icrc">The context.</param> protected void EnsureComponents(IChartComponentContext icrc) { if (LabelTemplate == null) { if (Theme?.TextBlockTemplate == null) { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(NameOrType(), $"No {nameof(LabelTemplate)} and {nameof(Theme.TextBlockTemplate)} was not found", new[] { nameof(LabelTemplate), nameof(Theme.TextBlockTemplate) })); } } } if (Source == null && !String.IsNullOrEmpty(SourceName)) { Source = icrc.Find(SourceName); } else { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(NameOrType(), $"Source '{SourceName}' was not found", new[] { nameof(Source), nameof(SourceName) })); } } if (Source == null) { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(NameOrType(), $"Source '{SourceName}' lookup failed; no other components can resolve", new[] { nameof(Source), nameof(SourceName) })); } return; } else { if (!(Source is IProvideSeriesItemValues)) { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(Source.NameOrType(), $"Source '{SourceName}' does not provide values; no labels will generate", new[] { nameof(Source), nameof(SourceName) })); } return; } } if (Source is IRequireCategoryAxis irca) { if (CategoryAxis == null && !String.IsNullOrEmpty(irca.CategoryAxisName)) { CategoryAxis = icrc.Find(irca.CategoryAxisName) as IChartAxis; } else { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(Source.NameOrType(), $"Category axis '{irca.CategoryAxisName}' was not found", new[] { nameof(CategoryAxis), nameof(irca.CategoryAxisName) })); } } } if (Source is IProvideValueExtents ipve) { if (ValueAxis == null && !String.IsNullOrEmpty(ipve.ValueAxisName)) { ValueAxis = icrc.Find(ipve.ValueAxisName) as IChartAxis; } else { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(Source.NameOrType(), $"Value axis '{ipve.ValueAxisName}' was not found", new[] { nameof(ValueAxis), nameof(ipve.ValueAxisName) })); } } } else if (Source is IRequireCategoryAxis2 irca2) { if (ValueAxis == null && !String.IsNullOrEmpty(irca2.CategoryAxis2Name)) { ValueAxis = icrc.Find(irca2.CategoryAxis2Name) as IChartAxis; } else { if (icrc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(Source.NameOrType(), $"Category 2 axis '{irca2.CategoryAxis2Name}' was not found", new[] { nameof(ValueAxis), nameof(irca2.CategoryAxis2Name) })); } } } }