There was a problem with the construction of 4 charts in the Chart. The graphs have different maximum values, but I need to make it so that all the graphs are visible regardless of scale. An example in the attached file. Example

I set up a series. aria and markers:

// Π Π°Π±ΠΎΡ‚Π°Π΅ΠΌ с Π³Ρ€Π°Ρ„ΠΈΠΊΠ°ΠΌΠΈ chGrafik.Series[0].LegendText = "Π• ΠΏΠΎΠ»Π΅"; chGrafik.Series[1].LegendText = "H ΠΏΠΎΠ»Π΅"; chGrafik.Series[2].LegendText = "Π“Π»ΡƒΠ±ΠΈΠ½Π°"; chGrafik.Series[3].LegendText = "Π’ΠΎΠΊ"; chGrafik.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[0].CursorX.AutoScroll = true; chGrafik.ChartAreas[0].AxisX.ScrollBar.Enabled = true; chGrafik.Series[0].IsValueShownAsLabel = false; // ΠΏΡ€ΠΈ true ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ‚ΠΎΡ‡ΠΊΠΈ Π² Π²ΠΈΠ΄Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ chGrafik.Series[0].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; // ΡΡ‚ΠΈΠ»ΡŒ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° Ρ‚ΠΎΡ‡ΠΊΠΈ Π΄Π°Π½Π½Ρ‹Ρ… chGrafik.Series[0].MarkerSize = 6; chGrafik.Series[0].MarkerColor = chGrafik.Series[0].Color; //Ρ†Π²Π΅Ρ‚ Ρ‚ΠΎΡ‡ΠΊΠΈ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.Series[0].Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Bold); //настройка ΡˆΡ€ΠΈΡ„Ρ‚Π° ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.ChartAreas[1].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[1].CursorX.AutoScroll = true; chGrafik.ChartAreas[1].AxisX.ScrollBar.Enabled = true; chGrafik.Series[1].IsValueShownAsLabel = false; // ΠΏΡ€ΠΈ true ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ‚ΠΎΡ‡ΠΊΠΈ Π² Π²ΠΈΠ΄Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ chGrafik.Series[1].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; // ΡΡ‚ΠΈΠ»ΡŒ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° Ρ‚ΠΎΡ‡ΠΊΠΈ Π΄Π°Π½Π½Ρ‹Ρ… chGrafik.Series[1].MarkerSize = 6; chGrafik.Series[1].MarkerColor = chGrafik.Series[1].Color; //Ρ†Π²Π΅Ρ‚ Ρ‚ΠΎΡ‡ΠΊΠΈ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.Series[1].Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Bold); //настройка ΡˆΡ€ΠΈΡ„Ρ‚Π° ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.ChartAreas[2].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[2].CursorX.AutoScroll = true; chGrafik.ChartAreas[2].AxisX.ScrollBar.Enabled = true; chGrafik.Series[2].IsValueShownAsLabel = false; // ΠΏΡ€ΠΈ true ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ‚ΠΎΡ‡ΠΊΠΈ Π² Π²ΠΈΠ΄Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ chGrafik.Series[2].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; // ΡΡ‚ΠΈΠ»ΡŒ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° Ρ‚ΠΎΡ‡ΠΊΠΈ Π΄Π°Π½Π½Ρ‹Ρ… chGrafik.Series[2].MarkerSize = 6; chGrafik.Series[2].MarkerColor = chGrafik.Series[2].Color; //Ρ†Π²Π΅Ρ‚ Ρ‚ΠΎΡ‡ΠΊΠΈ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.Series[2].Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Bold); //настройка ΡˆΡ€ΠΈΡ„Ρ‚Π° ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.ChartAreas[3].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[3].CursorX.AutoScroll = true; chGrafik.ChartAreas[3].AxisX.ScrollBar.Enabled = true; chGrafik.Series[3].IsValueShownAsLabel = false; // ΠΏΡ€ΠΈ true ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ‚ΠΎΡ‡ΠΊΠΈ Π² Π²ΠΈΠ΄Π΅ ΠΌΠ΅Ρ‚ΠΊΠΈ chGrafik.Series[3].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; // ΡΡ‚ΠΈΠ»ΡŒ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° Ρ‚ΠΎΡ‡ΠΊΠΈ Π΄Π°Π½Π½Ρ‹Ρ… chGrafik.Series[3].MarkerSize = 6; chGrafik.Series[3].MarkerColor = chGrafik.Series[3].Color; //Ρ†Π²Π΅Ρ‚ Ρ‚ΠΎΡ‡ΠΊΠΈ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° chGrafik.Series[3].Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Bold); //настройка ΡˆΡ€ΠΈΡ„Ρ‚Π° ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Π° // рисуСм Π³Ρ€Π°Ρ„ΠΈΠΊΠΈ chGrafik.ChartAreas[0].CursorX.IsUserEnabled = true; chGrafik.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chGrafik.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true; chGrafik.ChartAreas[1].CursorX.IsUserEnabled = true; chGrafik.ChartAreas[1].CursorX.IsUserSelectionEnabled = true; chGrafik.ChartAreas[1].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[1].AxisX.ScrollBar.IsPositionedInside = true; chGrafik.ChartAreas[2].CursorX.IsUserEnabled = true; chGrafik.ChartAreas[2].CursorX.IsUserSelectionEnabled = true; chGrafik.ChartAreas[2].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[2].AxisX.ScrollBar.IsPositionedInside = true; chGrafik.ChartAreas[3].CursorX.IsUserEnabled = true; chGrafik.ChartAreas[3].CursorX.IsUserSelectionEnabled = true; chGrafik.ChartAreas[3].AxisX.ScaleView.Zoomable = true; chGrafik.ChartAreas[3].AxisX.ScrollBar.IsPositionedInside = true; // Наносим Π½Π° ΠΊΠ°Ρ€Ρ‚Ρƒ ΠΌΠ°Ρ€ΠΊΠ΅Ρ€Ρ‹ Ρ‚ΠΎΡ‡Π΅ΠΊ. Π‘Ρ‚Ρ€ΠΎΠΈΠΌ Π³Ρ€Π°Ρ„ΠΈΠΊ for (int k = 0; k <= latitude.Length - 1; k++) { // РасчитываСм ΠœΠ°ΠΊΡΠΈΠΌΠ°Π»ΡŒΠ½Ρ€ΠΎΠ΅ минимальноС для Π³Π»ΡƒΠ±ΠΈΠ½Ρ‹. Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ Π³Π»ΡƒΠ±ΠΈΠ½Ρƒ double maxx = Math.Max(Glub[k], Glub[k + 1]); if (tmax < maxx + maxx) { tmax = maxx + maxx; chGrafik.ChartAreas[0].AxisY.Maximum = maxx + maxx; chGrafik.ChartAreas[0].AxisY.Minimum = 0; } chGrafik.Series[0].Points.AddY(Glub[k]); chGrafik.ChartAreas[0].AxisX.ScrollBar.Axis.ScaleView.Position = k-15; double maxx2 = Math.Max(E_Pole[k], E_Pole[k + 1]); if (tmax2 < maxx2 + maxx2) { tmax2 = maxx2 + maxx2; chGrafik.ChartAreas[1].AxisY.Maximum = maxx2 + maxx2; chGrafik.ChartAreas[1].AxisY.Minimum = 0; } chGrafik.Series[1].Points.AddY(E_Pole[k]); double maxx3 = Math.Max(Tok[k], Tok[k + 1]); if (tmax3 < maxx3 + maxx3) { tmax3 = maxx3 + maxx3; chGrafik.ChartAreas[2].AxisY.Maximum = maxx3 + maxx3; chGrafik.ChartAreas[2].AxisY.Minimum = 0; } chGrafik.Series[2].Points.AddY(Tok[k]); double maxx4 = Math.Max(H_Pole[k], H_Pole[k + 1]); if (tmax4 < maxx4 + maxx4) { tmax4 = maxx4 + maxx4; chGrafik.ChartAreas[3].AxisY.Maximum = maxx4 + maxx4; chGrafik.ChartAreas[3].AxisY.Minimum = 0; } chGrafik.Series[3].Points.AddY(H_Pole[k]); // } 

The result is this: enter image description here

1) I don’t know how to display scales of X values ​​for all graphs 2) For some reason, the output area of ​​graphs is not on the entire chart. 3) Need to do with the scroll bar. Now that a scroll bar appears, you need to increase the graph once with the mouse.

  • Can not do as in the picture. I configure my ChartAreas for each chart. When displaying graphs, only the last one is displayed. - DarkSeed
  • one
    Edit the question, add a description of how and what you are doing, and how and what comes out right or wrong. - Kromster

1 answer 1

The standard Chart control has only two Y axes, so it’s impossible to implement explicitly using standard tools. If you need just such a result, then it is best to search and try third-party controls for building graphs.


On the standard control, you can use a different approach. Three graphs are located above the X axis, we attach them to one of the available Y axes, for example, to Primary and set the logarithmic format on it in order to see both large and small values ​​equally well. The last graph, which you have turned upside down, is tied to another additional Y axis and set up as convenient. X axis leave one for all. The picture will not be the same as in the figure, the graphs will be smoother due to the logarithmic scale, but readable, especially if you add tooltips with values ​​to the markers. For graphs with a logarithmic Y axis, values ​​less than or equal to zero ( doc ) are not allowed.

Another option is to place several Area vertically in order to trace the connection along the X axis.

In order for the graphs to relate to each other along the X axis, they must either have the same number of points to build, or the points have explicitly specified values ​​along the X axis, and the starting and ending points of all graphs must have the same values ​​along X.

Most of the standard Chart squeeze will not work.


Well, the option for workaholic enthusiasts is the manual rendering of axes, graphs, and everything else you need on a regular Panel or UserControl . Although if you have fixed ranges of values ​​and do not need to automatically adjust the scale of the axes, this is also not the worst option, albeit more complicated, in terms of adding any ryushechek available in the ready out-of-the-box controls.

  • I decided to abandon the Y scale in general, the X scale for the four graphs is the same. The problem is that one chart changes from 0 to 5, and the other from 0 to 16000 .. how can I relate them so that you can clearly see it? With a logarithmic scale of Y Charts are not built at all - DarkSeed
  • @DarkSeed Π‘ логарифмичСской шкалой ΠΏΠΎ Y Π“Ρ€Π°Ρ„ΠΈΠΊΠΈ Π²ΠΎΠΎΠ±Ρ‰Π΅ Π½Π΅ строятся at all, this can not be. Probably somewhere wrong in the settings. Attach to the question a set of values ​​for each of the graphs, points 5-10, so that you can see for yourself - rdorn
  • @DarkSeed with the logagifmic scale has one more thing - the values ​​<= 0 are unacceptable. Therefore, the graph from 0 must be done along the additional axis. - rdorn