How to return (change) conditional values? #386
Replies: 4 comments 12 replies
-
Wow, you started on expert mode :)
Google (or search these discussions)
you can set
try with: ({ meta }) => ({
xs: meta.data.map(({ start_time }) => new Date(start_time)),
ys: meta.data.map(({ start_time }, i) =>
[16, 17, 18].includes(new Date(start_time).getHours()) ? 12 : 0
),
}); |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Managed to fudge the bars to overlap as I envisaged, but the hourly bar "starts" half an hour "early". |
Beta Was this translation helpful? Give feedback.
-
Firstly I'm impressed with this card, I have been a big ApexCharts card user but a crippling javascript bug and unaddressed limitations are forcing me to look for alternatives So I'm trying reproduce and improve the graphs I want with added interactive element of this plotly card.
Anyway, one of the things I could do with apex was set a data_generator and get it to spit out anything. One of the things I want to do here is add a series of fixed additions only when certain conditions are met, in example here, the condition is time of day. I add blocks of 12, but only ad certain hours (16, 17 and 18:00). I tried to use the same basic code and make an array of timestamps and values of either 0 or 12 but can't figure out how to output that in the plotly series (entity) it just shows the original entity contents.
This is what I want to achieve:
![image](https://private-user-images.githubusercontent.com/27061628/310513493-a2742ced-55e6-458d-b03c-52d743723dc7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTczMTYsIm5iZiI6MTczOTYxNzAxNiwicGF0aCI6Ii8yNzA2MTYyOC8zMTA1MTM0OTMtYTI3NDJjZWQtNTVlNi00NThkLWIwM2MtNTJkNzQzNzIzZGM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEwNTY1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMyMzA1ZjczOTZjMTUxNTAxMTA1MDlhNDJmMzlmM2E3ZTdkMDk2ODYzYmNhYTk3ZGZlZTZlMTUzODNhNjRiNGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.UxehAiMpw-sPaE0QX1O_Gc5QzrlkEwdu6bTon6Z06X0)
The filters:
The original data set ( for this series, I'm only interested in the datetime and whether or not the "bump" applies
![image](https://private-user-images.githubusercontent.com/27061628/310519632-6367003e-6a11-47c6-86c5-ba71be7f9068.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTczMTYsIm5iZiI6MTczOTYxNzAxNiwicGF0aCI6Ii8yNzA2MTYyOC8zMTA1MTk2MzItNjM2NzAwM2UtNmExMS00N2M2LTg2YzUtYmE3MWJlN2Y5MDY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEwNTY1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZmOWRlNjNlZTEzYzM3MDdjODlhMzI4NDIxYjFlZjg3MDYyNThlNTExZjJjOGYzM2UzNzljYzlhZmVmODJhMmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.W3Ir22METzzmRez_Qx_hpAWNm0qwOa5T08-GUJLlvgw)
Apex chart was happy to replace the whole entity with a timestamp, value array, but I think with plotly I need to be more precise. How would I best go about this with the plotly card and filters?
![image](https://private-user-images.githubusercontent.com/27061628/310523665-9de0c8ec-051e-4874-9b32-db966d870531.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTczMTYsIm5iZiI6MTczOTYxNzAxNiwicGF0aCI6Ii8yNzA2MTYyOC8zMTA1MjM2NjUtOWRlMGM4ZWMtMDUxZS00ODc0LTliMzItZGI5NjZkODcwNTMxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEwNTY1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc5YzdkYWUyODZkYmZlZmJiNzBlYTYzZjYxZDNhMGZjYTc3ZTgwNDA3NTg2YmQ0OWQ4OWQzMjg3NGFhZjZiZDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.VGtNiMSK4uKcWICbWcEXpct5b5UfaAUz2WvSX090Ias)
multi stacks and overlaid series with different semi-transparent colours are things I would want to use here too, but one thing at a time 😀
Beta Was this translation helpful? Give feedback.
All reactions