The results I want are one main chart and several sub charts which are synchronized with the main chart. (Sub charts must share the same x-axis with the main chart.)
At first, I tried it using multiple chartAreas
. I can sync sub chartAreas
with the main chartArea
. (Using this: How to align two (or more) charts in size, scroll and grid) This one is what I want exactly. But I can't only vertical scroll the sub-chartAreas
. If I scroll, all the charts are scrolled. I want to vertical scroll only sub-chartAreas
. (to show the main chartArea
at top anytime even when the scroll bar is down)
So, I reverse a decision to use multiple charts (not chart Areas). I can place them into TableLayoutPanel. One chart per row. Then, I cannot sync their x-axes...
Is there any way to sync an x-axis with multiple charts? Or to scroll only sub-chartAreas using multiple chartAreas?
By 'scroll' I mean Vertical scroll. See here:
From the image and the comments I gather that you actually want to scroll down a chart with several
ChartArea
but keep one fixed at the top.((If that is so you should correct the question title!))
By default a
Chart
can only scroll the data within a zoomedChartArea
, not severalChartAreas
within theChart
.Here is an example of faking both
ChartArea
scrolling and freeezing the topChartArea
.Here are the necessary steps:
We need a VerticalScrollbar control and anchor it to the right of the Chart.
We need to set its Minumum and Maximum fields to suitable values; I left the minimum at
0
and calculate the max with a few params..Then we can code its
Scroll
event..:visibleCount
controls how many ChartAreas are visible. In this example I have one for the year, fixed at the top and 12 more for the months..:For this to work you need to set up the chart so that the chartareas are intialized in a suitable way.
I used this piece of code, do use your own code for stuff like right space (I left 20% for the legend) etc..:
I draw extra rectangles around each CA, just for testing; do ignore them!
Note: Working with those percentages is always a little tricky and may take some tweaking!