Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DataZoomHelper.cs 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. namespace XCharts.Runtime
  2. {
  3. public static class DataZoomHelper
  4. {
  5. public static void UpdateDataZoomRuntimeStartEndValue(DataZoom dataZoom, Serie serie)
  6. {
  7. if (dataZoom == null || serie == null)
  8. return;
  9. double min = 0;
  10. double max = 0;
  11. SerieHelper.GetMinMaxData(serie, out min, out max, null);
  12. dataZoom.context.startValue = min + (max - min) * dataZoom.start / 100;
  13. dataZoom.context.endValue = min + (max - min) * dataZoom.end / 100;
  14. }
  15. public static void UpdateDataZoomRuntimeStartEndValue<T>(BaseChart chart) where T : Serie
  16. {
  17. foreach (var component in chart.components)
  18. {
  19. if (component is DataZoom)
  20. {
  21. var dataZoom = component as DataZoom;
  22. if (!dataZoom.enable)
  23. continue;
  24. double min = double.MaxValue;
  25. double max = double.MinValue;
  26. foreach (var serie in chart.series)
  27. {
  28. if (!serie.show || !(serie is T))
  29. continue;
  30. if (!dataZoom.IsContainsXAxis(serie.xAxisIndex))
  31. continue;
  32. var axis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
  33. if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
  34. {
  35. if (axis.min < min)
  36. min = axis.min;
  37. if (axis.max > max)
  38. max = axis.max;
  39. }
  40. else
  41. {
  42. double serieMinValue = 0;
  43. double serieMaxValue = 0;
  44. SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, null, 2);
  45. if (serieMinValue < min)
  46. min = serieMinValue;
  47. if (serieMaxValue > max)
  48. max = serieMaxValue;
  49. }
  50. }
  51. dataZoom.context.startValue = min + (max - min) * dataZoom.start / 100;
  52. dataZoom.context.endValue = min + (max - min) * dataZoom.end / 100;
  53. }
  54. }
  55. }
  56. }
  57. }