Y軸に算術(一定の目盛り)を使用してさまざまなチャートを作成しました。ここで、対数 Y 軸を持つものを作成したいと思います。
例: 1 と 2 の間の距離は、2 と 4 と同じにする必要があります。
スケーリング方法に関するアイデア
ありがとう
Y軸に算術(一定の目盛り)を使用してさまざまなチャートを作成しました。ここで、対数 Y 軸を持つものを作成したいと思います。
例: 1 と 2 の間の距離は、2 と 4 と同じにする必要があります。
スケーリング方法に関するアイデア
ありがとう
Morris.jsを使用してグラフを描画できます。
次に、Morris を拡張し、transY 関数を変更して、次のように対数スケールを実行できます。
(function () {
var $, MyMorris;
MyMorris = window.CbyMorris = {};
$ = jQuery;
MyMorris = Object.create(Morris);
MyMorris.Grid.prototype.gridDefaults["yLogScale"] = false;
MyMorris.Grid.prototype.transY = function (y) {
if (!this.options.horizontal) {
if (this.options.yLogScale) {
return this.bottom - (this.height * Math.log((y + 1) - this.ymin) / Math.log(this.ymax / (this.ymin + 1)));
} else {
return this.bottom - (y - this.ymin) * this.dy;
}
} else {
return this.left + (y - this.ymin) * this.dy;
}
};
}).call(this);
次にyLogScale
、Morris config でパラメーターを true に設定します。
yLogScale: true
結果を確認するには、私の完全な回答を参照してください: https://stackoverflow.com/a/39878478/1351076
「算術」は特定のプログラムまたはプラグインを指しますか? それ以外の場合は、x 値と y 値のリストがあることを意味する場合は、y 値を対数関数に通してプロットします。どの言語でプログラミングしていますか?
こんにちは、申し訳ありませんが、返信に時間がかかりました。これはあなたが探しているコードですか?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var test = {
x_values: [0,10,20,30,40,50,60,70,80,90,100],
y_values: [0,10,20,30,40,50,60,70,80,90,100],
convert_values_to_log10: function (values) {
var i=0;
var converted_values = []
for (i=0; i<values.length; i++) {
converted_values[i] = Math.log(values[i])/Math.LN10
}
return converted_values;
}
}
$(document).ready(function(){
$('#x_vals').text(test.x_values.toString());
$('#y_vals').text(test.y_values.toString());
$('#y10_vals').text(test.convert_values_to_log10(test.y_values).toString());
});
</script>
</head>
<body>
<h2>x values = </h2>
<p id="x_vals"></p>
<h2>y values = </h2>
<p id="y_vals"></p>
<h2>log10 y values = </h2>
<p id="y10_vals"></p>
</body>
</html>