JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ecomfe.github.io/echarts-examples/public/vendors/echarts/echarts.min.js?_v_=1539619315213"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js"></script>
<body>
</body>
JavaScript
/**
*
* @param name
* @param type
* @param displayName
* @param color
* @param hide
* @param format
* @constructor
*/
function Dimension(name, type, displayName, color, hide, format)
{
if(typeof name === typeof {})
{
type = name.type || null;
displayName = name.displayName || null;
color = name.color || null;
hide = name.hide || false;
format = name.format || null;
//TODO: keep this line last, because otherwise name is overwritten and parameters are useless
name = name.name || null;
}
/** @type (string) */
this.name = name;
/** @type (string) */
this.type = type;
/** @type (string) */
this.displayName = displayName;
/** @type (string) */
this.color = color;
/** @type {bool}*/
this.hide = hide;
/** @type {AxisLabelFormat} */
this.format = format;
}
/**
*
* @param d
* @return {EChartsData}
* @constructor
*/
var EChartsData = function (d){
this.keyColumn = null;
this.data = [];
/** @type {Array.<Dimension>} */
this.dimensions = [];
this.getKeyColumn = function(){
if (this.keyColumn)
{
return this.keyColumn;
}
throw "Property 'keyColumn' of data-set is not defined.";
};
this.setData = function(d)
{
if(d.hasOwnProperty('source'))
{
this.data = d.source;
}
else
{
this.data = d;
}
if (d.hasOwnProperty('keyColumn'))
{
this.keyColumn = d.keyColumn;
}
if(d.hasOwnProperty('dimensions'))
{
for(var i = 0; i < d.dimensions.length; i++)
{
var dimension = d.dimensions[i];
this.dimensions.push(new Dimension(dimension));
}
}
};
this.find = function (by, value){
var result = false;
if (typeof by !== typeof {})
{
var temp = {};
temp[by] = value;
by = temp;
}
if(Array.isArray(this.data))
{
result = [];
for(var i = 0; i < this.data.length; i++)
{
var row = this.data[i];
var passed = true;
for(var column in by)
{
if (by.hasOwnProperty(column))
{
var val =...