gpt4 book ai didi

javascript - AM 图表在轴中显示固定范围

转载 作者:行者123 更新时间:2023-11-30 09:59:49 24 4
gpt4 key购买 nike

真的希望你能帮上忙!我正在使用 AMCharts 并且我通过一个简单的 php 函数添加了一些数据(从数据库中提取)我使用以下函数添加了一些上限和下限

  // HORIZONTAL GREEN RANGE
var guide = new AmCharts.Guide();
guide.value =11.00;
guide.toValue = 11.80;
guide.fillColor = "#00CC00";
guide.inside = true;
guide.fillAlpha = 0.2;
guide.lineAlpha = 0;
valueAxis.addGuide(guide);

var guideRED = new AmCharts.Guide();
guideRED.value = 11.80;
guideRED.toValue = 11.90;
guideRED.fillColor = "orange";
guideRED.inside = true;
guideRED.fillAlpha = 0.2;
guideRED.lineAlpha = 0;
valueAxis.addGuide(guideRED);

var guideblue = new AmCharts.Guide();
guideblue.value = 11.00;
guideblue.toValue = 10.90;
guideblue.fillColor = "orange";
guideblue.inside = true;
guideblue.fillAlpha = 0.2;
guideblue.lineAlpha = 0;
valueAxis.addGuide(guideblue);

但我需要将 Y(从上到下???)的显示范围分别设置为 11.90 和 10.50,以便运算符(operator)可以看到绘制的线及其与红色和橙色区域的关系。目前,该图只是将图表呈现为 +1 其在值形式中的最大值和最小值。

这是图形函数

AmCharts.ready(function () {
// SERIAL CHART
chart = new AmCharts.AmSerialChart();

chart.dataProvider = chartData;
chart.dataDateFormat = "DD-MM-YY";
chart.categoryField = "date";

// AXES
// category

var categoryAxis = chart.categoryAxis;
// categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
// categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
categoryAxis.gridAlpha = 0.1;
categoryAxis.minorGridAlpha = 0.1;
categoryAxis.axisAlpha = 0;
categoryAxis.minorGridEnabled = true;
categoryAxis.inside = true;


// value
var valueAxis = new AmCharts.ValueAxis();
valueAxis.tickLength = 4;
valueAxis.axisAlpha = 0;
valueAxis.showFirstLabel = false;
valueAxis.showLastLabel = false;
valueAxis.autoGridCount = true;
valueAxis.gridCount = 500;

chart.addValueAxis(valueAxis);

// GRAPH
var graph = new AmCharts.AmGraph();
graph.dashLength = 2;
graph.lineColor = "#00CC00";
graph.valueField = "value";
graph.dashLength = 3;
graph.bullet = "round";
graph.balloonText = "[[category]]<br><b><span style=\'font-size:14px;\'>value:[[value]]</span></b>";


chart.addGraph(graph);

(这一切都在一个标签内,因此转义字符的

非常感谢。

最佳答案

要将值轴强制为特定比例,首先设置它的 minimummaximum 属性。该图表仍将尝试使用整数。禁用该集 strictMinMax .

即:

var valueAxis = new AmCharts.ValueAxis();
valueAxis.minimum = 10.5;
valueAxis.maximum = 11.90;
valueAxis.strictMinMax = true;

关于javascript - AM 图表在轴中显示固定范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32252828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com