From Dark and Darker Wiki

No edit summary
(readded suggested bounds)
 
(65 intermediate revisions by the same user not shown)
Line 67: Line 67:
},
},
border: {
border: {
display:false,
color:axisColor
color:axisColor
},
},
afterBuildTicks: function(axis) {
var min = 100;
var max = 0;
for (let i = 0; i < axis.ticks.length; i++) {
if (axis.ticks[i].value < min) {
min = axis.ticks[i].value;
}
else if (axis.ticks[i].value > max) {
max = axis.ticks[i].value;
}
}
min = Math.ceil(Math.log2(min));
max = Math.floor(Math.log2(max));
axis.ticks = Array.from({ length: (max - min) + 1 }, (_, i) => min + i).map(v => ({ value: Math.pow(2,v) }));
},
suggestedMin:0.5,
suggestedMax:2,
ticks: {
ticks: {
color:fontColor,
color:fontColor,
Line 74: Line 92:
size: 18
size: 18
},
},
callback: (val, index) => {
callback: (val) => {
return (Math.log2(val)|0) === Math.log2(val) ? val : undefined;
return (Math.log2(val)|0) === Math.log2(val) ? val : undefined;
},
},
major: true
},
},
type: 'logarithmic'
type: 'logarithmic'
Line 90: Line 109:
},
},
border: {
border: {
display:false,
color:axisColor
color:axisColor
},
},
ticks: {
ticks: {
color:fontColor
color:fontColor,
font: {
size: 18
},
callback: function (val, index, ticks) {
console.log(val)
return val%5==0 ? this.getLabelForValue(Number(val)) : undefined;
}
}
}
}
}
Line 127: Line 154:


==Example==
==Example==
<pre>{{#widget:LogDatasetsChart|uniqueId=ExampleChart|title=This String Becomes the Title|datasets={"labels":[0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500],"datasets":[{"label":"Luck Grade 5","data":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],"borderColor":"#AD5AFF","backgroundColor":"#AD5AFFBB"},{"label":"Luck Grade 6","data":[1, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22],"borderColor":"#F7A22D","backgroundColor":"#F7A22DBB"}]}|}}</pre>
<pre>{{#widget:LogDatasetsChart|uniqueId=2Hoardtreasure_HR3|datasets={"labels":[0, "", 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],"datasets":[{"label":"2","data":[1.0, 0.84902, 0.739258, 0.657067, 0.592511, 0.541233, 0.498804, 0.46412, 0.434549, 0.409781, 0.388129, 0.369863, 0.353686, 0.339913, 0.327543, 0.317101, 0.307695, 0.299859, 0.29273, 0.286992, 0.281855],"borderColor":"#DEDEDE","backgroundColor":"#DEDEDEAA"},{"label":"3","data":[1.0, 0.859332, 0.758213, 0.682312, 0.623696, 0.577007, 0.539248, 0.508346, 0.482832, 0.461465, 0.443576, 0.428578, 0.416101, 0.405624, 0.397022, 0.390038, 0.384619, 0.380532, 0.377716, 0.376136, 0.375806],"borderColor":"#62BE0B","backgroundColor":"#62BE0BAA"},{"label":"4","data":[1.0, 1.069009, 1.119123, 1.156519, 1.185646, 1.208831, 1.227867, 1.243414, 1.256328, 1.267184, 1.276612, 1.28445, 1.291163, 1.296779, 1.301836, 1.305849, 1.309243, 1.312074, 1.31445, 1.316101, 1.317201],"borderColor":"#4A9BD1","backgroundColor":"#4A9BD1AA"},{"label":"5","data":[1.0, 1.100804, 1.172956, 1.227479, 1.269845, 1.30346, 1.330864, 1.353216, 1.372208, 1.388088, 1.401257, 1.412595, 1.422235, 1.430634, 1.437221, 1.443142, 1.448091, 1.45173, 1.454583, 1.456776, 1.458504],"borderColor":"#AD5AFF","backgroundColor":"#AD5AFFAA"},{"label":"6","data":[1.0, 1.13174, 1.226789, 1.29844, 1.354044, 1.398666, 1.43386, 1.463527, 1.48857, 1.508992, 1.526345, 1.54074, 1.553723, 1.564084, 1.573002, 1.580436, 1.586554, 1.591385, 1.595093, 1.597827, 1.599808],"borderColor":"#F7A22D","backgroundColor":"#F7A22DAA"}]}|title=Luck's Effect on Each Luck Grade|yAxisLabel=Probability at  X  Luck  /  Probability at  0  Luck|xAxisLabel=Luck}}</pre>
{{#widget:LogDatasetsChart|uniqueId=ExampleChart|title=This String Becomes the Title|datasets={"labels":[0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500],"datasets":[{"label":"Luck Grade 5","data":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],"borderColor":"#AD5AFF","backgroundColor":"#AD5AFFBB"},{"label":"Luck Grade 6","data":[1, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22],"borderColor":"#F7A22D","backgroundColor":"#F7A22DBB"}]}|}}
 
<div style="display:inline-block; vertical-align:top; min-width:550px; width:55%">
    {{#widget:LogDatasetsChart|uniqueId=2Hoardtreasure_HR3|datasets={"labels":[0, "", 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],"datasets":[{"label":"2","data":[1.0, 1, 0.739258, 0.657067, 0.592511, 0.541233, 0.498804, 0.46412, 0.434549, 0.409781, 0.388129, 0.369863, 0.353686, 0.339913, 0.327543, 0.317101, 0.307695, 0.299859, 0.29273, 0.286992, 0.281855],"borderColor":"#DEDEDE","backgroundColor":"#DEDEDEAA"},{"label":"3","data":[1.0, 0.859332, 0.758213, 0.682312, 0.623696, 0.577007, 0.539248, 0.508346, 0.482832, 0.461465, 0.443576, 0.428578, 0.416101, 0.405624, 0.397022, 0.390038, 0.384619, 0.380532, 0.377716, 0.376136, 0.375806],"borderColor":"#62BE0B","backgroundColor":"#62BE0BAA"},{"label":"4","data":[1.0, 1.069009, 1.119123, 1.156519, 1.185646, 1.208831, 1.227867, 1.243414, 1.256328, 1.267184, 1.276612, 1.28445, 1.291163, 1.296779, 1.301836, 1.305849, 1.309243, 1.312074, 1.31445, 1.316101, 1.317201],"borderColor":"#4A9BD1","backgroundColor":"#4A9BD1AA"},{"label":"5","data":[1.0, 1.100804, 1.172956, 1.227479, 1.269845, 1.30346, 1.330864, 1.353216, 1.372208, 1.388088, 1.401257, 1.412595, 1.422235, 1.430634, 1.437221, 1.443142, 1.448091, 1.45173, 1.454583, 1.456776, 1.458504],"borderColor":"#AD5AFF","backgroundColor":"#AD5AFFAA"},{"label":"6","data":[1.0, 1.13174, 1.226789, 1.29844, 1.354044, 1.398666, 1.43386, 1.463527, 1.48857, 1.508992, 1.526345, 1.54074, 1.553723, 1.564084, 1.573002, 1.580436, 1.586554, 1.591385, 1.595093, 1.597827, 1.599808],"borderColor":"#F7A22D","backgroundColor":"#F7A22DAA"}]}|title=Luck's Effect on Each Luck Grade|yAxisLabel=Probability at  X  Luck  /  Probability at  0  Luck|xAxisLabel=Luck}}</div>
</noinclude>
</noinclude>

Latest revision as of 09:22, 21 September 2024

Parameters

uniqueId
  • Determines canvas element name
  • Name needs to be unique if multiple widgets are to be displayed on the same page.
title
  • Default: "" empty string
  • String of text to display as the title of the graph.
  • This string also serves to detemine whether or not to show the legend.
    If no string is provided both the legend and the title are not displayed.
yAxisLabel
  • Default: "" empty string
  • String of text to display on the y-axis. Text is rendered vertically, bottom to top.
xAxisLabel
  • Default: "" empty string
  • String of text to display on the x-axis.
gridColor
  • Default: '#80808080'
axisColor
  • Default: var gridColor
fontColor
  • Default: 'white'
datasets
  • String of text that is a properly formatted JSON object when parsed by JSON.parse(). The graph will not render if an improper JSON object is passed.
    It is recommended that you check the string format with some sort of tool like JSON Lint, or whatever else you prefer.
  • The first set of objects within the JSON object must have the "datasets" array pair.


Example

{{#widget:LogDatasetsChart|uniqueId=2Hoardtreasure_HR3|datasets={"labels":[0, "", 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500],"datasets":[{"label":"2","data":[1.0, 0.84902, 0.739258, 0.657067, 0.592511, 0.541233, 0.498804, 0.46412, 0.434549, 0.409781, 0.388129, 0.369863, 0.353686, 0.339913, 0.327543, 0.317101, 0.307695, 0.299859, 0.29273, 0.286992, 0.281855],"borderColor":"#DEDEDE","backgroundColor":"#DEDEDEAA"},{"label":"3","data":[1.0, 0.859332, 0.758213, 0.682312, 0.623696, 0.577007, 0.539248, 0.508346, 0.482832, 0.461465, 0.443576, 0.428578, 0.416101, 0.405624, 0.397022, 0.390038, 0.384619, 0.380532, 0.377716, 0.376136, 0.375806],"borderColor":"#62BE0B","backgroundColor":"#62BE0BAA"},{"label":"4","data":[1.0, 1.069009, 1.119123, 1.156519, 1.185646, 1.208831, 1.227867, 1.243414, 1.256328, 1.267184, 1.276612, 1.28445, 1.291163, 1.296779, 1.301836, 1.305849, 1.309243, 1.312074, 1.31445, 1.316101, 1.317201],"borderColor":"#4A9BD1","backgroundColor":"#4A9BD1AA"},{"label":"5","data":[1.0, 1.100804, 1.172956, 1.227479, 1.269845, 1.30346, 1.330864, 1.353216, 1.372208, 1.388088, 1.401257, 1.412595, 1.422235, 1.430634, 1.437221, 1.443142, 1.448091, 1.45173, 1.454583, 1.456776, 1.458504],"borderColor":"#AD5AFF","backgroundColor":"#AD5AFFAA"},{"label":"6","data":[1.0, 1.13174, 1.226789, 1.29844, 1.354044, 1.398666, 1.43386, 1.463527, 1.48857, 1.508992, 1.526345, 1.54074, 1.553723, 1.564084, 1.573002, 1.580436, 1.586554, 1.591385, 1.595093, 1.597827, 1.599808],"borderColor":"#F7A22D","backgroundColor":"#F7A22DAA"}]}|title=Luck's Effect on Each Luck Grade|yAxisLabel=Probability at  X  Luck  /  Probability at  0  Luck|xAxisLabel=Luck}}