简体   繁体   English

如何使用JavaScript设置ASP图表的X轴(或Y轴)值

[英]How can I set the x-axis (or y-axis) value of an asp chart using javascript

I have a simple asp chart 我有一个简单的asp图表

<asp:Chart ID="chtRISKSCORE" runat="server" Width="450px" BackColor="#1E1E1E" Height="400px">
    <Titles>
        <asp:Title ForeColor="White" Text="Risk Score" Font="Tahoma, 12pt"/>
    </Titles>
        <BorderSkin PageColor="Transparent" BackColor="Transparent" BackHatchStyle="None" />
    <Series>
        <asp:Series Name="Categories" ChartType="Column Palette="EarthTones" ChartArea="MainChartArea" LabelForeColor="White" LabelBackColor="White"></asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="MainChartArea" BackColor="Transparent" Area3DStyle-Enable3D="false">
            <Area3DStyle Enable3D="false"></Area3DStyle>
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>

What I'd like to do is allow the user to set where a point crosses (ie set an x and ay value). 我想做的是允许用户设置点的交叉点(即设置x和ay值)。 I have two sliders that will eventually (with your help) set the x and y value of the point on the chart. 我有两个滑块,最终将在您的帮助下设置图表上该点的x和y值。

Any Javascript examples would be perfect. 任何Javascript示例都是完美的。 I can't seem to find anything on this issue so far. 到目前为止,我似乎找不到任何关于此问题的信息。

I've started with this but now I'm stuck. 我已经开始了,但是现在我陷入了困境。 So I add an 'onValueChanged' event to a slider. 因此,我向滑块添加了“ onValueChanged”事件。 I've then located the asp chart but how can I set the x(or y)-axis value? 然后,我找到了asp图表,但是如何设置x(或y)轴值?

function pageLoad(sender, e) {
    var slider = $find("<%=sleNEWSCOREIMPACTSLIDER.ClientID%>");
    slider.add_valueChanged(onValueChanged);
}

function onValueChanged(sender, e) {
    var slider = $find("<%=sleNEWSCOREIMPACTSLIDER.ClientID%>");
    var slidervalue = slider.value;
    var chart = $find("<%=chtRISKSCORE.ClientID%>");
    var series = chart.options.series;
}

You can not modify the chart at client side using the JavaScript. 您无法使用JavaScript在客户端修改图表。 The chart is an image generated at server. 图表是在服务器上生成的图像。 So after sliding you need to go back to the server and generate the chart again as per sliding value. 因此,滑动后,您需要返回服务器并根据滑动值再次生成图表。 If you want a chart that interacts with user input at client side and can be controlled with simple JavaScript and jquery then you need to use jquery graphs like jqplot etc. 如果您希望图表与客户端的用户输入进行交互并且可以通过简单的JavaScript和jquery进行控制,则需要使用jqplot等jquery图。

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

相关问题 D3 图表 - 如何将 X 轴置于 Y 轴下方? - D3 chart - How can I put the X-axis below the Y-axis? X 轴上的时间和 Y 轴上带有超链接的值的图表 - Chart with time on X-axis and value on Y-axis with hyperlinks 如何使用highcharts.js在x轴和y轴的末端获得箭头? - How can I get arrows at the end of x-axis and y-axis using highcharts.js? 我无法使用JChartFX在多个Y轴和日期X轴图表中显示任何内容 - I can't display anything in a Multiple Y-axis and Date X-axis chart with JChartFX 如何自定义 y 轴标签并从 Chart js 中 x 轴的数据范围中随机选取值 - How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js 如何在chart.js中使y轴与x轴在0处相交 - How do I make the y-axis intersect the x-axis at 0 in chart.js 如何在javascript中使用谷歌图表将x轴点交换到y轴 - How to interchange x-axis points to y-axis using google charts in javascript 如何在 x 轴和 y 轴上添加轴标签? (图表.js) - How do you add Axis Labels on to both x-axis and y-axis? (Chart.js) 移动 x 轴以通过 chart.js 中的给定 y 轴值 - Move x-axis to pass through given y-axis value in chart.js highchart-散点图:设置x轴和y轴的小数 - highchart - scatter : set decimals of x-axis and y-axis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM