简体   繁体   English

使用C#的ASP.NET图表操作

[英]ASP.NET Chart Manipulation with c#

To explain my question I drew an image, here it is: 为了解释我的问题,我画了一个图,它是:

在此处输入图片说明

So I have a Chart that has a bar graph and a line chart, 2 in 1. I am trying to displaly it in asp.net just the way i drew it on here. 所以我有一个图表,其中有一个条形图和一个折线图,二合一。我正尝试将其绘制在asp.net中,就像我在此处绘制它一样。 This means the A box on the image has a set of values which reflect the line graph, and C box on the image has a set of values that define the bar graph values. 这意味着图像上的A框具有一组反映折线图的值,而图像上的C框具有一组定义条形图值的值。

What I want to ask is how do I set two different sets of values on a single chart. 我想问的是如何在单个图表上设置两组不同的值。 I know I can use series to draw multiple graphs and by having series defined as different types I can change if its a bar graph or a ilne chart, however I don't know how to add 2 range of values on the side. 我知道我可以使用级数绘制多个图形,并且通过将级数定义为不同的类型,可以更改它的条形图还是ilne图,但是我不知道如何在侧面添加2个值的范围。

As for the the box B, what I wish to ask is how do I set these values so that they are showing different dates, I was able to do it using a line of code shown bellow, however that line of code sets every value to same, and I need them to reflect different values such as range of dates in this example on the image. 至于方框B,我想问的是如何设置这些值,以便它们显示不同的日期,我可以使用下面显示的代码行来实现,但是该代码行将每个值设置为相同,我需要它们在图像上反映不同的值,例如本示例中的日期范围。

Code that I tried is: Chart1.Series["Series1"].AxisLabel = "Test"; 我尝试过的代码是: Chart1.Series["Series1"].AxisLabel = "Test";

Help is most appreciated! 非常感谢您的帮助!

Cheers! 干杯!

Ok so i'm going to leave this question up for those that come into similar problem. 好的,所以我将把这个问题留给那些遇到类似问题的人解决。

This is how you set column A and column c 这是设置A列和c列的方式

Chart1.Series[0].YAxisType = AxisType.Primary;
    Chart1.Series[1].YAxisType = AxisType.Secondary;

    Chart1.ChartAreas[0].AxisY.Maximum = 500;
    Chart1.ChartAreas[0].AxisY2.Maximum = 7000;

Your grid lines might get messed up so if you want to disable them use 您的网格线可能会弄乱,因此,如果要禁用它们,请使用

Chart1.ChartAreas[0].AxisY2.MajorGrid.Enabled = false;

And just as a bonus if you want to set intervals on each Y axis you can do that with 作为奖励,如果您想在每个Y轴上设置间隔,可以使用

Chart1.ChartAreas[0].AxisY.Interval = 50;

I still haven't figured out how to do part B that I mentioned, so if you know the answer then please share. 我仍然没有弄清楚我提到的B部分,因此,如果您知道答案,请分享。

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM